Class OrderableAggregator
java.lang.Object
org.apache.derby.impl.sql.execute.SystemAggregator
org.apache.derby.impl.sql.execute.OrderableAggregator
- All Implemented Interfaces:
Externalizable
,Serializable
,Formatable
,TypedFormat
,ExecAggregator
- Direct Known Subclasses:
MaxMinAggregator
,SumAggregator
Abstract aggregator for Orderable aggregates (max/min).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the result of the operations that we have been performing.void
merge
(ExecAggregator addend) Merges one aggregator into a another aggregator.void
void
setup
(ClassFactory cf, String aggregateName, DataTypeDescriptor returnDataType) Set's up the aggregate for processing.toString()
void
Although we are not expected to be persistent per se, we may be written out by the sorter temporarily.Methods inherited from class org.apache.derby.impl.sql.execute.SystemAggregator
accumulate, accumulate, didEliminateNulls
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.derby.iapi.sql.execute.ExecAggregator
newAggregator
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
-
Field Details
-
value
-
-
Constructor Details
-
OrderableAggregator
OrderableAggregator()
-
-
Method Details
-
setup
Description copied from interface:ExecAggregator
Set's up the aggregate for processing.- Parameters:
cf
- 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.
-
merge
Description copied from interface:ExecAggregator
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:
addend
- the other Aggregator (input partial aggregate)- Throws:
StandardException
- on error- See Also:
-
getResult
Return the result of the operations that we have been performing. Returns a DataValueDescriptor.- Returns:
- the result as a DataValueDescriptor
- Throws:
StandardException
- on error
-
toString
- Overrides:
toString
in classSystemAggregator
-
writeExternal
Although we are not expected to be persistent per se, we may be written out by the sorter temporarily. So we need to be able to write ourselves out and read ourselves back in. We rely on formatable to handle situations where value is null.Why would we be called to write ourselves out if we are null? For scalar aggregates, we don't bother setting up the aggregator since we only need a single row. So for a scalar aggregate that needs to go to disk, the aggregator might be null.
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classSystemAggregator
- Throws:
IOException
- on error- See Also:
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classSystemAggregator
- Throws:
IOException
- on errorClassNotFoundException
- on error- See Also:
-