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

pack-priv Class AggregateSortObserver

extends BasicSortObserver
Class Inheritance
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.execute.ExecRow, org.apache.derby.iapi.types.DataValueDescriptor, .UserDataValue

This sort observer performs aggregation.

Field Summary

Modifier and TypeField and Description
private final GenericAggregator[]
private final GenericAggregator[]
private int
Inherited from org.apache.derby.impl.sql.execute.BasicSortObserver:
distinctdoClone

Constructor Summary

AccessConstructor and Description
public
AggregateSortObserver(boolean
If true, then rows that are retained by the sorter will be cloned. This is needed if language is reusing row wrappers.
doClone
,
GenericAggregator[]
the array of aggregates that need to be accumulated/merged in the sorter.
aggsToProcess
,
GenericAggregator[]
the array of aggregates that need to be iniitialized as they are inserted into the sorter. This may be different than aggsToProcess in the case where some distinct aggregates are dropped in the initial pass of a two phase aggregation for scalar or vector distinct aggregation. The initialization process consists of replacing an empty UserValue with a new, initialized aggregate of the appropriate type. Note that for each row, only the first aggregate in this list is checked to see whether initialization is needed. If so, ALL aggregates are initialized; otherwise, NO aggregates are initialized.
aggsToInitialize
,
ExecRow
ExecRow to use as source of clone for store.
execRow
)

Simple constructor

Method Summary

Modifier and TypeMethod and Description
public DataValueDescriptor[]
insertDuplicateKey(DataValueDescriptor[]
the current row that the sorter is on the verge of retaining. It is a duplicate of existingRow.
insertRow
,
DataValueDescriptor[]
the row that is already in the the sorter which is a duplicate of insertRow
existingRow
)

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.insertDuplicateKey.

Implements org.apache.derby.iapi.store.access.SortObserver.insertDuplicateKey.

Called prior to inserting a duplicate sort key.

public DataValueDescriptor[]

Returns:

the row to be inserted by the sorter. If null, then nothing is inserted by the sorter. Distinct sorts will want to return null.
insertNonDuplicateKey
(DataValueDescriptor[]
the current row that the sorter is on the verge of retaining
insertRow
)

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.insertNonDuplicateKey.

Implements org.apache.derby.iapi.store.access.SortObserver.insertNonDuplicateKey.

Called prior to inserting a distinct sort key.

Inherited from org.apache.derby.impl.sql.execute.BasicSortObserver:
addToFreeListdeferrabledeferredgetArrayClonerememberDuplicate

Field Detail

aggsToInitializeback to summary
private final GenericAggregator[] aggsToInitialize
aggsToProcessback to summary
private final GenericAggregator[] aggsToProcess
firstAggregatorColumnback to summary
private int firstAggregatorColumn

Constructor Detail

AggregateSortObserverback to summary
public AggregateSortObserver(boolean doClone, GenericAggregator[] aggsToProcess, GenericAggregator[] aggsToInitialize, ExecRow execRow)

Simple constructor

Parameters
doClone:boolean

If true, then rows that are retained by the sorter will be cloned. This is needed if language is reusing row wrappers.

aggsToProcess:GenericAggregator[]

the array of aggregates that need to be accumulated/merged in the sorter.

aggsToInitialize:GenericAggregator[]

the array of aggregates that need to be iniitialized as they are inserted into the sorter. This may be different than aggsToProcess in the case where some distinct aggregates are dropped in the initial pass of a two phase aggregation for scalar or vector distinct aggregation. The initialization process consists of replacing an empty UserValue with a new, initialized aggregate of the appropriate type. Note that for each row, only the first aggregate in this list is checked to see whether initialization is needed. If so, ALL aggregates are initialized; otherwise, NO aggregates are initialized.

execRow:ExecRow

ExecRow to use as source of clone for store.

Method Detail

insertDuplicateKeyback to summary
public DataValueDescriptor[] insertDuplicateKey(DataValueDescriptor[] insertRow, DataValueDescriptor[] existingRow) throws StandardException

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.insertDuplicateKey.

Implements org.apache.derby.iapi.store.access.SortObserver.insertDuplicateKey.

Called prior to inserting a duplicate sort key. We do aggregation here.

Parameters
insertRow:DataValueDescriptor[]

the current row that the sorter is on the verge of retaining. It is a duplicate of existingRow.

existingRow:DataValueDescriptor[]

the row that is already in the the sorter which is a duplicate of insertRow

Returns:DataValueDescriptor[]

Doc from org.apache.derby.iapi.store.access.SortObserver.insertDuplicateKey.

the row to be inserted by the sorter. If null, then nothing is inserted by the sorter. Distinct sorts will want to return null.

Exceptions
StandardException:
never thrown
insertNonDuplicateKeyback to summary
public DataValueDescriptor[] insertNonDuplicateKey(DataValueDescriptor[] insertRow) throws StandardException

Overrides org.apache.derby.impl.sql.execute.BasicSortObserver.insertNonDuplicateKey.

Implements org.apache.derby.iapi.store.access.SortObserver.insertNonDuplicateKey.

Called prior to inserting a distinct sort key.

Parameters
insertRow:DataValueDescriptor[]

the current row that the sorter is on the verge of retaining

Returns:DataValueDescriptor[]

the row to be inserted by the sorter. If null, then nothing is inserted by the sorter. Distinct sorts will want to return null.

Exceptions
StandardException:
never thrown