com.sun.btrace.aggregation
Class Aggregation

java.lang.Object
  extended by com.sun.btrace.aggregation.Aggregation
All Implemented Interfaces:
java.lang.Cloneable

public class Aggregation
extends java.lang.Object
implements java.lang.Cloneable

BTrace stores the results of aggregating functions in an Aggregation. The aggregated values may be grouped using a composite AggregationKey.

Author:
Christian Glencross

Constructor Summary
Aggregation(AggregationFunction type)
          Creates an aggregation.
 
Method Summary
 void add(AggregationKey key, long data)
          Adds an item of data to the aggregation with the specified grouping key.
 void add(long data)
          Adds an item of data to the aggregation with an empty key.
 void clear()
          Resets all values in the aggregation to their default.
protected  java.lang.Object clone()
           
 java.util.List<java.lang.Object[]> getData()
          Returns details of the aggregation in a tabular format which can be serialized across the wire and formatted for display.
 java.util.List<AggregationKey> getKeyData()
          Returns a list of the AggregationKeys that belong to this aggregation.
 java.lang.Long getValueForKey(AggregationKey key)
          Returns a value for the given key if the key has a value associated with it.
 void truncate(int count)
          Reduces the size of the aggregation to the absolute value of count.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Aggregation

public Aggregation(AggregationFunction type)
Creates an aggregation.

Parameters:
type - the type of aggregation function to use
Method Detail

add

public void add(long data)
Adds an item of data to the aggregation with an empty key. This method is recommended if the aggregation will contain only a single value.

Parameters:
data - the value to be added

add

public void add(AggregationKey key,
                long data)
Adds an item of data to the aggregation with the specified grouping key.

Parameters:
key - the aggregation key
data - the value to be added

clear

public void clear()
Resets all values in the aggregation to their default.


truncate

public void truncate(int count)
Reduces the size of the aggregation to the absolute value of count. If count is greater than zero, the largest aggregated values are preserved. If it is less than zero, the smallest aggregated values are preserved. Passing a value of zero clears the aggregation completely.

Parameters:
count - the absolute number indicates the number of aggregated values to preserve.

getData

public java.util.List<java.lang.Object[]> getData()
Returns details of the aggregation in a tabular format which can be serialized across the wire and formatted for display. The data is represented as a List of rows. The last element in each row represents the aggregated value, the elements before this in the row contain the elements of the aggregating key.

Returns:
details of the aggregation in a tabular format.

getKeyData

public java.util.List<AggregationKey> getKeyData()
Returns a list of the AggregationKeys that belong to this aggregation.

Returns:
a list of aggregationsKeys belonging to this aggregation.

getValueForKey

public java.lang.Long getValueForKey(AggregationKey key)
Returns a value for the given key if the key has a value associated with it. Returns zero if the key is not valid for this Aggregation.

Parameters:
key -
Returns:
the value for the given key, or zero.

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException