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

java.lang.Object
  extended byorg.apache.derby.impl.sql.execute.BasicSortObserver
      extended byorg.apache.derby.impl.sql.execute.AggregateSortObserver
All Implemented Interfaces:
SortObserver

public class AggregateSortObserver
extends BasicSortObserver

This sort observer performs aggregation.

Author:
jamie

Field Summary
protected  GenericAggregator[] aggsToInitialize
           
protected  GenericAggregator[] aggsToProcess
           
private  int firstAggregatorColumn
           
 
Fields inherited from class org.apache.derby.impl.sql.execute.BasicSortObserver
distinct, doClone
 
Constructor Summary
AggregateSortObserver(boolean doClone, GenericAggregator[] aggsToProcess, GenericAggregator[] aggsToInitialize, ExecRow execRow)
          Simple constructor
 
Method Summary
 DataValueDescriptor[] insertDuplicateKey(DataValueDescriptor[] insertRow, DataValueDescriptor[] existingRow)
          Called prior to inserting a duplicate sort key.
 DataValueDescriptor[] insertNonDuplicateKey(DataValueDescriptor[] insertRow)
          Called prior to inserting a distinct sort key.
 
Methods inherited from class org.apache.derby.impl.sql.execute.BasicSortObserver
addToFreeList, getArrayClone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aggsToProcess

protected GenericAggregator[] aggsToProcess

aggsToInitialize

protected GenericAggregator[] aggsToInitialize

firstAggregatorColumn

private int firstAggregatorColumn
Constructor Detail

AggregateSortObserver

public AggregateSortObserver(boolean doClone,
                             GenericAggregator[] aggsToProcess,
                             GenericAggregator[] aggsToInitialize,
                             ExecRow execRow)
Simple constructor

Parameters:
doClone - If true, then rows that are retained by the sorter will be cloned. This is needed if language is reusing row wrappers.
aggsToProcess - the array of aggregates that need to be accumulated/merged in the sorter.
aggsToInitialize - 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 to use as source of clone for store.
Method Detail

insertNonDuplicateKey

public DataValueDescriptor[] insertNonDuplicateKey(DataValueDescriptor[] insertRow)
                                            throws StandardException
Called prior to inserting a distinct sort key.

Specified by:
insertNonDuplicateKey in interface SortObserver
Overrides:
insertNonDuplicateKey in class BasicSortObserver
Parameters:
insertRow - the current row that the sorter is on the verge of retaining
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.
Throws:
StandardException - never thrown

insertDuplicateKey

public DataValueDescriptor[] insertDuplicateKey(DataValueDescriptor[] insertRow,
                                                DataValueDescriptor[] existingRow)
                                         throws StandardException
Called prior to inserting a duplicate sort key. We do aggregation here.

Specified by:
insertDuplicateKey in interface SortObserver
Overrides:
insertDuplicateKey in class BasicSortObserver
Parameters:
insertRow - the current row that the sorter is on the verge of retaining. It is a duplicate of existingRow.
existingRow - the row that is already in the the sorter which is a duplicate of insertRow
Throws:
StandardException - never thrown

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.