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

pack-priv Class TableScanResultSet

extends ScanResultSet
implements CursorResultSet, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.apache.derby.iapi.sql.execute.CursorResultSet, org.apache.derby.iapi.sql.ResultSet
Known Direct Subclasses
org.apache.derby.impl.sql.execute.ValidateCheckConstraintResultSet, org.apache.derby.impl.sql.execute.BulkTableScanResultSet, org.apache.derby.impl.sql.execute.MultiProbeTableScanResultSet
Imports
java.util.Properties, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.loader.GeneratedMethod, 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.store.access.BackingStoreHashtable, .ConglomerateController, .DynamicCompiledOpenConglomInfo, .Qualifier, .ScanController, .StaticCompiledOpenConglomInfo, .TransactionController, org.apache.derby.iapi.types.DataValueDescriptor, .RowLocation

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.

Field Summary

Modifier and TypeField and Description
public boolean
protected long
protected boolean
protected DynamicCompiledOpenConglomInfo
private long
protected boolean
public boolean
protected int[]
public boolean
protected boolean
protected boolean
public boolean
protected BackingStoreHashtable
past2FutureTbl

This field is used by beetle 3865, updateable cursor using index.

public Qualifier[][]
protected boolean
private RowLocation
public int
protected long
protected boolean
pack-priv final boolean
protected ScanController
protected boolean
private Properties
protected boolean
protected StaticCompiledOpenConglomInfo
protected GeneratedMethod
protected ExecIndexRow
public String
protected int
protected GeneratedMethod
protected ExecIndexRow
public String
protected int
public String
Inherited from org.apache.derby.impl.sql.execute.ScanResultSet:
accessedColscandidatefetchRowLocationsindexNameisolationLevellockModeresultRowBuildertableName

Constructor Summary

AccessConstructor and Description
pack-priv
TableScanResultSet(long conglomId, StaticCompiledOpenConglomInfo scoci, Activation activation, int resultRowTemplate, int resultSetNumber, GeneratedMethod startKeyGetter, int startSearchOperator, GeneratedMethod stopKeyGetter, int stopSearchOperator, boolean sameStartStopPosition, Qualifier[][] qualifiers, String tableName, String userSuppliedOptimizerOverrides, 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

Modifier and TypeMethod and Description
protected boolean
canGetInstantaneousLocks()

Implements abstract org.apache.derby.impl.sql.execute.ScanResultSet.canGetInstantaneousLocks.

Can we get instantaneous locks when getting share row locks at READ COMMITTED.

public Object
clone()

Overrides java.lang.Object.clone.

Shallow clone this result set.

public void
close()

Overrides org.apache.derby.impl.sql.execute.ScanResultSet.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 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 Properties
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

pack-priv void
initStartAndStopKey()

Initialize the startPosition and stopPosition fields which are used to limit the rows returned by the scan.

public boolean

Returns:

Whether or not the result set is for update.
isForUpdate
()

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

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

Is this ResultSet or it's source result set for update

pack-priv boolean
loopControl(boolean moreRows)

public void
protected void
public void
private String
printPosition(int searchOperator, GeneratedMethod positionGetter, ExecIndexRow positioner)

Return a start or stop positioner as a String.

public String
printStartPosition()

Print an array of Qualifiers to the trace stream.

public String
public void
protected void
public boolean
protected final void
setRowCountIfPossible(long
The number of rows to update the scanController to
rowsThisScan
)

Update the number of rows in the scan controller.

Inherited from org.apache.derby.impl.sql.execute.ScanResultSet:
getScanIsolationLevelinitIsolationLevelsetRowLocationsStatetoXML

Field Detail

coarserLockback to summary
public boolean coarserLock
conglomIdback to summary
protected long conglomId
currentRowIsValidback to summary
protected boolean currentRowIsValid
dcociback to summary
protected DynamicCompiledOpenConglomInfo dcoci
estimatedRowCountback to summary
private long estimatedRowCount
firstScanback to summary
protected boolean firstScan
forUpdateback to summary
public boolean forUpdate
indexColsback to summary
protected int[] indexCols
isConstraintback to summary
public boolean isConstraint
isKeyedback to summary
protected boolean isKeyed
nextDoneback to summary
protected boolean nextDone
oneRowScanback to summary
public boolean oneRowScan
past2FutureTblback to summary
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.

qualifiersback to summary
public Qualifier[][] qualifiers
qualifyback to summary
protected boolean qualify
rlTemplateback to summary
private RowLocation rlTemplate
rowsPerReadback to summary
public int rowsPerRead
rowsThisScanback to summary
protected long rowsThisScan
runTimeStatisticsOnback to summary
protected boolean runTimeStatisticsOn
sameStartStopPositionback to summary
pack-priv final boolean sameStartStopPosition
scanControllerback to summary
protected ScanController scanController
scanControllerOpenedback to summary
protected boolean scanControllerOpened
scanPropertiesback to summary
private Properties scanProperties
scanRepositionedback to summary
protected boolean scanRepositioned
scociback to summary
protected StaticCompiledOpenConglomInfo scoci
startKeyGetterback to summary
protected GeneratedMethod startKeyGetter
startPositionback to summary
protected ExecIndexRow startPosition
startPositionStringback to summary
public String startPositionString
startSearchOperatorback to summary
protected int startSearchOperator
stopKeyGetterback to summary
protected GeneratedMethod stopKeyGetter
stopPositionback to summary
protected ExecIndexRow stopPosition
stopPositionStringback to summary
public String stopPositionString
stopSearchOperatorback to summary
protected int stopSearchOperator
userSuppliedOptimizerOverridesback to summary
public String userSuppliedOptimizerOverrides

Constructor Detail

TableScanResultSetback to summary
pack-priv TableScanResultSet(long conglomId, StaticCompiledOpenConglomInfo scoci, Activation activation, int resultRowTemplate, int resultSetNumber, GeneratedMethod startKeyGetter, int startSearchOperator, GeneratedMethod stopKeyGetter, int stopSearchOperator, boolean sameStartStopPosition, Qualifier[][] qualifiers, String tableName, String userSuppliedOptimizerOverrides, 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

Method Detail

canGetInstantaneousLocksback to summary
protected boolean canGetInstantaneousLocks()

Implements abstract org.apache.derby.impl.sql.execute.ScanResultSet.canGetInstantaneousLocks.

Can we get instantaneous locks when getting share row locks at READ COMMITTED.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Shallow clone this result set. Used in trigger reference. beetle 4373.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

closeback to summary
public void close() throws StandardException

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

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

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

Exceptions
StandardException:
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, the row has been deleted, or no longer qualifies (for forward only result sets) 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 any) from the scan (if open).

Returns:ExecRow

Doc from org.apache.derby.iapi.sql.execute.NoPutResultSet.getNextRowCore.

the next row in the result

Exceptions
StandardException:
thrown on failure to get next row
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. If the cursor is closed, or the row has been deleted a null is returned.

Returns:RowLocation

the row location of the current cursor row.

Exceptions
StandardException:
thrown on failure to get row location
See Also
CursorResultSet
getScanPropertiesback to summary
public Properties getScanProperties()
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).

