java.io.Externalizable
, java.io.Serializable
, Formatable
, TypedFormat
, ExecAggregator
public final class UserDefinedAggregator extends java.lang.Object implements ExecAggregator
Modifier and Type | Field | Description |
---|---|---|
private Aggregator |
_aggregator |
|
private boolean |
_eliminatedNulls |
|
private DataTypeDescriptor |
_resultType |
|
private static int |
FIRST_VERSION |
Constructor | Description |
---|---|
UserDefinedAggregator() |
0-arg constructor for Formatable interface
|
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() |
Return the result of the aggregation. .
|
int |
getTypeFormatId() |
Get the formatID which corresponds to this class.
|
private void |
logAggregatorInstantiationError(java.lang.String aggregateName,
java.lang.Throwable t) |
Record an instantiation error trying to load the aggregator class.
|
void |
merge(ExecAggregator addend) |
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 |
readExternal(java.io.ObjectInput in) |
|
private void |
setup(java.lang.Class<?> udaClass,
DataTypeDescriptor resultType) |
Initialization logic shared by setup() and newAggregator()
|
void |
setup(ClassFactory classFactory,
java.lang.String aggregateName,
DataTypeDescriptor resultType) |
Set's up the aggregate for processing.
|
void |
writeExternal(java.io.ObjectOutput out) |
private static final int FIRST_VERSION
private Aggregator _aggregator
private DataTypeDescriptor _resultType
private boolean _eliminatedNulls
public UserDefinedAggregator()
public void setup(ClassFactory classFactory, java.lang.String aggregateName, DataTypeDescriptor resultType)
ExecAggregator
setup
in interface ExecAggregator
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.resultType
- The type returned by the getResult() method.private void setup(java.lang.Class<?> udaClass, DataTypeDescriptor resultType)
public boolean didEliminateNulls()
ExecAggregator
didEliminateNulls
in interface ExecAggregator
public void accumulate(DataValueDescriptor addend, java.lang.Object ga) throws StandardException
ExecAggregator
accumulate
in interface ExecAggregator
addend
- the DataValueDescriptor addend (current input to
the aggregation)ga
- a result set getterStandardException
- on errorpublic void merge(ExecAggregator addend) throws StandardException
ExecAggregator
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(); }
merge
in interface ExecAggregator
addend
- the other Aggregator
(input partial aggregate)StandardException
- on errorpublic DataValueDescriptor getResult() throws StandardException
getResult
in interface ExecAggregator
StandardException
- on errorpublic ExecAggregator newAggregator()
ExecAggregator
newAggregator
in interface ExecAggregator
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
- on errorpublic void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
- on errorjava.lang.ClassNotFoundException
Externalizable.readExternal(java.io.ObjectInput)
public int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
private void logAggregatorInstantiationError(java.lang.String aggregateName, java.lang.Throwable t)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.