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

public final Class MaxMinAggregator

extends OrderableAggregator
Class Inheritance
Imports
org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.sql.execute.ExecAggregator, org.apache.derby.iapi.services.io.StoredFormatIds, org.apache.derby.iapi.services.loader.ClassFactory, java.io.ObjectOutput, .ObjectInput, .IOException

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

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from org.apache.derby.impl.sql.execute.OrderableAggregator:
value

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
accumulate(DataValueDescriptor
value to be added in
addend
)

Implements abstract org.apache.derby.impl.sql.execute.SystemAggregator.accumulate.

Accumulate

public int

Returns:

the formatID of this class
getTypeFormatId
()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

public ExecAggregator

Returns:

ExecAggregator the new aggregator
newAggregator
()

Implements org.apache.derby.iapi.sql.execute.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.

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

Overrides org.apache.derby.impl.sql.execute.OrderableAggregator.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.
returnType
)

Overrides org.apache.derby.impl.sql.execute.OrderableAggregator.setup.

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

Set's up the aggregate for processing.

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

Overrides org.apache.derby.impl.sql.execute.OrderableAggregator.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.OrderableAggregator:
getResultmergetoString

Field Detail

isMaxback to summary
private boolean isMax

Constructor Detail

MaxMinAggregatorback to summary
public MaxMinAggregator()

Method Detail

accumulateback to summary
protected void accumulate(DataValueDescriptor addend) throws StandardException

Implements abstract org.apache.derby.impl.sql.execute.SystemAggregator.accumulate.

Accumulate

Parameters
addend:DataValueDescriptor

value to be added in

Exceptions
StandardException:
on error
getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

Returns:int

the formatID of this class

newAggregatorback to summary
public ExecAggregator newAggregator()

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

Doc from org.apache.derby.iapi.sql.execute.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.

Returns:ExecAggregator

ExecAggregator the new aggregator

readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Overrides org.apache.derby.impl.sql.execute.OrderableAggregator.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 returnType)

Overrides org.apache.derby.impl.sql.execute.OrderableAggregator.setup.

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.

returnType:DataTypeDescriptor

The type returned by the getResult() method.

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

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

Implements java.io.Externalizable.writeExternal.

Doc from org.apache.derby.impl.sql.execute.OrderableAggregator.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