Class ScanResultSet
java.lang.Object
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
org.apache.derby.impl.sql.execute.NoPutResultSetImpl
org.apache.derby.impl.sql.execute.ScanResultSet
- All Implemented Interfaces:
NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource
- Direct Known Subclasses:
DependentResultSet, HashScanResultSet, LastIndexKeyResultSet, TableScanResultSet
Abstract
Example: if accessedCols indicates that we want to retrieve columns 1 and 4, then candidate row will have space for 5 columns (because that's the size of the rows in the underlying object), but only cols "1" and "4" will have values:
Rows returned by this ScanResultSet will have the values:
ResultSet class for NoPutResultSets which
contain a scan. Returns rows that may be a column sub-set of the
rows in the underlying object to be scanned. If accessedCols is
not null then a sub-set of columns will be fetched from the underlying
object (usually into the candidate row object), then the returned
rows will be a compacted form of that row, with the not-fetched columns
moved out. If accessedCols is null then the full row will be returned.
Example: if accessedCols indicates that we want to retrieve columns 1 and 4, then candidate row will have space for 5 columns (because that's the size of the rows in the underlying object), but only cols "1" and "4" will have values:
0 1 2 3 4
[ - , COL1, - , - , COL4 ]
Rows returned by this ScanResultSet will have the values:
0 1
[ COL1, COL4 ]
-
Nested Class Summary
Nested classes/interfaces inherited from class BasicNoPutResultSetImpl
BasicNoPutResultSetImpl.FieldComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FormatableBitSetIf not null indicates the subset of columns that need to be pulled from the underlying object to be scanned.(package private) final ExecRowThe candidate row, matches the shape of the rows in the underlying object to be scanned.protected booleantrue if the scan should pick up row locations(package private) intThe scan isolation level.private booleanTells whether the isolation level needs to be updated.(package private) intThe actual lock mode used.(package private) final ExecRowBuilderObject used to create and reset the candidate row.private final intThe lock mode supplied through the constructor.private final booleanIf true, the table is marked as table locked in SYS.SYSTABLES.private final booleanIf true, the isolation level is unspecified and must be refreshed on each open.Fields 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
ConstructorsConstructorDescriptionScanResultSet(Activation activation, int resultSetNumber, int resultRowTemplate, int lockMode, boolean tableLocked, int isolationLevel, int colRefItem, double optimizerEstimatedRowCount, double optimizerEstimatedCost) Construct aScanResultSet. -
Method Summary
Modifier and TypeMethodDescription(package private) abstract booleanCan we get instantaneous locks when getting share row locks at READ COMMITTED.voidclose()Close the result set.private intgetLockMode(int languageLevel) Get the lock mode based on the language isolation level.intReturn the isolation level of the scan in the result set.(package private) voidInitialize the isolation level and the lock mode.protected voidDetermine whether this scan should return row locationsProduce an xml image of this ResultSet and its descendant ResultSets.private inttranslateLanguageIsolationLevel(int languageLevel) Translate isolation level from language to store.Methods 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, finish, finishAndRTS, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCompactRow, getCurrentTimeMillis, getElapsedMillis, getEndExecutionTimestamp, getEstimatedRowCount, getExecuteTime, getExecutionFactory, getFirstRow, getLanguageConnectionContext, getLastRow, getNextRow, getNextRowCore, getPointOfAttachment, getPreviousRow, getRelativeRow, getRowNumber, getSubqueryTrackingArray, getTransactionController, getWarnings, isClosed, isXplainOnlyMode, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, reopenCore, 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 NoPutResultSet
openCoreMethods inherited from interface ResultSet
getTimeSpent
-
Field Details
-
tableLocked
private final boolean tableLockedIf true, the table is marked as table locked in SYS.SYSTABLES. -
unspecifiedIsolationLevel
private final boolean unspecifiedIsolationLevelIf true, the isolation level is unspecified and must be refreshed on each open. -
suppliedLockMode
private final int suppliedLockModeThe lock mode supplied through the constructor. -
isolationLevelNeedsUpdate
private boolean isolationLevelNeedsUpdateTells whether the isolation level needs to be updated. -
lockMode
int lockModeThe actual lock mode used. -
isolationLevel
int isolationLevelThe scan isolation level. -
resultRowBuilder
Object used to create and reset the candidate row. -
candidate
The candidate row, matches the shape of the rows in the underlying object to be scanned. -
accessedCols
If not null indicates the subset of columns that need to be pulled from the underlying object to be scanned. Set from the PreparedStatement's saved objects, if it exists. -
fetchRowLocations
protected boolean fetchRowLocationstrue if the scan should pick up row locations -
tableName
-
indexName
-
-
Constructor Details
-
ScanResultSet
ScanResultSet(Activation activation, int resultSetNumber, int resultRowTemplate, int lockMode, boolean tableLocked, int isolationLevel, int colRefItem, double optimizerEstimatedRowCount, double optimizerEstimatedCost) throws StandardException Construct aScanResultSet.- Parameters:
activation- the activationresultSetNumber- number of the result set (unique within statement)resultRowTemplate- identifier of saved object for row templatelockMode- lock mode (record or table)tableLocked- true if marked as table locked in SYS.SYSTABLESisolationLevel- language isolation level for the result setcolRefItem- Identifier of saved object for accessedCols, -1 if need to fetch all columns.optimizerEstimatedRowCount- estimated row countoptimizerEstimatedCost- estimated cost- Throws:
StandardException
-
-
Method Details
-
initIsolationLevel
void initIsolationLevel()Initialize the isolation level and the lock mode. If the result set was constructed with an explicit isolation level, or if the isolation level has already been initialized, this is a no-op. All sub-classes should invoke this method from theiropenCore()methods. -
getLockMode
private int getLockMode(int languageLevel) Get the lock mode based on the language isolation level. Always do row locking unless the isolation level is serializable or the table is marked as table locked.- Parameters:
languageLevel- the (language) isolation level- Returns:
- lock mode
-
setRowLocationsState
Determine whether this scan should return row locations- Throws:
StandardException
-
translateLanguageIsolationLevel
private int translateLanguageIsolationLevel(int languageLevel) Translate isolation level from language to store.- Parameters:
languageLevel- language isolation level- Returns:
- store isolation level
-
canGetInstantaneousLocks
abstract boolean canGetInstantaneousLocks()Can we get instantaneous locks when getting share row locks at READ COMMITTED. -
getScanIsolationLevel
public int getScanIsolationLevel()Return the isolation level of the scan in the result set.- Specified by:
getScanIsolationLevelin interfaceNoPutResultSet- Overrides:
getScanIsolationLevelin classBasicNoPutResultSetImpl- Returns:
- The isolation level of the scan (in TransactionController constants).
- See Also:
-
close
Close the result set.- Specified by:
closein interfaceResultSet- Overrides:
closein classNoPutResultSetImpl- Throws:
StandardException- if an error occurs
-
toXML
Description copied from interface:ResultSetProduce an xml image of this ResultSet and its descendant ResultSets. Appends an element to the parentNode and returns the appended element.
- Specified by:
toXMLin interfaceResultSet- Overrides:
toXMLin classBasicNoPutResultSetImpl- Parameters:
parentNode- Node to put content into.tag- Element tag for content- Returns:
- the content as an element with the given tag name
- Throws:
Exception
-