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

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

public final class MaxMinAggregator
extends OrderableAggregator

Aggregator for MAX()/MIN(). Defers most of its work to OrderableAggregator.

See Also:
OrderableAggregator, Serialized Form

Field Summary
private  boolean isMax
           
 
Fields inherited from class org.apache.derby.impl.sql.execute.OrderableAggregator
value
 
Constructor Summary
MaxMinAggregator()
           
 
Method Summary
protected  void accumulate(DataValueDescriptor addend)
          Accumulate
 int getTypeFormatId()
          Get the formatID which corresponds to this class.
 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 setup(java.lang.String aggregateName)
          Set's up the aggregate for processing.
 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.OrderableAggregator
getResult, merge, toString
 
Methods inherited from class org.apache.derby.impl.sql.execute.SystemAggregator
accumulate, didEliminateNulls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isMax

private boolean isMax
Constructor Detail

MaxMinAggregator

public MaxMinAggregator()
Method Detail

setup

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

Specified by:
setup in interface ExecAggregator
Overrides:
setup in class OrderableAggregator

accumulate

protected void accumulate(DataValueDescriptor addend)
                   throws StandardException
Accumulate

Specified by:
accumulate in class SystemAggregator
Parameters:
addend - value to be added in
Throws:
StandardException - on error

newAggregator

public ExecAggregator newAggregator()
Description copied from interface: ExecAggregator
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.

Returns:
ExecAggregator the new aggregator

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Description copied from class: OrderableAggregator
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 OrderableAggregator
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 OrderableAggregator
Throws:
java.io.IOException - on error
java.lang.ClassNotFoundException - on error
See Also:
Externalizable.readExternal(java.io.ObjectInput)

getTypeFormatId

public int getTypeFormatId()
Get the formatID which corresponds to this class.

Returns:
the formatID of this class

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

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