org.apache.derby.impl.sql.execute
Class HashScanResultSet

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
      extended by org.apache.derby.impl.sql.execute.NoPutResultSetImpl
          extended by org.apache.derby.impl.sql.execute.ScanResultSet
              extended by org.apache.derby.impl.sql.execute.HashScanResultSet
All Implemented Interfaces:
CursorResultSet, NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource
Direct Known Subclasses:
DistinctScanResultSet

public class HashScanResultSet
extends ScanResultSet
implements CursorResultSet

Takes a conglomerate and a table filter builds a hash table on the specified column of the conglomerate on the 1st open. Look up into the hash table is done on the hash key column. The hash table consists of either DataValueDescriptor[]s or Lists of DataValueDescriptor[]. The store builds the hash table. When a collision occurs, the store builds a List with the colliding DataValueDescriptor[]s.


Field Summary
protected  ExecRow compactRow
           
private  long conglomId
           
static int DEFAULT_INITIAL_CAPACITY
           
static float DEFAULT_LOADFACTOR
           
static int DEFAULT_MAX_CAPACITY
           
protected  boolean eliminateDuplicates
           
private  java.util.List entryVector
           
private  int entryVectorSize
           
protected  boolean firstNext
           
 boolean forUpdate
           
protected  BackingStoreHashtable hashtable
           
private  boolean hashtableBuilt
           
 int hashtableSize
           
 java.lang.String indexName
           
private  int initialCapacity
           
 boolean isConstraint
           
private  boolean keepAfterCommit
           
 int[] keyColumns
           
private  float loadFactor
           
private  int maxCapacity
           
 Qualifier[][] nextQualifiers
           
private  int numFetchedOnNext
           
private  GeneratedMethod resultRowAllocator
           
private  boolean runTimeStatisticsOn
           
private  boolean sameStartStopPosition
           
 java.util.Properties scanProperties
           
 Qualifier[][] scanQualifiers
           
protected  StaticCompiledOpenConglomInfo scoci
           
private  boolean skipNullKeyColumns
           
private  GeneratedMethod startKeyGetter
           
private  ExecIndexRow startPosition
           
 java.lang.String startPositionString
           
private  int startSearchOperator
           
private  GeneratedMethod stopKeyGetter
           
private  ExecIndexRow stopPosition
           
 java.lang.String stopPositionString
           
private  int stopSearchOperator
           
 java.lang.String tableName
           
 java.lang.String userSuppliedOptimizerOverrides
           
 
Fields inherited from class org.apache.derby.impl.sql.execute.ScanResultSet
accessedCols, candidate, isolationLevel, lockMode
 
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, 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.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
 
Fields inherited from interface org.apache.derby.iapi.sql.execute.NoPutResultSet
ABSOLUTE, FIRST, LAST, NEXT, PREVIOUS, RELATIVE
 
