Top Description Fields Constructors Methods
org.apache.derby.impl.sql.execute

pack-priv abstract Class OrderableAggregator

extends SystemAggregator
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.execute.SumAggregator, org.apache.derby.impl.sql.execute.MaxMinAggregator
Imports
java.io.IOException, .ObjectInput, .ObjectOutput, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.loader.ClassFactory, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.execute.ExecAggregator, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor

Abstract aggregator for Orderable aggregates (max/min).

Field Summary

Modifier and TypeField and Description
protected DataValueDescriptor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public DataValueDescriptor

Returns:

the result as a DataValueDescriptor
getResult
()

Implements org.apache.derby.iapi.sql.execute.ExecAggregator.getResult.

Return the result of the operations that we have been performing.

public void
merge(ExecAggregator
the other Aggregator (input partial aggregate)
addend
)

Implements org.apache.derby.iapi.sql.execute.ExecAggregator.merge.

Merges one aggregator into a another aggregator.

public void
readExternal(ObjectInput
the stream to read data from in order to restore the object
in
)

Overrides org.apache.derby.impl.sql.execute.SystemAggregator.readExternal.

Implements java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.

public void
setup(ClassFactory
Database-specific class factory.
cf
,
String
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.
aggregateName
,
DataTypeDescriptor
The type returned by the getResult() method.
returnDataType
)

Implements org.apache.derby.iapi.sql.execute.ExecAggregator.setup.

Set's up the aggregate for processing.

public String
toString()

Overrides org.apache.derby.impl.sql.execute.SystemAggregator.toString.

Returns a string representation of the object.

public void
writeExternal(ObjectOutput
the stream to write the object to
out
)

Overrides org.apache.derby.impl.sql.execute.SystemAggregator.writeExternal.

Implements java.io.Externalizable.writeExternal.

Although we are not expected to be persistent per se, we may be written out by the sorter temporarily.

Inherited from org.apache.derby.impl.sql.execute.SystemAggregator:
accumulateaccumulatedidEliminateNulls

Field Detail

valueback to summary
protected DataValueDescriptor value

Constructor Detail

OrderableAggregatorback to summary
pack-priv OrderableAggregator()

Method Detail

getResultback to summary
public DataValueDescriptor getResult() throws StandardException

Implements org.apache.derby.iapi.sql.execute.ExecAggregator.getResult.

Return the result of the operations that we have been performing. Returns a DataValueDescriptor.

Returns:DataValueDescriptor

the result as a DataValueDescriptor

Exceptions
StandardException:

Doc from org.apache.derby.iapi.sql.execute.ExecAggregator.getResult.

on error

mergeback to summary
public void merge(ExecAggregator addend) throws StandardException

Implements org.apache.derby.iapi.sql.execute.ExecAggregator.merge.

Doc from org.apache.derby.iapi.sql.execute.ExecAggregator.merge.

Merges one aggregator into a another aggregator. Merges two partial aggregates results into a single result. Needed for:

  • parallel aggregation
  • vector aggregation (GROUP BY)
  • distinct aggregates (e.g. MAX(DISTINCT Col))

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:ExecAggregator

the other Aggregator (input partial aggregate)

Exceptions
StandardException:
on error
See Also
ExecAggregator#merge
readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Overrides org.apache.derby.impl.sql.execute.SystemAggregator.readExternal.

Implements java.io.Externalizable.readExternal.

Doc from java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Parameters
in:ObjectInput

the stream to read data from in order to restore the object

Exceptions
IOException:
on error
ClassNotFoundException:
on error
See Also
java.io.Externalizable#readExternal
setupback to summary
public void setup(ClassFactory cf, String aggregateName, DataTypeDescriptor returnDataType)

Implements org.apache.derby.iapi.sql.execute.ExecAggregator.setup.

Doc from org.apache.derby.iapi.sql.execute.ExecAggregator.setup.

Set's up the aggregate for processing.

Parameters
cf:ClassFactory

Database-specific class factory.

aggregateName:String

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.

returnDataType:DataTypeDescriptor

The type returned by the getResult() method.

toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.execute.SystemAggregator.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Overrides org.apache.derby.impl.sql.execute.SystemAggregator.writeExternal.

Implements java.io.Externalizable.writeExternal.

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.

Parameters
out:ObjectOutput

Doc from java.io.Externalizable.writeExternal.

the stream to write the object to

Exceptions
IOException:
on error
See Also
java.io.Externalizable#writeExternal