java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat, ExecAggregatorpublic final class AvgAggregator extends SumAggregator
| Modifier and Type | Field | Description |
|---|---|---|
private long |
count |
|
private int |
scale |
value| Constructor | Description |
|---|---|
AvgAggregator() |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
accumulate(DataValueDescriptor addend) |
Accumulate
|
DataValueDescriptor |
getResult() |
Return the result of the aggregation.
|
int |
getTypeFormatId() |
Get the formatID which corresponds to this 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) |
|
void |
writeExternal(java.io.ObjectOutput out) |
Although we are not expected to be persistent per se,
we may be written out by the sorter temporarily.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsetuptoStringaccumulate, didEliminateNullsprotected void accumulate(DataValueDescriptor addend) throws StandardException
SumAggregatoraccumulate in class SumAggregatoraddend - value to be added inStandardException - on errorExecAggregator.accumulate(org.apache.derby.iapi.types.DataValueDescriptor, java.lang.Object)public void merge(ExecAggregator addend) throws StandardException
ExecAggregatorAn 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 ExecAggregatormerge in class OrderableAggregatoraddend - the other Aggregator
(input partial aggregate)StandardException - on errorExecAggregator.merge(org.apache.derby.iapi.sql.execute.ExecAggregator)public DataValueDescriptor getResult() throws StandardException
getResult in interface ExecAggregatorgetResult in class OrderableAggregatorStandardException - on errorpublic ExecAggregator newAggregator()
ExecAggregatornewAggregator in interface ExecAggregatornewAggregator in class SumAggregatorpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
OrderableAggregatorWhy 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.
writeExternal in interface java.io.ExternalizablewriteExternal in class OrderableAggregatorjava.io.IOException - on errorExternalizable.writeExternal(java.io.ObjectOutput)public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.ExternalizablereadExternal in class OrderableAggregatorjava.io.IOException - on errorjava.lang.ClassNotFoundException - on errorExternalizable.readExternal(java.io.ObjectInput)public int getTypeFormatId()
getTypeFormatId in interface TypedFormatgetTypeFormatId in class SumAggregatorApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.