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

pack-priv Class IndexToBaseRowNode

extends FromTable
Class Inheritance
Imports
java.util.List, .Properties, org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.iapi.sql.compile.AccessPath, .CostEstimate, .Optimizable, .RequiredRowOrdering, .Visitor, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo

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

Modifier and TypeField and Description
private FormatableBitSet
protected ConglomerateDescriptor
protected boolean
protected boolean
private FormatableBitSet
private FormatableBitSet
private FormatableBitSet
protected PredicateList
protected FromBaseTable
Inherited from org.apache.derby.impl.sql.compile.FromTable:
ADD_PLANbestAccessPathbestCostEstimatebestSortAvoidancePathcorrelationNamecorrTableNamecurrentAccessPathhashKeyColumnsinitialCapacitylevelLOAD_PLANloadFactormaxCapacityorigTableNameREMOVE_PLANtableNumbertablePropertiestrulyTheBestAccessPathuserSpecifiedJoinStrategy

Constructor Summary

AccessConstructor and Description
pack-priv
IndexToBaseRowNode(FromBaseTable source, ConglomerateDescriptor baseCD, ResultColumnList resultColumns, boolean cursorTargetTable, FormatableBitSet heapReferencedCols, FormatableBitSet indexReferencedCols, PredicateList restrictionList, boolean forUpdate, Properties tableProperties, ContextManager cm)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.FromTable.acceptChildren.

Accept the visitor for all visitable children of this node.

pack-priv void
adjustForSortElimination()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort.

pack-priv void
adjustForSortElimination(RequiredRowOrdering rowOrdering)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed.

pack-priv void
decrementLevel(int
The amount to decrement by.
decrement
)

Overrides org.apache.derby.impl.sql.compile.FromTable.decrementLevel.

Decrement (query block) level (0-based) for this FromTable.

public boolean
forUpdate()

Overrides org.apache.derby.impl.sql.compile.FromTable.forUpdate.

Implements org.apache.derby.iapi.sql.compile.Optimizable.forUpdate.

Return true if this is the target table of an update

pack-priv void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
the method for the method to be built
mb
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

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

pack-priv CostEstimate
getCostEstimate()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.getCostEstimate.

Get the CostEstimate for this ResultSetNode.

pack-priv CostEstimate
getFinalCostEstimate()

Overrides org.apache.derby.impl.sql.compile.FromTable.getFinalCostEstimate.

Get the final CostEstimate for this FromTable.

private int[]

Returns:

The int[] with the mapping.
getIndexColMapping
()

Fill in the column mapping for those columns coming from the index.

public AccessPath
pack-priv boolean

Returns:

Whether or not the underlying FBT is for NOT EXISTS.
isNotExists
()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.isNotExists.

Return whether or not the underlying FBT is for NOT EXISTS.

pack-priv boolean

Returns:

Whether or not the underlying ResultSet tree will return a single row.
isOneRowResultSet
()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.isOneRowResultSet.

Return whether or not the underlying ResultSet tree will return a single row, at most.

pack-priv boolean

Returns:

