Class TableScanResultSet
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
-
- org.apache.derby.impl.sql.execute.NoPutResultSetImpl
-
- org.apache.derby.impl.sql.execute.ScanResultSet
-
- org.apache.derby.impl.sql.execute.TableScanResultSet
-
- All Implemented Interfaces:
java.lang.Cloneable,CursorResultSet,NoPutResultSet,ResultSet,RowLocationRetRowSource,RowSource
- Direct Known Subclasses:
BulkTableScanResultSet,MultiProbeTableScanResultSet,ValidateCheckConstraintResultSet
class TableScanResultSet extends ScanResultSet implements CursorResultSet, java.lang.Cloneable
Takes a table and a table filter and returns the table's rows satisfying the filter as a result set. There are several things we could do during object construction that are done in the open and next calls, to improve performance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
BasicNoPutResultSetImpl.FieldComparator
-
-
Field Summary
-
Fields inherited from class org.apache.derby.impl.sql.execute.ScanResultSet
accessedCols, candidate, fetchRowLocations, indexName, isolationLevel, lockMode, resultRowBuilder, tableName
-
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
Constructors Constructor Description TableScanResultSet(long conglomId, StaticCompiledOpenConglomInfo scoci, Activation activation, int resultRowTemplate, int resultSetNumber, GeneratedMethod startKeyGetter, int startSearchOperator, GeneratedMethod stopKeyGetter, int stopSearchOperator, boolean sameStartStopPosition, Qualifier[][] qualifiers, java.lang.String tableName, java.lang.String userSuppliedOptimizerOverrides, java.lang.String indexName, boolean isConstraint, boolean forUpdate, int colRefItem, int indexColItem, int lockMode, boolean tableLocked, int isolationLevel, int rowsPerRead, boolean oneRowScan, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanGetInstantaneousLocks()Can we get instantaneous locks when getting share row locks at READ COMMITTED.java.lang.Objectclone()Shallow clone this result set.voidclose()If the result set has been opened, close the open scan.ExecRowgetCurrentRow()This result set has its row from the last fetch done.ExecRowgetNextRowCore()Return the next row (if any) from the scan (if open).RowLocationgetRowLocation()This result set has its row location from the last fetch done.java.util.PropertiesgetScanProperties()longgetTimeSpent(int type)Return the total amount of time spent in this ResultSet(package private) voidinitStartAndStopKey()Initialize thestartPositionandstopPositionfields which are used to limit the rows returned by the scan.booleanisForUpdate()Is this ResultSet or it's source result set for update(package private) booleanloopControl(boolean moreRows)voidopenCore()open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...protected voidopenScanController(TransactionController tc)voidpositionScanAtRowLocation(RowLocation rl)Positions the cursor in the specified rowLocation.private java.lang.StringprintPosition(int searchOperator, GeneratedMethod positionGetter, ExecIndexRow positioner)Return a start or stop positioner as a String.java.lang.StringprintStartPosition()Print an array of Qualifiers to the trace stream.java.lang.StringprintStopPosition()voidreopenCore()Reopen a table scan.protected voidreopenScanController()booleanrequiresRelocking()Do we need to relock the row when going to the heap.protected voidsetRowCountIfPossible(long rowsThisScan)Update the number of rows in the scan controller.-
Methods inherited from class org.apache.derby.impl.sql.execute.ScanResultSet
getScanIsolationLevel, initIsolationLevel, setRowLocationsState, toXML
-
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, markRowAsDeleted, needsRowLocation, needsRowLocationForDeferredCheckConstraints, needsToClone, offendingRowLocation, 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, finish, finishAndRTS, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCompactRow, getCurrentTimeMillis, getElapsedMillis, getEndExecutionTimestamp, getEstimatedRowCount, getExecuteTime, getExecutionFactory, getFirstRow, getLanguageConnectionContext, getLastRow, getNextRow, getPointOfAttachment, getPreviousRow, getRelativeRow, getRowNumber, getSubqueryTrackingArray, getTransactionController, getWarnings, isClosed, isXplainOnlyMode, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, returnsRows, setAfterLastRow, setBeforeFirstRow, setCompactRow, setCompatRow, toXML
-
Methods inherited from class java.lang.Object
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 Detail
-
scanController
protected ScanController scanController
-
scanControllerOpened
protected boolean scanControllerOpened
-
isKeyed
protected boolean isKeyed
-
firstScan
protected boolean firstScan
-
startPosition
protected ExecIndexRow startPosition
-
stopPosition
protected ExecIndexRow stopPosition
-
conglomId
protected long conglomId
-
dcoci
protected DynamicCompiledOpenConglomInfo dcoci
-
scoci
protected StaticCompiledOpenConglomInfo scoci
-
startKeyGetter
protected GeneratedMethod startKeyGetter
-
startSearchOperator
protected int startSearchOperator
-
stopKeyGetter
protected GeneratedMethod stopKeyGetter
-
stopSearchOperator
protected int stopSearchOperator
-
qualifiers
public Qualifier[][] qualifiers
-
userSuppliedOptimizerOverrides
public java.lang.String userSuppliedOptimizerOverrides
-
runTimeStatisticsOn
protected boolean runTimeStatisticsOn
-
indexCols
protected int[] indexCols
-
rowsPerRead
public int rowsPerRead
-
forUpdate
public boolean forUpdate
-
sameStartStopPosition
final boolean sameStartStopPosition
-
nextDone
protected boolean nextDone
-
rlTemplate
private RowLocation rlTemplate
-
scanProperties
private java.util.Properties scanProperties
-
startPositionString
public java.lang.String startPositionString
-
stopPositionString
public java.lang.String stopPositionString
-
isConstraint
public boolean isConstraint
-
coarserLock
public boolean coarserLock
-
oneRowScan
public boolean oneRowScan
-
rowsThisScan
protected long rowsThisScan
-
estimatedRowCount
private long estimatedRowCount
-
past2FutureTbl
protected BackingStoreHashtable past2FutureTbl
This field is used by beetle 3865, updateable cursor using index. It is a hash table containing updated rows that are thrown into future direction of the index scan, and as a result we'll hit it again but should skip it. The hash table will spill to disk if it grows too big to be kept in memory.
-
qualify
protected boolean qualify
-
currentRowIsValid
protected boolean currentRowIsValid
-
scanRepositioned
protected boolean scanRepositioned
-
-
Constructor Detail
-
TableScanResultSet
TableScanResultSet(long conglomId, StaticCompiledOpenConglomInfo scoci, Activation activation, int resultRowTemplate, int resultSetNumber, GeneratedMethod startKeyGetter, int startSearchOperator, GeneratedMethod stopKeyGetter, int stopSearchOperator, boolean sameStartStopPosition, Qualifier[][] qualifiers, java.lang.String tableName, java.lang.String userSuppliedOptimizerOverrides, java.lang.String indexName, boolean isConstraint, boolean forUpdate, int colRefItem, int indexColItem, int lockMode, boolean tableLocked, int isolationLevel, int rowsPerRead, boolean oneRowScan, double optimizerEstimatedRowCount, double optimizerEstimatedCost) throws StandardException- Throws:
StandardException
-
-
Method Detail
-
openCore
public void openCore() throws StandardExceptionopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...- Specified by:
openCorein interfaceNoPutResultSet- Throws:
StandardException- thrown on failure to open
-
initStartAndStopKey
void initStartAndStopKey() throws StandardExceptionInitialize thestartPositionandstopPositionfields which are used to limit the rows returned by the scan.- Throws:
StandardException
-
openScanController
protected void openScanController(TransactionController tc) throws StandardException
- Throws:
StandardException
-
reopenScanController
protected void reopenScanController() throws StandardException- Throws:
StandardException
-
reopenCore
public void reopenCore() throws StandardExceptionReopen a table scan. Here we take advantage of the reopenScan() interface on scanController for optimimal performance on joins where we are an inner table.- Specified by:
reopenCorein interfaceNoPutResultSet- Overrides:
reopenCorein classBasicNoPutResultSetImpl- Throws:
StandardException- thrown on failure to open- See Also:
NoPutResultSet.openCore()
-
loopControl
boolean loopControl(boolean moreRows) throws StandardException- Throws:
StandardException
-
getNextRowCore
public ExecRow getNextRowCore() throws StandardException
Return the next row (if any) from the scan (if open).- Specified by:
getNextRowCorein interfaceNoPutResultSet- Specified by:
getNextRowCorein classBasicNoPutResultSetImpl- Returns:
- the next row in the result
- Throws:
StandardException- thrown on failure to get next row- See Also:
NoPutResultSet.getNextRowCore()
-
close
public void close() throws StandardExceptionIf the result set has been opened, close the open scan.- Specified by:
closein interfaceResultSet- Overrides:
closein classScanResultSet- Throws:
StandardException- 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
public RowLocation getRowLocation() throws StandardException
This result set has its row location from the last fetch done. If the cursor is closed, or the row has been deleted a null is returned.- Specified by:
getRowLocationin interfaceCursorResultSet- Returns:
- the row location of the current cursor row.
- Throws:
StandardException- thrown on failure to get row location- See Also:
CursorResultSet
-
getCurrentRow
public ExecRow getCurrentRow() throws StandardException
This result set has its row from the last fetch done. If the cursor is closed, the row has been deleted, or no longer qualifies (for forward only result sets) a null is returned.- Specified by:
getCurrentRowin interfaceCursorResultSet- Returns:
- the last row returned;
- Throws:
StandardException- thrown on failure.- See Also:
CursorResultSet
-
positionScanAtRowLocation
public void positionScanAtRowLocation(RowLocation rl) throws StandardException
Description copied from interface:NoPutResultSetPositions the cursor in the specified rowLocation. Used for scrollable insensitive result sets in order to position the cursor back to a row that has already be visited.- Specified by:
positionScanAtRowLocationin interfaceNoPutResultSet- Overrides:
positionScanAtRowLocationin classNoPutResultSetImpl- Parameters:
rl- row location of the current cursor row- Throws:
StandardException- thrown on failure to get location from storage engine- See Also:
Also sets qualify to false so that later calls to getCurrentRow will not attempt to re-qualify the current row.
-
printStartPosition
public java.lang.String printStartPosition()
Print an array of Qualifiers to the trace stream.
-
printStopPosition
public java.lang.String printStopPosition()
-
printPosition
private java.lang.String printPosition(int searchOperator, GeneratedMethod positionGetter, ExecIndexRow positioner)Return a start or stop positioner as a String. If we already generated the information, then use that. Otherwise, invoke the activation to get it.
-
getScanProperties
public java.util.Properties getScanProperties()
-
requiresRelocking
public boolean requiresRelocking()
Description copied from interface:NoPutResultSetDo we need to relock the row when going to the heap.- Specified by:
requiresRelockingin interfaceNoPutResultSet- Overrides:
requiresRelockingin classBasicNoPutResultSetImpl- Returns:
- Whether or not we need to relock the row when going to the heap.
- See Also:
NoPutResultSet.requiresRelocking()
-
setRowCountIfPossible
protected final void setRowCountIfPossible(long rowsThisScan) throws StandardExceptionUpdate the number of rows in the scan controller. NOTE: It would be more efficient to only update the scan controller if the optimizer's estimated number of rows were wrong by more than some threshold (like 10%). This would require a little more work than I have the time for now, however, as the row estimate that is given to this result set is the total number of rows for all scans, not the number of rows per scan.- Parameters:
rowsThisScan- The number of rows to update the scanController to- Throws:
StandardException- Thrown on error
-
canGetInstantaneousLocks
protected boolean canGetInstantaneousLocks()
Can we get instantaneous locks when getting share row locks at READ COMMITTED.- Specified by:
canGetInstantaneousLocksin classScanResultSet
-
isForUpdate
public boolean isForUpdate()
Is this ResultSet or it's source result set for update- Specified by:
isForUpdatein interfaceNoPutResultSet- Overrides:
isForUpdatein classNoPutResultSetImpl- Returns:
- Whether or not the result set is for update.
-
clone
public java.lang.Object clone()
Shallow clone this result set. Used in trigger reference. beetle 4373.- Overrides:
clonein classjava.lang.Object
-
-