org.apache.derby.iapi.sql.execute
Interface ExecAggregator

All Superinterfaces:
java.io.Externalizable, Formatable, java.io.Serializable, TypedFormat
All Known Implementing Classes:
AvgAggregator, CountAggregator, MaxMinAggregator, OrderableAggregator, SumAggregator, SystemAggregator

public interface ExecAggregator
extends Formatable

An ExecAggregator is the interface that execution uses to an aggregate. System defined aggregates will implement this directly.

The life time of an ExecAggregator is as follows.

  1. An ExecAggregator instance is created using the defined class name.
  2. Its setup() method is called to define its role (COUNT(*), SUM, etc.).
  3. Its newAggregator() method may be called any number of times to create new working aggregators as required. These aggregators have the same role and must be created in an initialized state.
  4. accumlate and merge will be called across these set of aggregators
  5. One of these aggregators will be used as the final one for obtaining the result


Method Summary
 void accumulate(DataValueDescriptor addend, java.lang.Object ga)
          Iteratively accumulates the addend into the aggregator.
 boolean didEliminateNulls()
          Return true if the aggregation eliminated at least one null from the input data set.
 DataValueDescriptor getResult()
          Produces the result to be returned by the query.
 void merge(ExecAggregator inputAggregator)
          Merges one aggregator into a another aggregator.
 ExecAggregator newAggregator()
          Return a new initialized copy of this aggregator, any state set by the setup() method of the original Aggregator must be copied into the new aggregator.
 void setup(java.lang.String aggregateName)
          Set's up the aggregate for processing.
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
 

Method Detail

setup

void setup(java.lang.String aggregateName)
Set's up the aggregate for processing.


accumulate

void accumulate(DataValueDescriptor addend,
                java.lang.Object ga)
                throws StandardException
Iteratively accumulates the addend into the aggregator. Called on each member of the set of values that is being aggregated.

Parameters:
addend - the DataValueDescriptor addend (current input to the aggregation)
ga - a result set getter
Throws:
StandardException - on error

merge

void merge(ExecAggregator inputAggregator)
           throws StandardException
Merges one aggregator into a another aggregator. Merges two partial aggregates results into a single result. Needed for:

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(ExecAggregator inputAggregator) throws StandardException
                {
                   count += ((CountAccgregator)inputAggregator).getCount();
                } 

Parameters:
inputAggregator - the other Aggregator (input partial aggregate)
Throws:
StandardException - on error

getResult

DataValueDescriptor getResult()
                              throws StandardException
Produces the result to be returned by the query. The last processing of the aggregate.

Throws:
StandardException - on error

newAggregator

ExecAggregator newAggregator()
Return a new initialized copy of this aggregator, any state set by the setup() method of the original Aggregator must be copied into the new aggregator.

Returns:
ExecAggregator the new aggregator

didEliminateNulls

boolean didEliminateNulls()
Return true if the aggregation eliminated at least one null from the input data set.


Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.