Interface ExecAggregator
-
- All Superinterfaces:
java.io.Externalizable
,Formatable
,java.io.Serializable
,TypedFormat
- All Known Implementing Classes:
AvgAggregator
,CountAggregator
,MaxMinAggregator
,OrderableAggregator
,SumAggregator
,SystemAggregator
,UserDefinedAggregator
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.
- An ExecAggregator instance is created using the defined class name.
- Its setup() method is called to define its role (COUNT(*), SUM, etc.).
- 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.
- accumlate and merge will be called across these set of aggregators
- One of these aggregators will be used as the final one for obtaining the result
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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(ClassFactory classFactory, java.lang.String aggregateName, DataTypeDescriptor returnDataType)
Set's up the aggregate for processing.-
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
-
-
-
-
Method Detail
-
setup
void setup(ClassFactory classFactory, java.lang.String aggregateName, DataTypeDescriptor returnDataType)
Set's up the aggregate for processing.- Parameters:
classFactory
- Database-specific class factory.aggregateName
- For builtin aggregates, this is a SQL aggregate name like MAX. For user-defined aggregates, this is the name of the user-written class which implements org.apache.derby.agg.Aggregator.returnDataType
- The type returned by the getResult() method.
-
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:- parallel aggregation
- vector aggregation (GROUP BY)
- distinct aggregates (e.g. MAX(DISTINCT Col))
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.
-
-