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

pack-priv Class ScalarAggregateResultSet

extends GenericAggregateResultSet
implements CursorResultSet
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.execute.CursorResultSet, org.apache.derby.iapi.sql.ResultSet
Known Direct Subclasses
org.apache.derby.impl.sql.execute.DistinctScalarAggregateResultSet
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.sql.execute.CursorResultSet, .ExecIndexRow, .ExecRow, .NoPutResultSet, org.apache.derby.iapi.types.RowLocation

This ResultSet evaluates scalar, non distinct aggregates. It will scan the entire source result set and calculate the scalar aggregates when scanning the source during the first call to next().

Field Summary

Modifier and TypeField and Description
protected int
protected boolean
private boolean
public int
public boolean
protected ExecIndexRow
Inherited from org.apache.derby.impl.sql.execute.GenericAggregateResultSet:
aggInfoListaggregatesoriginalSourcesource

Constructor Summary

AccessConstructor and Description
pack-priv
ScalarAggregateResultSet(NoPutResultSet
input result set
s
,
boolean
true if the source results are in sorted order
isInSortedOrder
,
int
indicates the number of the SavedObject off of the PreparedStatement that holds the AggregatorInfoList used by this routine.
aggregateItem
,
Activation
activation
a
,
int
saved object that builds an empty output row
ra
,
int
The resultSetNumber for this result set
resultSetNumber
,
boolean singleInputRow, double optimizerEstimatedRowCount, double optimizerEstimatedCost)

Constructor

Method Summary

Modifier and TypeMethod and Description
protected void
accumulateScalarAggregation(ExecRow
the input row
inputRow
,
ExecRow
the row with the accumulator (may be the same as the input row.
accumulateRow
,
boolean
does this scan have distinct aggregates. Used to figure out whether to merge or accumulate nondistinct aggregates.
hasDistinctAggregates
)

Run accumulation on every aggregate in this row.

public void
close()

Overrides org.apache.derby.impl.sql.execute.NoPutResultSetImpl.close.

Implements org.apache.derby.iapi.sql.ResultSet.close.

If the result set has been opened, close the open scan.

public ExecRow

Returns:

the last row returned;
getCurrentRow
()

Implements org.apache.derby.iapi.sql.execute.CursorResultSet.getCurrentRow.

This result set has its row from the last fetch done.

public ExecRow
public ExecIndexRow
getRowFromResultSet(boolean
- true of the row should be cloned
doClone
)

Get a row from the input result set.

public RowLocation

Returns:

the row location of the current cursor row.
getRowLocation
()

Implements org.apache.derby.iapi.sql.execute.CursorResultSet.getRowLocation.

This result set has its row location from the last fetch done.

public long

Returns:

long The total amount of time spent (in milliseconds).
getTimeSpent
(int
CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.
type
)

Implements org.apache.derby.iapi.sql.ResultSet.getTimeSpent.

Return the total amount of time spent in this ResultSet

private void
public void
public void
Inherited from org.apache.derby.impl.sql.execute.GenericAggregateResultSet:
finishfinishAggregationgetRowTemplategetSortAggregatorstoXML

Field Detail

countOfRowsback to summary
protected int countOfRows
isInSortedOrderback to summary
protected boolean isInSortedOrder
nextSatisfiedback to summary
private boolean nextSatisfied
rowsInputback to summary
public int rowsInput
singleInputRowback to summary
public boolean singleInputRow
sourceExecIndexRowback to summary
protected ExecIndexRow sourceExecIndexRow

Constructor Detail

ScalarAggregateResultSetback to summary
pack-priv ScalarAggregateResultSet(NoPutResultSet s, boolean isInSortedOrder, int aggregateItem, Activation a, int ra, int resultSetNumber, boolean singleInputRow, double optimizerEstimatedRowCount, double optimizerEstimatedCost) throws StandardException

Constructor

Parameters
s:NoPutResultSet

input result set

isInSortedOrder:boolean

true if the source results are in sorted order

aggregateItem:int

indicates the number of the SavedObject off of the PreparedStatement that holds the AggregatorInfoList used by this routine.

a:Activation

activation

ra:int

saved object that builds an empty output row

resultSetNumber:int

The resultSetNumber for this result set

Exceptions
StandardException:
Thrown on error

Method Detail

accumulateScalarAggregationback to summary
protected void accumulateScalarAggregation(ExecRow inputRow, ExecRow accumulateRow, boolean hasDistinctAggregates) throws StandardException

Run accumulation on every aggregate in this row. This method is useful when draining the source or sorter, depending on whether or not there were any distinct aggregates. Remember, if there are distinct aggregates, then the non-distinct aggregates were calculated on the way into the sorter and only the distinct aggregates will be accumulated here. Otherwise, all aggregates will be accumulated here.

Parameters
inputRow:ExecRow

the input row

accumulateRow:ExecRow

the row with the accumulator (may be the same as the input row.

hasDistinctAggregates:boolean

does this scan have distinct aggregates. Used to figure out whether to merge or accumulate nondistinct aggregates.

Exceptions
StandardException:
Thrown on error
closeback to summary
public void close() throws StandardException

Overrides org.apache.derby.impl.sql.execute.NoPutResultSetImpl.close.

Implements org.apache.derby.iapi.sql.ResultSet.close.

If the result set has been opened, close the open scan.

Exceptions
StandardException:
thrown on error
getCurrentRowback to summary
public ExecRow getCurrentRow() throws StandardException

Implements org.apache.derby.iapi.sql.execute.CursorResultSet.getCurrentRow.

This result set has its row from the last fetch done. If the cursor is closed, a null is returned.

Returns:ExecRow

the last row returned;

Exceptions
StandardException:
thrown on failure.
See Also
CursorResultSet
getNextRowCoreback to summary
public ExecRow getNextRowCore() throws StandardException

Implements abstract org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRowCore.

Implements org.apache.derby.iapi.sql.execute.NoPutResultSet.getNextRowCore.

Return the next row. If it is a scalar aggregate scan

Returns:ExecRow

the next row in the result

Exceptions
StandardException:
  • thrown on failure.
  • ResultSetNotOpen thrown if not yet open.
getRowFromResultSetback to summary
public ExecIndexRow getRowFromResultSet(boolean doClone) throws StandardException

Get a row from the input result set.

Parameters
doClone:boolean

- true of the row should be cloned

Exceptions
StandardException:
Thrown on error
getRowLocationback to summary
public RowLocation getRowLocation() throws StandardException

Implements org.apache.derby.iapi.sql.execute.CursorResultSet.getRowLocation.

This result set has its row location from the last fetch done. Always returns null.

Returns:RowLocation

the row location of the current cursor row.

Exceptions
StandardException:
thrown on failure to get row location
See Also
CursorResultSet
getTimeSpentback to summary
public long getTimeSpent(int type)

Implements org.apache.derby.iapi.sql.ResultSet.getTimeSpent.

Return the total amount of time spent in this ResultSet

Parameters
type:int

CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.

Returns:long

long The total amount of time spent (in milliseconds).

initializeScalarAggregationback to summary
private void initializeScalarAggregation(ExecRow row) throws StandardException
openCoreback to summary
public void openCore() throws StandardException

Implements org.apache.derby.iapi.sql.execute.NoPutResultSet.openCore.

Open the scan. Load the sorter and prepare to get rows from it.

Exceptions
StandardException:
thrown if cursor finished.
reopenCoreback to summary
public void reopenCore() throws StandardException

Overrides org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.reopenCore.

Implements org.apache.derby.iapi.sql.execute.NoPutResultSet.reopenCore.

reopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...

Exceptions
StandardException:
thrown if cursor finished.