java.io.Externalizable
, java.io.Serializable
, Formatable
, TypedFormat
, ExecAggregator
public 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, wait
setup
toString
accumulate, didEliminateNulls
protected void accumulate(DataValueDescriptor addend) throws StandardException
SumAggregator
accumulate
in class SumAggregator
addend
- value to be added inStandardException
- on errorExecAggregator.accumulate(org.apache.derby.iapi.types.DataValueDescriptor, java.lang.Object)
public 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
merge
in class OrderableAggregator
addend
- 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 ExecAggregator
getResult
in class OrderableAggregator
StandardException
- on errorpublic ExecAggregator newAggregator()
ExecAggregator
newAggregator
in interface ExecAggregator
newAggregator
in class SumAggregator
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
OrderableAggregator
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.
writeExternal
in interface java.io.Externalizable
writeExternal
in class OrderableAggregator
java.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.Externalizable
readExternal
in class OrderableAggregator
java.io.IOException
- on errorjava.lang.ClassNotFoundException
- on errorExternalizable.readExternal(java.io.ObjectInput)
public int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
getTypeFormatId
in class SumAggregator
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.