org.apache.derby.impl.sql.compile
Class IndexToBaseRowNode

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.ResultSetNode
          extended byorg.apache.derby.impl.sql.compile.FromTable
              extended byorg.apache.derby.impl.sql.compile.IndexToBaseRowNode
All Implemented Interfaces:
Optimizable, Visitable

public class IndexToBaseRowNode
extends FromTable

This node type translates an index row to a base row. It takes a FromBaseTable as its source ResultSetNode, and generates an IndexRowToBaseRowResultSet that takes a TableScanResultSet on an index conglomerate as its source.


Field Summary
protected  ConglomerateDescriptor baseCD
           
protected  boolean cursorTargetTable
           
protected  boolean forUpdate
           
private  FormatableBitSet heapReferencedCols
           
private  FormatableBitSet indexReferencedCols
           
protected  PredicateList restrictionList
           
protected  FromBaseTable source
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.FromTable
bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, loadFactor, maxCapacity, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategy
 
Fields inherited from class org.apache.derby.impl.sql.compile.ResultSetNode
costEstimate, insertSource, optimizer, referencedTableMap, resultColumns, resultSetNumber, scratchCostEstimate, statementResultSet
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
IndexToBaseRowNode()
           
 
Method Summary
(package private)  void decrementLevel(int decrement)
          Decrement (query block) level (0-based) for this FromTable.
 boolean forUpdate()
          Return true if this is the target table of an update
 void generate(ActivationClassBuilder acb, MethodBuilder mb)
          Generation of an IndexToBaseRowNode creates an IndexRowToBaseRowResultSet, which uses the RowLocation in the last column of an index row to get the row from the base conglomerate (heap).
 CostEstimate getCostEstimate()
          Get the CostEstimate for this ResultSetNode.
 CostEstimate getFinalCostEstimate()
          Get the final CostEstimate for this ResultSetNode.
private  int[] getIndexColMapping()
          Fill in the column mapping for those columns coming from the index.
 AccessPath getTrulyTheBestAccessPath()
          Get the best access path overall for this Optimizable.
 void init(java.lang.Object source, java.lang.Object baseCD, java.lang.Object resultColumns, java.lang.Object cursorTargetTable, java.lang.Object heapReferencedCols, java.lang.Object indexReferencedCols, java.lang.Object restrictionList, java.lang.Object forUpdate, java.lang.Object tableProperties)
          Initialize a query tree node.
 boolean isNotExists()
          Return whether or not the underlying FBT is for NOT EXISTS.
 boolean isOneRowResultSet()
          Return whether or not the underlying ResultSet tree will return a single row, at most.
(package private)  boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, java.util.Vector fbtVector)
          Return whether or not the underlying ResultSet tree is ordered on the specified columns.
(package private)  void markOrderingDependent()
          Notify the underlying result set tree that the result is ordering dependent.
 int updateTargetLockMode()
          Get the lock mode for the target of an update statement (a delete or update).
 
Methods inherited from class org.apache.derby.impl.sql.compile.FromTable
areAllColumnsProjected, assignCostEstimate, canBeOrdered, considerSortAvoidancePath, convertAbsoluteToRelativeColumnPosition, cursorTargetTable, estimateCost, feasibleJoinStrategy, fillInReferencedTableMap, flatten, getBaseTableName, getBestAccessPath, getBestSortAvoidancePath, getCostEstimate, getCurrentAccessPath, getExposedName, getFromTableByName, getLevel, getName, getNumColumnsReturned, getProperties, getResultColumnsForList, getSchemaDescriptor, getSchemaDescriptor, getScratchCostEstimate, getTableDescriptor, getTableName, getTableNumber, getUserSpecifiedJoinStrategy, hashKeyColumns, hasTableNumber, init, initAccessPaths, initialCapacity, isBaseTable, isCoveringIndex, isFlattenableJoinNode, isMaterializable, isOneRowScan, isTargetTable, legalJoinOrder, loadFactor, LOJ_reorderable, markUpdatableByCursor, maxCapacity, memoryUsageOK, modifyAccessPath, needsSpecialRCLBinding, nextAccessPath, optimizeIt, optimizeSubqueries, pullOptPredicates, pushExpressions, pushOptPredicate, rememberAsBest, rememberJoinStrategyAsBest, rememberSortAvoidancePath, resetJoinStrategies, setAllColumnsProjected, setCostEstimate, setHashKeyColumns, setLevel, setProperties, setTableNumber, startOptimizing, supportsMultipleInstantiations, tellRowOrderingAboutConstantColumns, toString, transformOuterJoins, uniqueJoin, verifyProperties
 
Methods inherited from class org.apache.derby.impl.sql.compile.ResultSetNode
accept, addNewPredicate, assignResultSetNumber, bindExpressions, bindExpressionsWithTables, bindNonVTITables, bindResultColumns, bindResultColumns, bindTargetExpressions, bindUntypedNullsToResultColumns, bindVTITables, changeAccessPath, closeMethodArgument, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, ensurePredicateList, flattenableInFromSubquery, generateNormalizationResultSet, generateResultSet, genNewRCForInsert, genNormalizeResultSetNode, genProjectRestrict, genProjectRestrict, genProjectRestrictForReordering, getAllResultColumns, getCursorTargetTable, getFromList, getMatchingColumn, getNewCostEstimate, getOptimizer, getReferencedTableMap, getResultColumns, getResultSetNumber, isPossibleDistinctScan, isUpdatableCursor, LOJgetReferencedTables, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markStatementResultSet, modifyAccessPaths, notCursorTargetTable, notFlattenableJoin, numDistinctAggregates, optimize, parseDefault, performMaterialization, preprocess, printSubNodes, projectResultColumns, pushOrderByList, referencesTarget, rejectParameters, rejectXMLValues, renameGeneratedResultNames, replaceDefaults, returnsAtMostOneRow, setInsertSource, setReferencedTableMap, setResultColumns, setResultToBooleanTrueNode, setTableConstructorTypes, subqueryReferencesTarget, verifySelectStarSubquery
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.sql.compile.Optimizable
getDataDictionary, getReferencedTableMap, getResultSetNumber
 