initStartAndStopKeyback to summary
pack-priv void initStartAndStopKey() throws StandardException

Initialize the startPosition and stopPosition fields which are used to limit the rows returned by the scan.

isForUpdateback to summary
public boolean isForUpdate()

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

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

Is this ResultSet or it's source result set for update

Returns:boolean

Whether or not the result set is for update.

loopControlback to summary
pack-priv boolean loopControl(boolean moreRows) throws StandardException
openCoreback to summary
public void openCore() throws StandardException

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

open 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 on failure to open
openScanControllerback to summary
protected void openScanController(TransactionController tc) throws StandardException
positionScanAtRowLocationback to summary
public void positionScanAtRowLocation(RowLocation rl) throws StandardException

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

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

Doc from org.apache.derby.iapi.sql.execute.NoPutResultSet.positionScanAtRowLocation.

Positions 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.

Parameters
rl:RowLocation

row location of the current cursor row

Exceptions
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.
printPositionback to summary
private 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.

printStartPositionback to summary
public String printStartPosition()

Print an array of Qualifiers to the trace stream.

printStopPositionback to summary
public String printStopPosition()
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 table scan. Here we take advantage of the reopenScan() interface on scanController for optimimal performance on joins where we are an inner table.

Exceptions
StandardException:
thrown on failure to open
reopenScanControllerback to summary
protected void reopenScanController() throws StandardException
requiresRelockingback to summary
public boolean requiresRelocking()

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

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

Doc from org.apache.derby.iapi.sql.execute.NoPutResultSet.requiresRelocking.

Do we need to relock the row when going to the heap.

Returns:boolean

Whether or not we need to relock the row when going to the heap.

See Also
NoPutResultSet#requiresRelocking
setRowCountIfPossibleback to summary
protected final void setRowCountIfPossible(long rowsThisScan) throws StandardException

Update 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:long

The number of rows to update the scanController to

Exceptions
StandardException:
Thrown on error