Whether the underlying ResultSet tree is ordered on the specified column.
isOrderedOn
(ColumnReference[]
The specified ColumnReference[]
crs
,
boolean
Whether or not the order of the CRs in the array can be permuted
permuteOrdering
,
List<FromBaseTable>
List that is to be filled with the FromBaseTable
fbtHolder
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.isOrderedOn.

Return whether or not the underlying ResultSet tree is ordered on the specified columns.

pack-priv int

Returns:

The lock mode
updateTargetLockMode
()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.updateTargetLockMode.

Get the lock mode for the target of an update statement (a delete or update).

Inherited from org.apache.derby.impl.sql.compile.FromTable:
assignCostEstimatecanBeOrderedcolumnsAreUpdatableconsiderSortAvoidancePathconvertAbsoluteToRelativeColumnPositioncursorTargetTableestimateCostfeasibleJoinStrategyfillInReferencedTableMapflattengetBaseTableNamegetBestAccessPathgetBestSortAvoidancePathgetCorrelationNamegetCostEstimategetCurrentAccessPathgetExposedNamegetFromTableByNamegetLevelgetMergeTableIDgetNamegetNumColumnsReturnedgetOrigTableNamegetPropertiesgetResultColumnsForListgetSchemaDescriptorgetSchemaDescriptorgetScratchCostEstimategetTableDescriptorgetTableNamegetTableNumbergetUserSpecifiedJoinStrategyhashKeyColumnshasLargeObjectColumnshasTableNumberinitAccessPathsinitialCapacityisBaseTableisCoveringIndexisFlattenableJoinNodeisJoinColumnForRightOuterJoinisMaterializableisOneRowScanisTargetTablelegalJoinOrderloadFactorLOJ_reorderablemarkUpdatableByCursormaxCapacitymemoryUsageOKmodifyAccessPathneedsSpecialRCLBindingnextAccessPathoptimizeItoptimizeSubqueriespullOptPredicatespushExpressionspushOptPredicaterememberAsBestrememberJoinStrategyAsBestrememberSortAvoidancePathresetJoinStrategiessetCostEstimateCostsetHashKeyColumnssetLevelsetMergeTableIDsetOrigTableNamesetPropertiessetTableNumberstartOptimizingsupportsMultipleInstantiationstellRowOrderingAboutConstantColumnstoStringtransformOuterJoinsuniqueJoinupdateBestPlanMapverifyProperties

Field Detail

allReferencedColsback to summary
private FormatableBitSet allReferencedCols
baseCDback to summary
protected ConglomerateDescriptor baseCD
cursorTargetTableback to summary
protected boolean cursorTargetTable

Hides org.apache.derby.impl.sql.compile.ResultSetNode.cursorTargetTable.

forUpdateback to summary
protected boolean forUpdate
heapOnlyReferencedColsback to summary
private FormatableBitSet heapOnlyReferencedCols
heapReferencedColsback to summary
private FormatableBitSet heapReferencedCols
indexReferencedColsback to summary
private FormatableBitSet indexReferencedCols
restrictionListback to summary
protected PredicateList restrictionList
sourceback to summary
protected FromBaseTable source

Constructor Detail

IndexToBaseRowNodeback to summary
pack-priv IndexToBaseRowNode(FromBaseTable source, ConglomerateDescriptor baseCD, ResultColumnList resultColumns, boolean cursorTargetTable, FormatableBitSet heapReferencedCols, FormatableBitSet indexReferencedCols, PredicateList restrictionList, boolean forUpdate, Properties tableProperties, ContextManager cm)

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

Overrides org.apache.derby.impl.sql.compile.FromTable.acceptChildren.

Accept the visitor for all visitable children of this node.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on error
adjustForSortEliminationback to summary
pack-priv void adjustForSortElimination()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

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.

Annotations
@Override
See Also
ResultSetNode#adjustForSortElimination
adjustForSortEliminationback to summary
pack-priv void adjustForSortElimination(RequiredRowOrdering rowOrdering) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed.

Annotations
@Override
See Also
ResultSetNode#adjustForSortElimination
decrementLevelback to summary
pack-priv void decrementLevel(int decrement)

Overrides org.apache.derby.impl.sql.compile.FromTable.decrementLevel.

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

Parameters
decrement:int

The amount to decrement by.

Annotations
@Override
forUpdateback to summary
public boolean forUpdate()

Overrides org.apache.derby.impl.sql.compile.FromTable.forUpdate.

Implements org.apache.derby.iapi.sql.compile.Optimizable.forUpdate.

Doc from org.apache.derby.iapi.sql.compile.Optimizable.forUpdate.

Return true if this is the target table of an update

Annotations
@Override
See Also
Optimizable#forUpdate
generateback to summary
pack-priv void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

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

Parameters
acb:ActivationClassBuilder

The ActivationClassBuilder for the class being built

mb:MethodBuilder

the method for the method to be built

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getCostEstimateback to summary
pack-priv CostEstimate getCostEstimate()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.getCostEstimate.

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.getCostEstimate.

Get the CostEstimate for this ResultSetNode.

Returns:CostEstimate

The CostEstimate for this ResultSetNode.

Annotations
@Override
getFinalCostEstimateback to summary
pack-priv CostEstimate getFinalCostEstimate()

Overrides org.apache.derby.impl.sql.compile.FromTable.getFinalCostEstimate.

Doc from org.apache.derby.impl.sql.compile.FromTable.getFinalCostEstimate.

Get the final CostEstimate for this FromTable.

Returns:CostEstimate

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.

Annotations
@Override
getIndexColMappingback to summary
private int[] getIndexColMapping()

Fill in the column mapping for those columns coming from the index.

Returns:int[]

The int[] with the mapping.

getTrulyTheBestAccessPathback to summary
public AccessPath getTrulyTheBestAccessPath()

Overrides org.apache.derby.impl.sql.compile.FromTable.getTrulyTheBestAccessPath.

Implements org.apache.derby.iapi.sql.compile.Optimizable.getTrulyTheBestAccessPath.

Doc from org.apache.derby.iapi.sql.compile.Optimizable.getTrulyTheBestAccessPath.

Get the best access path overall for this Optimizable.

Annotations
@Override
See Also
Optimizable#getTrulyTheBestAccessPath
isNotExistsback to summary
pack-priv boolean isNotExists()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.isNotExists.

Return whether or not the underlying FBT is for NOT EXISTS.

Returns:boolean

Whether or not the underlying FBT is for NOT EXISTS.

Annotations
@Override
isOneRowResultSetback to summary
pack-priv boolean isOneRowResultSet() throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.isOneRowResultSet.

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.

Returns:boolean

Whether or not the underlying ResultSet tree will return a single row.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
isOrderedOnback to summary
pack-priv boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, List<FromBaseTable> fbtHolder) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.isOrderedOn.

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.

Parameters
crs:ColumnReference[]

The specified ColumnReference[]

permuteOrdering:boolean

Whether or not the order of the CRs in the array can be permuted

fbtHolder:List<FromBaseTable>

List that is to be filled with the FromBaseTable

Returns:boolean

Whether the underlying ResultSet tree is ordered on the specified column.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
updateTargetLockModeback to summary
pack-priv int updateTargetLockMode()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.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.

Returns:int

The lock mode

Annotations
@Override