org.apache.derby.impl.sql.execute
Class OrderableAggregator

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.SystemAggregator
      extended by org.apache.derby.impl.sql.execute.OrderableAggregator
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat, ExecAggregator
Direct Known Subclasses:
MaxMinAggregator, SumAggregator

abstract class OrderableAggregator
extends SystemAggregator

Abstract aggregator for Orderable aggregates (max/min).


Field Summary
protected  DataValueDescriptor value
           
 
Constructor Summary
OrderableAggregator()
           
 
Method Summary
 DataValueDescriptor getResult()
          Return the result of the operations that we have been performing.
 void merge(ExecAggregator addend)
          Merges one aggregator into a another aggregator.
 void readExternal(java.io.ObjectInput in)
           
 void setup(java.lang.String aggregateName)
          Set's up the aggregate for processing.
 java.lang.String toString()
           
 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.
 
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 Detail

value

protected DataValueDescriptor value
Constructor Detail

OrderableAggregator

OrderableAggregator()
Method Detail

setup

public void setup(java.lang.String aggregateName)
Description copied from interface: ExecAggregator
Set's up the aggregate for processing.


merge

public void merge(ExecAggregator addend)
           throws StandardException
Description copied from interface: ExecAggregator
Merges one aggregator into a another aggregator. Merges two partial aggregates results into a single result. Needed for:

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:
ExecAggregator.merge(org.apache.derby.iapi.sql.execute.ExecAggregator)

getResult

public DataValueDescriptor getResult()
                              throws StandardException
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

public java.lang.String toString()
Overrides:
toString in class SystemAggregator

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
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 interface java.io.Externalizable
Overrides:
writeExternal in class SystemAggregator
Throws:
java.io.IOException - on error
See Also:
Externalizable.writeExternal(java.io.ObjectOutput)

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class SystemAggregator
Throws:
java.io.IOException - on error
java.lang.ClassNotFoundException - on error
See Also:
Externalizable.readExternal(java.io.ObjectInput)

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.