Class DistinctScalarAggregateResultSet
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
org.apache.derby.impl.sql.execute.DistinctScalarAggregateResultSet
- All Implemented Interfaces:
CursorResultSet
,NoPutResultSet
,ResultSet
,RowLocationRetRowSource
,RowSource
This ResultSet evaluates scalar aggregates where
1 (or more, in the future) of the aggregates are distinct.
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 org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
BasicNoPutResultSetImpl.FieldComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private int
private ColumnOrdering[]
private ScanController
private boolean
private long
private ExecIndexRow
Fields inherited from class org.apache.derby.impl.sql.execute.ScalarAggregateResultSet
countOfRows, isInSortedOrder, rowsInput, singleInputRow, sourceExecIndexRow
Fields inherited from class org.apache.derby.impl.sql.execute.GenericAggregateResultSet
aggInfoList, aggregates, originalSource, source
Fields inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
checkNullCols, clonedExecRow, cncLen, resultSetNumber, targetResultSet
Fields inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
activation, beginTime, closeTime, compactRow, constructorTime, currentRow, endExecutionTime, finished, isOpen, isTopResultSet, nextTime, numOpens, openTime, optimizerEstimatedCost, optimizerEstimatedRowCount, resultDescription, rowsFiltered, rowsSeen, startExecutionTime, subqueryTrackingArray
Fields inherited from interface org.apache.derby.iapi.sql.execute.NoPutResultSet
ABSOLUTE, FIRST, LAST, NEXT, PREVIOUS, RELATIVE, TEMPORARY_RESULT_SET_NUMBER
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
-
Constructor Summary
ConstructorsConstructorDescriptionDistinctScalarAggregateResultSet
(NoPutResultSet s, boolean isInSortedOrder, int aggregateItem, int orderingItem, Activation a, int ra, int maxRowSize, int resultSetNumber, boolean singleInputRow, double optimizerEstimatedRowCount, double optimizerEstimatedCost) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
If the result set has been opened, close the open scan.protected void
Close the source of whatever we have been scanning.Return the next row.getRowFromResultSet
(boolean doClone) Get a row from the sorter.private ScanController
Load up the sorter.void
openCore()
Open the scan.void
reopen 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 org.apache.derby.impl.sql.execute.ScalarAggregateResultSet
accumulateScalarAggregation, getCurrentRow, getRowLocation, getTimeSpent
Methods inherited from class org.apache.derby.impl.sql.execute.GenericAggregateResultSet
finish, finishAggregation, getRowTemplate, getSortAggregators, toXML
Methods inherited from class org.apache.derby.impl.sql.execute.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, updateRow
Methods inherited from class org.apache.derby.impl.sql.execute.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, toXML
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.derby.iapi.sql.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
-
order
-
maxRowSize
private int maxRowSize -
dropDistinctAggSort
private boolean dropDistinctAggSort -
sortId
private long sortId -
scanController
-
sortResultRow
-
sorted
private boolean sorted
-
-
Constructor Details
-
DistinctScalarAggregateResultSet
DistinctScalarAggregateResultSet(NoPutResultSet s, boolean isInSortedOrder, int aggregateItem, int orderingItem, Activation a, int ra, int maxRowSize, 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:
openCore
in interfaceNoPutResultSet
- Overrides:
openCore
in classScalarAggregateResultSet
- Throws:
StandardException
- thrown if cursor finished.
-
getNextRowCore
Return the next row. If it is a scalar aggregate scan- Specified by:
getNextRowCore
in interfaceNoPutResultSet
- Overrides:
getNextRowCore
in classScalarAggregateResultSet
- Returns:
- the next row in the result
- Throws:
StandardException
- thrown on failure.StandardException
- ResultSetNotOpen thrown if not yet open.- See Also:
-
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:
reopenCore
in interfaceNoPutResultSet
- Overrides:
reopenCore
in classScalarAggregateResultSet
- Throws:
StandardException
- thrown if cursor finished.- See Also:
-
close
If the result set has been opened, close the open scan.- Specified by:
close
in interfaceResultSet
- Overrides:
close
in classScalarAggregateResultSet
- Throws:
StandardException
- thrown on error
-
getRowFromResultSet
Get a row from the sorter. Side effects: sets currentRow.- Overrides:
getRowFromResultSet
in classScalarAggregateResultSet
- Parameters:
doClone
- - true of the row should be cloned- Throws:
StandardException
- Thrown on error
-
closeSource
Close the source of whatever we have been scanning.- Throws:
StandardException
- thrown on error
-
loadSorter
Load up the sorter. Feed it every row from the source scan. If we have a vector aggregate, initialize the aggregator for each source row. When done, close the source scan and open the sort. Return the sort scan controller.- Returns:
- the sort controller
- Throws:
StandardException
- thrown on failure.
-