Field Detail

source

protected FromBaseTable source

baseCD

protected ConglomerateDescriptor baseCD

cursorTargetTable

protected boolean cursorTargetTable

restrictionList

protected PredicateList restrictionList

forUpdate

protected boolean forUpdate

heapReferencedCols

private FormatableBitSet heapReferencedCols

indexReferencedCols

private FormatableBitSet indexReferencedCols
Constructor Detail

IndexToBaseRowNode

public IndexToBaseRowNode()
Method Detail

init

public void init(java.lang.Object source,
                 java.lang.Object baseCD,
                 java.lang.Object resultColumns,
                 java.lang.Object cursorTargetTable,
                 java.lang.Object heapReferencedCols,
                 java.lang.Object indexReferencedCols,
                 java.lang.Object restrictionList,
                 java.lang.Object forUpdate,
                 java.lang.Object tableProperties)
Description copied from class: QueryTreeNode
Initialize a query tree node.

Overrides:
init in class QueryTreeNode

forUpdate

public boolean forUpdate()
Description copied from interface: Optimizable
Return true if this is the target table of an update

Specified by:
forUpdate in interface Optimizable
Overrides:
forUpdate in class FromTable
See Also:
Optimizable.forUpdate()

getTrulyTheBestAccessPath

public AccessPath getTrulyTheBestAccessPath()
Description copied from interface: Optimizable
Get the best access path overall for this Optimizable.

Specified by:
getTrulyTheBestAccessPath in interface Optimizable
Overrides:
getTrulyTheBestAccessPath in class FromTable
See Also:
Optimizable.getTrulyTheBestAccessPath()

getCostEstimate

public CostEstimate getCostEstimate()
Description copied from class: ResultSetNode
Get the CostEstimate for this ResultSetNode.

Overrides:
getCostEstimate in class ResultSetNode
Returns:
The CostEstimate for this ResultSetNode.

getFinalCostEstimate

public CostEstimate getFinalCostEstimate()
Description copied from class: ResultSetNode
Get the final CostEstimate for this ResultSetNode.

Overrides:
getFinalCostEstimate in class ResultSetNode
Returns:
The final CostEstimate for this ResultSetNode.

isOrderedOn

boolean isOrderedOn(ColumnReference[] crs,
                    boolean permuteOrdering,
                    java.util.Vector fbtVector)
              throws StandardException
Return whether or not the underlying ResultSet tree is ordered on the specified columns. RESOLVE - This method currently only considers the outermost table of the query block.

Overrides:
isOrderedOn in class ResultSetNode
Parameters:
crs - The specified ColumnReference[]
permuteOrdering - Whether or not the order of the CRs in the array can be permuted
fbtVector - Vector that is to be filled with the FromBaseTable
Returns:
Whether the underlying ResultSet tree is ordered on the specified column.
Throws:
StandardException - Thrown on error

generate

public void generate(ActivationClassBuilder acb,
                     MethodBuilder mb)
              throws StandardException
Generation of an IndexToBaseRowNode creates an IndexRowToBaseRowResultSet, which uses the RowLocation in the last column of an index row to get the row from the base conglomerate (heap).

Overrides:
generate in class QueryTreeNode
Parameters:
acb - The ActivationClassBuilder for the class being built
mb - the method for the method to be built
Returns:
A compiled Expression that returns a ResultSet that gets a base from from an index row.
Throws:
StandardException - Thrown on error

isOneRowResultSet

public boolean isOneRowResultSet()
                          throws StandardException
Return whether or not the underlying ResultSet tree will return a single row, at most. This is important for join nodes where we can save the extra next on the right side if we know that it will return at most 1 row.

Overrides:
isOneRowResultSet in class ResultSetNode
Returns:
Whether or not the underlying ResultSet tree will return a single row.
Throws:
StandardException - Thrown on error

isNotExists

public boolean isNotExists()
Return whether or not the underlying FBT is for NOT EXISTS.

Overrides:
isNotExists in class ResultSetNode
Returns:
Whether or not the underlying FBT is for NOT EXISTS.

decrementLevel

void decrementLevel(int decrement)
Decrement (query block) level (0-based) for this FromTable. This is useful when flattening a subquery.

Overrides:
decrementLevel in class FromTable
Parameters:
decrement - The amount to decrement by.

updateTargetLockMode

public int updateTargetLockMode()
Get the lock mode for the target of an update statement (a delete or update). The update mode will always be row for CurrentOfNodes. It will be table if there is no where clause.

Overrides:
updateTargetLockMode in class ResultSetNode
Returns:
The lock mode
See Also:
TransactionController

markOrderingDependent

void markOrderingDependent()
Notify the underlying result set tree that the result is ordering dependent. (For example, no bulk fetch on an index if under an IndexRowToBaseRow.)

Overrides:
markOrderingDependent in class ResultSetNode
Returns:
Nothing.

getIndexColMapping

private int[] getIndexColMapping()
Fill in the column mapping for those columns coming from the index.

Returns:
The int[] with the mapping.

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.