Class ScalarAggregateResultSet
java.lang.Object
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
org.apache.derby.impl.sql.execute.NoPutResultSetImpl
org.apache.derby.impl.sql.execute.GenericAggregateResultSet
org.apache.derby.impl.sql.execute.ScalarAggregateResultSet
- All Implemented Interfaces:
CursorResultSet, NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource
- Direct Known Subclasses:
DistinctScalarAggregateResultSet
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().
-
Nested Class Summary
Nested classes/interfaces inherited from class BasicNoPutResultSetImpl
BasicNoPutResultSetImpl.FieldComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected booleanprivate booleanintbooleanprotected ExecIndexRowFields inherited from class GenericAggregateResultSet
aggInfoList, aggregates, originalSource, sourceFields inherited from class NoPutResultSetImpl
checkNullCols, clonedExecRow, cncLen, resultSetNumber, targetResultSetFields inherited from class BasicNoPutResultSetImpl
activation, beginTime, closeTime, compactRow, constructorTime, currentRow, endExecutionTime, finished, isOpen, isTopResultSet, nextTime, numOpens, openTime, optimizerEstimatedCost, optimizerEstimatedRowCount, resultDescription, rowsFiltered, rowsSeen, startExecutionTime, subqueryTrackingArrayFields inherited from interface NoPutResultSet
ABSOLUTE, FIRST, LAST, NEXT, PREVIOUS, RELATIVE, TEMPORARY_RESULT_SET_NUMBERFields inherited from interface ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST -
Constructor Summary
ConstructorsConstructorDescriptionScalarAggregateResultSet(NoPutResultSet s, boolean isInSortedOrder, int aggregateItem, Activation a, int ra, int resultSetNumber, boolean singleInputRow, double optimizerEstimatedRowCount, double optimizerEstimatedCost) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaccumulateScalarAggregation(ExecRow inputRow, ExecRow accumulateRow, boolean hasDistinctAggregates) Run accumulation on every aggregate in this row.voidclose()If the result set has been opened, close the open scan.This result set has its row from the last fetch done.Return the next row.getRowFromResultSet(boolean doClone) Get a row from the input result set.This result set has its row location from the last fetch done.longgetTimeSpent(int type) Return the total amount of time spent in this ResultSetprivate void////////////////////////////////////////////////////////////////////////////voidopenCore()Open the scan.voidreopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...Methods inherited from class GenericAggregateResultSet
finish, finishAggregation, getRowTemplate, getSortAggregators, toXMLMethods inherited from class NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, isForUpdate, markRowAsDeleted, needsRowLocation, needsRowLocationForDeferredCheckConstraints, needsToClone, offendingRowLocation, positionScanAtRowLocation, printQualifiers, resultSetNumber, rowLocation, setCurrentRow, setHasDeferrableChecks, setNeedsRowLocation, setTargetResultSet, skipRow, skipScan, unpackHashValue, updateRowMethods inherited from class BasicNoPutResultSetImpl
addWarning, attachStatementContext, checkCancellationFlag, checkRowPosition, childrenToXML, cleanUp, dumpTimeStats, finishAndRTS, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCompactRow, getCurrentTimeMillis, getElapsedMillis, getEndExecutionTimestamp, getEstimatedRowCount, getExecuteTime, getExecutionFactory, getFirstRow, getLanguageConnectionContext, getLastRow, getNextRow, getPointOfAttachment, getPreviousRow, getRelativeRow, getRowNumber, getScanIsolationLevel, getSubqueryTrackingArray, getTransactionController, getWarnings, isClosed, isXplainOnlyMode, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, requiresRelocking, returnsRows, setAfterLastRow, setBeforeFirstRow, setCompactRow, setCompatRow, toXMLMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ResultSet
addWarning, checkRowPosition, cleanUp, clearCurrentRow, finish, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getResultDescription, getRowNumber, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows, setAfterLastRow, setBeforeFirstRow, toXML
-
Field Details
-
rowsInput
public int rowsInput -
singleInputRow
public boolean singleInputRow -
isInSortedOrder
protected boolean isInSortedOrder -
sourceExecIndexRow
-
nextSatisfied
private boolean nextSatisfied -
countOfRows
protected int countOfRows
-
-
Constructor Details
-
ScalarAggregateResultSet
ScalarAggregateResultSet(NoPutResultSet s, boolean isInSortedOrder, int aggregateItem, Activation a, int ra, int resultSetNumber, boolean singleInputRow, double optimizerEstimatedRowCount, double optimizerEstimatedCost) throws StandardException Constructor- Parameters:
s- input result setisInSortedOrder- true if the source results are in sorted orderaggregateItem- indicates the number of the SavedObject off of the PreparedStatement that holds the AggregatorInfoList used by this routine.a- activationra- saved object that builds an empty output rowresultSetNumber- The resultSetNumber for this result set- Throws:
StandardException- Thrown on error
-
-
Method Details
-
openCore
Open the scan. Load the sorter and prepare to get rows from it.- Specified by:
openCorein interfaceNoPutResultSet- Throws:
StandardException- thrown if cursor finished.
-
getNextRowCore
Return the next row. If it is a scalar aggregate scan- Specified by:
getNextRowCorein interfaceNoPutResultSet- Specified by:
getNextRowCorein classBasicNoPutResultSetImpl- Returns:
- the next row in the result
- Throws:
StandardException- thrown on failure.StandardException- ResultSetNotOpen thrown if not yet open.- See Also:
-
close
If the result set has been opened, close the open scan.- Specified by:
closein interfaceResultSet- Overrides:
closein classNoPutResultSetImpl- Throws:
StandardException- thrown on error
-
getTimeSpent
public long getTimeSpent(int type) Return the total amount of time spent in this ResultSet- Specified by:
getTimeSpentin interfaceResultSet- Parameters:
type- CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.- Returns:
- long The total amount of time spent (in milliseconds).
-
getRowLocation
This result set has its row location from the last fetch done. Always returns null.- Specified by:
getRowLocationin interfaceCursorResultSet- Returns:
- the row location of the current cursor row.
- Throws:
StandardException- thrown on failure to get row location- See Also:
-
getCurrentRow
This result set has its row from the last fetch done. If the cursor is closed, a null is returned.- Specified by:
getCurrentRowin interfaceCursorResultSet- Returns:
- the last row returned;
- Throws:
StandardException- thrown on failure.- See Also:
-
getRowFromResultSet
Get a row from the input result set.- Parameters:
doClone- - true of the row should be cloned- Throws:
StandardException- Thrown on error
-
reopenCore
reopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...- Specified by:
reopenCorein interfaceNoPutResultSet- Overrides:
reopenCorein classBasicNoPutResultSetImpl- Throws:
StandardException- thrown if cursor finished.- See Also:
-
accumulateScalarAggregation
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- the input rowaccumulateRow- the row with the accumulator (may be the same as the input row.hasDistinctAggregates- does this scan have distinct aggregates. Used to figure out whether to merge or accumulate nondistinct aggregates.- Throws:
StandardException- Thrown on error
-
initializeScalarAggregation
////////////////////////////////////////////////////////////////////////////- Throws:
StandardException
-