Class IndexToBaseRowNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.ResultSetNode
-
- org.apache.derby.impl.sql.compile.FromTable
-
- org.apache.derby.impl.sql.compile.IndexToBaseRowNode
-
- All Implemented Interfaces:
Optimizable
,Visitable
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.derby.impl.sql.compile.ResultSetNode
ResultSetNode.QueryExpressionClauses
-
-
Field Summary
Fields Modifier and Type Field Description private FormatableBitSet
allReferencedCols
protected ConglomerateDescriptor
baseCD
protected boolean
cursorTargetTable
protected boolean
forUpdate
private FormatableBitSet
heapOnlyReferencedCols
private FormatableBitSet
heapReferencedCols
private FormatableBitSet
indexReferencedCols
protected PredicateList
restrictionList
protected FromBaseTable
source
-
Fields inherited from class org.apache.derby.impl.sql.compile.FromTable
ADD_PLAN, bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, LOAD_PLAN, loadFactor, maxCapacity, origTableName, REMOVE_PLAN, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategy
-
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
-
Constructor Summary
Constructors Constructor Description IndexToBaseRowNode(FromBaseTable source, ConglomerateDescriptor baseCD, ResultColumnList resultColumns, boolean cursorTargetTable, FormatableBitSet heapReferencedCols, FormatableBitSet indexReferencedCols, PredicateList restrictionList, boolean forUpdate, java.util.Properties tableProperties, ContextManager cm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
acceptChildren(Visitor v)
Accept the visitor for all visitable children of this node.(package private) void
adjustForSortElimination()
Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort.(package private) void
adjustForSortElimination(RequiredRowOrdering rowOrdering)
Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed.(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(package private) 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).(package private) CostEstimate
getCostEstimate()
Get the CostEstimate for this ResultSetNode.(package private) CostEstimate
getFinalCostEstimate()
Get the final CostEstimate for this FromTable.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.(package private) boolean
isNotExists()
Return whether or not the underlying FBT is for NOT EXISTS.(package private) 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.List<FromBaseTable> fbtHolder)
Return whether or not the underlying ResultSet tree is ordered on the specified columns.(package private) 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
assignCostEstimate, canBeOrdered, columnsAreUpdatable, considerSortAvoidancePath, convertAbsoluteToRelativeColumnPosition, cursorTargetTable, estimateCost, feasibleJoinStrategy, fillInReferencedTableMap, flatten, getBaseTableName, getBestAccessPath, getBestSortAvoidancePath, getCorrelationName, getCostEstimate, getCurrentAccessPath, getExposedName, getFromTableByName, getLevel, getMergeTableID, getName, getNumColumnsReturned, getOrigTableName, getProperties, getResultColumnsForList, getSchemaDescriptor, getSchemaDescriptor, getScratchCostEstimate, getTableDescriptor, getTableName, getTableNumber, getUserSpecifiedJoinStrategy, hashKeyColumns, hasLargeObjectColumns, hasTableNumber, initAccessPaths, initialCapacity, isBaseTable, isCoveringIndex, isFlattenableJoinNode, isJoinColumnForRightOuterJoin, isMaterializable, isOneRowScan, isTargetTable, legalJoinOrder, loadFactor, LOJ_reorderable, markUpdatableByCursor, maxCapacity, memoryUsageOK, modifyAccessPath, needsSpecialRCLBinding, nextAccessPath, optimizeIt, optimizeSubqueries, pullOptPredicates, pushExpressions, pushOptPredicate, rememberAsBest, rememberJoinStrategyAsBest, rememberSortAvoidancePath, resetJoinStrategies, setCostEstimateCost, setHashKeyColumns, setLevel, setMergeTableID, setOrigTableName, setProperties, setTableNumber, startOptimizing, supportsMultipleInstantiations, tellRowOrderingAboutConstantColumns, toString, transformOuterJoins, uniqueJoin, updateBestPlanMap, verifyProperties
-
Methods inherited from class org.apache.derby.impl.sql.compile.ResultSetNode
addNewPredicate, assignResultSetNumber, bindExpressions, bindExpressionsWithTables, bindNonVTITables, bindResultColumns, bindResultColumns, bindTargetExpressions, bindUntypedNullsToResultColumns, bindVTITables, changeAccessPath, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, ensurePredicateList, flattenableInFromSubquery, generateNormalizationResultSet, generateResultSet, genProjectRestrict, genProjectRestrict, genProjectRestrictForReordering, getAllResultColumns, getCandidateFinalCostEstimate, getCursorTargetTable, getFromList, getMatchingColumn, getNewCostEstimate, getOptimizer, getOptimizerImpl, getRCLForInsert, getReferencedTableMap, getResultColumns, getResultSetNumber, getScratchCostEstimate, isCursorTargetTable, isInsertSource, isPossibleDistinctScan, isStatementResultSet, isUpdatableCursor, LOJgetReferencedTables, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markStatementResultSet, modifyAccessPaths, modifyAccessPaths, notCursorTargetTable, notFlattenableJoin, numDistinctAggregates, optimize, parseDefault, performMaterialization, preprocess, printQueryExpressionSuffixClauses, printSubNodes, projectResultColumns, pushOffsetFetchFirst, pushOrderByList, pushQueryExpressionSuffix, referencesTarget, rejectParameters, rejectXMLValues, renameGeneratedResultNames, replaceOrForbidDefaults, returnsAtMostOneRow, setCandidateFinalCostEstimate, setCostEstimate, setCursorTargetTable, setInsertSource, setOptimizer, setReferencedTableMap, setResultColumns, setResultSetNumber, setResultToBooleanTrueNode, setScratchCostEstimate, setTableConstructorTypes, subqueryReferencesTarget, verifySelectStarSubquery
-
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, 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, getOptimizerTracer, getReferencedTableMap, getResultSetNumber, optimizerTracingIsOn
-
Methods inherited from interface org.apache.derby.iapi.sql.compile.Visitable
accept, addTag, taggedWith
-
-
-
-
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
-
allReferencedCols
private FormatableBitSet allReferencedCols
-
heapOnlyReferencedCols
private FormatableBitSet heapOnlyReferencedCols
-
-
Constructor Detail
-
IndexToBaseRowNode
IndexToBaseRowNode(FromBaseTable source, ConglomerateDescriptor baseCD, ResultColumnList resultColumns, boolean cursorTargetTable, FormatableBitSet heapReferencedCols, FormatableBitSet indexReferencedCols, PredicateList restrictionList, boolean forUpdate, java.util.Properties tableProperties, ContextManager cm)
-
-
Method Detail
-
forUpdate
public boolean forUpdate()
Description copied from interface:Optimizable
Return true if this is the target table of an update- Specified by:
forUpdate
in interfaceOptimizable
- Overrides:
forUpdate
in classFromTable
- 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 interfaceOptimizable
- Overrides:
getTrulyTheBestAccessPath
in classFromTable
- See Also:
Optimizable.getTrulyTheBestAccessPath()
-
getCostEstimate
CostEstimate getCostEstimate()
Description copied from class:ResultSetNode
Get the CostEstimate for this ResultSetNode.- Overrides:
getCostEstimate
in classResultSetNode
- Returns:
- The CostEstimate for this ResultSetNode.
-
getFinalCostEstimate
CostEstimate getFinalCostEstimate()
Description copied from class:FromTable
Get the final CostEstimate for this FromTable.- Overrides:
getFinalCostEstimate
in classFromTable
- Returns:
- The final CostEstimate for this FromTable, which is the costEstimate of trulyTheBestAccessPath if there is one. If there's no trulyTheBestAccessPath for this node, then we just return the value stored in costEstimate as a default.
-
isOrderedOn
boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, java.util.List<FromBaseTable> fbtHolder) 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 classResultSetNode
- Parameters:
crs
- The specified ColumnReference[]permuteOrdering
- Whether or not the order of the CRs in the array can be permutedfbtHolder
- List 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
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 classQueryTreeNode
- Parameters:
acb
- The ActivationClassBuilder for the class being builtmb
- the method for the method to be built- Throws:
StandardException
- Thrown on error
-
isOneRowResultSet
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 classResultSetNode
- Returns:
- Whether or not the underlying ResultSet tree will return a single row.
- Throws:
StandardException
- Thrown on error
-
isNotExists
boolean isNotExists()
Return whether or not the underlying FBT is for NOT EXISTS.- Overrides:
isNotExists
in classResultSetNode
- 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 classFromTable
- Parameters:
decrement
- The amount to decrement by.
-
updateTargetLockMode
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 classResultSetNode
- Returns:
- The lock mode
- See Also:
TransactionController
-
adjustForSortElimination
void adjustForSortElimination()
Description copied from class:ResultSetNode
Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort. Sort elimination can happen as part of preprocessing (see esp. SelectNode.preprocess(...)) or it can happen if the optimizer chooses an access path that inherently returns the rows in the correct order (also known as a "sort avoidance" plan). In either case we drop the sort and rely on the underlying result set tree to return its rows in the correct order. For most types of ResultSetNodes we automatically get the rows in the correct order if the sort was eliminated. One exception to this rule, though, is the case of an IndexRowToBaseRowNode, for which we have to disable bulk fetching on the underlying base table. Otherwise the index scan could return rows out of order if the base table is updated while the scan is "in progress" (i.e. while the result set is open). In order to account for this (and potentially other, similar issues in the future) this method exists to notify the result set node that it is expected to return rows in the correct order. The result set can then take necessary action to satsify this requirement--such as disabling bulk fetch in the case of IndexRowToBaseRowNode. All of that said, any ResultSetNodes for which we could potentially eliminate sorts should override this method accordingly. So we don't ever expect to get here.- Overrides:
adjustForSortElimination
in classResultSetNode
- See Also:
ResultSetNode.adjustForSortElimination()
-
adjustForSortElimination
void adjustForSortElimination(RequiredRowOrdering rowOrdering) throws StandardException
Description copied from class:ResultSetNode
Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed.- Overrides:
adjustForSortElimination
in classResultSetNode
- Throws:
StandardException
- See Also:
ResultSetNode.adjustForSortElimination()
-
getIndexColMapping
private int[] getIndexColMapping()
Fill in the column mapping for those columns coming from the index.- Returns:
- The int[] with the mapping.
-
acceptChildren
void acceptChildren(Visitor v) throws StandardException
Accept the visitor for all visitable children of this node.- Overrides:
acceptChildren
in classFromTable
- Parameters:
v
- the visitor- Throws:
StandardException
- on error
-
-