Constructor Summary
HashScanResultSet(long conglomId, StaticCompiledOpenConglomInfo scoci, Activation activation, GeneratedMethod resultRowAllocator, int resultSetNumber, GeneratedMethod startKeyGetter, int startSearchOperator, GeneratedMethod stopKeyGetter, int stopSearchOperator, boolean sameStartStopPosition, Qualifier[][] scanQualifiers, Qualifier[][] nextQualifiers, int initialCapacity, float loadFactor, int maxCapacity, int hashKeyItem, java.lang.String tableName, java.lang.String userSuppliedOptimizerOverrides, java.lang.String indexName, boolean isConstraint, boolean forUpdate, int colRefItem, int lockMode, boolean tableLocked, int isolationLevel, boolean skipNullKeyColumns, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
           
 
Method Summary
(package private)  boolean canGetInstantaneousLocks()
          Can we get instantaneous locks when getting share row locks at READ COMMITTED.
 void close()
          If the result set has been opened, close the open scan.
 ExecRow getCurrentRow()
          This result set has its row from the last fetch done.
 ExecRow getNextRowCore()
          Return the next row (if any) from the scan (if open).
 RowLocation getRowLocation()
          This result set has its row location from the last fetch done.
 java.util.Properties getScanProperties()
           
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
 boolean isForUpdate()
          Is this ResultSet or it's source result set for update
 void openCore()
          open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...
private  java.lang.String printPosition(int searchOperator, GeneratedMethod positionGetter, ExecIndexRow eiRow)
          Return a start or stop positioner as a String.
 java.lang.String printStartPosition()
           
 java.lang.String printStopPosition()
           
 void reopenCore()
          reopen this ResultSet.
 boolean requiresRelocking()
          Do we need to relock the row when going to the heap.
private  void resetProbeVariables()
           
 
Methods inherited from class org.apache.derby.impl.sql.execute.ScanResultSet
getScanIsolationLevel, initIsolationLevel
 
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, markRowAsDeleted, needsRowLocation, needsToClone, positionScanAtRowLocation, printQualifiers, resultSetNumber, rowLocation, setCurrentRow, setNeedsRowLocation, setTargetResultSet, skipRow, skipScan, updateRow
 
Methods inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
addWarning, attachStatementContext, checkCancellationFlag, checkRowPosition, 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, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, returnsRows, setAfterLastRow, setBeforeFirstRow, setCompactRow, setCompatRow
 
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
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
 

Field Detail

hashtableBuilt

private boolean hashtableBuilt

startPosition

private ExecIndexRow startPosition

stopPosition

private ExecIndexRow stopPosition

compactRow

protected ExecRow compactRow

firstNext

protected boolean firstNext

numFetchedOnNext

private int numFetchedOnNext

entryVectorSize

private int entryVectorSize

entryVector

private java.util.List entryVector

conglomId

private long conglomId

scoci

protected StaticCompiledOpenConglomInfo scoci

resultRowAllocator

private GeneratedMethod resultRowAllocator

startKeyGetter

private GeneratedMethod startKeyGetter

startSearchOperator

private int startSearchOperator

stopKeyGetter

private GeneratedMethod stopKeyGetter

stopSearchOperator

private int stopSearchOperator

scanQualifiers

public Qualifier[][] scanQualifiers

nextQualifiers

public Qualifier[][] nextQualifiers

initialCapacity

private int initialCapacity

loadFactor

private float loadFactor

maxCapacity

private int maxCapacity

tableName

public java.lang.String tableName

userSuppliedOptimizerOverrides

public java.lang.String userSuppliedOptimizerOverrides

indexName

public java.lang.String indexName

forUpdate

public boolean forUpdate

runTimeStatisticsOn

private boolean runTimeStatisticsOn

keyColumns

public int[] keyColumns

sameStartStopPosition

private boolean sameStartStopPosition

skipNullKeyColumns

private boolean skipNullKeyColumns

keepAfterCommit

private boolean keepAfterCommit

hashtable

protected BackingStoreHashtable hashtable

eliminateDuplicates

protected boolean eliminateDuplicates

scanProperties

public java.util.Properties scanProperties

startPositionString

public java.lang.String startPositionString

stopPositionString

public java.lang.String stopPositionString

hashtableSize

public int hashtableSize

isConstraint

public boolean isConstraint

DEFAULT_INITIAL_CAPACITY

public static final int DEFAULT_INITIAL_CAPACITY
See Also:
Constant Field Values

DEFAULT_LOADFACTOR

public static final float DEFAULT_LOADFACTOR
See Also:
Constant Field Values

DEFAULT_MAX_CAPACITY

public static final int DEFAULT_MAX_CAPACITY
See Also:
Constant Field Values
Constructor Detail

HashScanResultSet

HashScanResultSet(long conglomId,
                  StaticCompiledOpenConglomInfo scoci,
                  Activation activation,
                  GeneratedMethod resultRowAllocator,
                  int resultSetNumber,
                  GeneratedMethod startKeyGetter,
                  int startSearchOperator,
                  GeneratedMethod stopKeyGetter,
                  int stopSearchOperator,
                  boolean sameStartStopPosition,
                  Qualifier[][] scanQualifiers,
                  Qualifier[][] nextQualifiers,
                  int initialCapacity,
                  float loadFactor,
                  int maxCapacity,
                  int hashKeyItem,
                  java.lang.String tableName,
                  java.lang.String userSuppliedOptimizerOverrides,
                  java.lang.String indexName,
                  boolean isConstraint,
                  boolean forUpdate,
                  int colRefItem,
                  int lockMode,
                  boolean tableLocked,
                  int isolationLevel,
                  boolean skipNullKeyColumns,
                  double optimizerEstimatedRowCount,
                  double optimizerEstimatedCost)
            throws StandardException
Throws:
StandardException
Method Detail

canGetInstantaneousLocks

boolean canGetInstantaneousLocks()
Can we get instantaneous locks when getting share row locks at READ COMMITTED.

Specified by:
canGetInstantaneousLocks in class ScanResultSet

openCore

public void openCore()
              throws StandardException
open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...

Specified by:
openCore in interface NoPutResultSet
Throws:
StandardException - thrown on failure to open

reopenCore

public void reopenCore()
                throws StandardException
reopen this ResultSet.

Specified by:
reopenCore in interface NoPutResultSet
Overrides:
reopenCore in class BasicNoPutResultSetImpl
Throws:
StandardException - thrown if cursor finished.
See Also:
NoPutResultSet.openCore()

resetProbeVariables

private void resetProbeVariables()
                          throws StandardException
Throws:
StandardException

getNextRowCore

public ExecRow getNextRowCore()
                       throws StandardException
Return the next row (if any) from the scan (if open).

Specified by:
getNextRowCore in interface NoPutResultSet
Specified by:
getNextRowCore in class BasicNoPutResultSetImpl
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 StandardException
If the result set has been opened, close the open scan.

Specified by:
close in interface ResultSet
Overrides:
close in class ScanResultSet
Throws:
StandardException - thrown on error

getTimeSpent

public long getTimeSpent(int type)
Return the total amount of time spent in this ResultSet

Specified by:
getTimeSpent in interface ResultSet
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).

requiresRelocking

public boolean requiresRelocking()
Description copied from interface: NoPutResultSet
Do we need to relock the row when going to the heap.

Specified by:
requiresRelocking in interface NoPutResultSet
Overrides:
requiresRelocking in class BasicNoPutResultSetImpl
Returns:
Whether or not we need to relock the row when going to the heap.
See Also:
NoPutResultSet.requiresRelocking()

getRowLocation

public RowLocation getRowLocation()
                           throws StandardException
This result set has its row location from the last fetch done. If the cursor is closed, a null is returned.

Specified by:
getRowLocation in interface CursorResultSet
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, a null is returned.

Specified by:
getCurrentRow in interface CursorResultSet
Returns:
the last row returned;
Throws:
StandardException - thrown on failure.
See Also:
CursorResultSet

printStartPosition

public java.lang.String printStartPosition()

printStopPosition

public java.lang.String printStopPosition()

printPosition

private java.lang.String printPosition(int searchOperator,
                                       GeneratedMethod positionGetter,
                                       ExecIndexRow eiRow)
Return a start or stop positioner as a String.


getScanProperties

public java.util.Properties getScanProperties()

isForUpdate

public boolean isForUpdate()
Is this ResultSet or it's source result set for update

Specified by:
isForUpdate in interface NoPutResultSet
Overrides:
isForUpdate in class NoPutResultSetImpl
Returns:
Whether or not the result set is for update.

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.