Class Hierarchy Previous Next Index
Aggregators are user defined set/column functions that are invoked to generate a scalar from a set of values. The Aggregator is used at execution time (AggregateDefinition is used at compile time).
Aggregators provide the methods used to perform aggregation, as well as to store any temporary data used in aggregation. For example, a MAX() aggregator both implements the methods in this interface and stores the temporary result that will be returned by the Aggregator.getResult() method.
Aggregators live for the duration of the aggregation. If an aggregate requires a sort that is large enough, an aggregator may be written to disk while the sort is being processed. Therefore, an aggregator must implement Serializable at a minimum (Externalizable is preferable). An aggregator is never permanently stored on disk.
Aggregators may take any datatype that can be stored in Cloudscape, including serialized Objects. Aggregators may return any type of Object. The input type and the return type must be the same for the duration of a single aggregation. For example,
NOTE: An Aggregator must implement a zero argument public constructor.
Cloudscape reserves the right to change, rename, or remove this interface at any time.
public void initialize()
public void accumulate(java.sql.ResultSet addend) throws java.lang.Throwable
addend
- The addend (current input to the aggregation)
in a one row, one column java.sql.ResultSet wrapper.
NOTE: next() has already
been called on this result set (i.e. it is
already positioned on the only row), so all you need
to do to retrieve a value is to call getXXX(1).
public void merge(Aggregator inputAggregator) throws java.lang.Throwable
An example of a merge would be: given two COUNT() aggregators, C1 and C2, a merge of C1 into C2 would set C1.count += C2.count. So, given a CountAggregator with a getCount() method that returns its counts, its merge method might look like this:
public void merge(Aggregator inputAggregator) throws StandardException { count += ((CountAccgregator)inputAggregator).getCount(); }
inputAggregator
- the other Aggregator
(input partial aggregate)
public java.lang.Object getResult()
public Aggregator newInstance()
Just implement it to do new myClass().
Class Hierarchy Previous Next Index