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

pack-priv Class NestedLoopJoinStrategy

extends BaseJoinStrategy
Class Inheritance
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CostEstimate, .ExpressionClassBuilderInterface, .JoinStrategy, .Optimizable, .OptimizablePredicate, .OptimizablePredicateList, .Optimizer, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, .DataDictionary, org.apache.derby.iapi.store.access.StoreCostController, .TransactionController

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
divideUpPredicateLists(Optimizable
The inner table of the join
innerTable
,
OptimizablePredicateList
Initially contains all predicates. This method removes predicates from this list and moves them to other lists, as appropriate.
originalRestrictionList
,
OptimizablePredicateList
To be filled in with predicates to be pushed down to store.
storeRestrictionList
,
OptimizablePredicateList
To be filled in with predicates that are not pushed down to the store.
nonStoreRestrictionList
,
OptimizablePredicateList
Copy of predicates used to re-qualify rows, if necessary.
requalificationRestrictionList
,
DataDictionary
The DataDictionary
dd
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.divideUpPredicateLists.

Divide up the predicates into different lists for different phases of the operation.

public boolean
doesMaterialization()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.doesMaterialization.

Is materialization built in to the join strategy?

public void
estimateCost(Optimizable
The inner table to join with
innerTable
,
OptimizablePredicateList
The predicate list for the join
predList
,
ConglomerateDescriptor
The conglomerate descriptor (if appropriate) to get the cost of
cd
,
CostEstimate
The estimated cost of the part of the plan outer to the inner table
outerCost
,
Optimizer
The optimizer to use to help estimate the cost
optimizer
,
CostEstimate
The estimated cost of doing a single scan of the inner table, to be filled in with the cost of doing the join.
costEstimate
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.estimateCost.

Get the estimated cost for the join.

public boolean
feasible(Optimizable
The inner table of the join
innerTable
,
OptimizablePredicateList
The predicateList for the join
predList
,
Optimizer
The optimizer to use
optimizer
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.feasible.

Is this join strategy feasible under the circumstances?

public OptimizablePredicateList
getBasePredicates(OptimizablePredicateList
The predicate list to pull from.
predList
,
OptimizablePredicateList
The list to put the base predicates in.
basePredicates
,
Optimizable
The inner table of the join
innerTable
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getBasePredicates.

Get the base predicates for this join strategy.

public String
getName()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getName.

Get the name of this join strategy

public String
getOperatorSymbol()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getOperatorSymbol.

Get the operator symbol used to represent this join strategy in optimizer traces

public int
getScanArgs(TransactionController
The TransactionController
tc
,
MethodBuilder
The method to generate the arguments in
mb
,
Optimizable
The inner table of the join
innerTable
,
OptimizablePredicateList
The predicate list to be evaluated in the store
storeRestrictionList
,
OptimizablePredicateList
The predicate list to be evaluated outside of the store
nonStoreRestrictionList
,
ExpressionClassBuilderInterface
The expression class builder for the activation class we're building
acbi
,
int
The amount of bulk fetch to do
bulkFetch
,
int
The saved object index of a result row template
resultRowTemplate
,
int
The item number of the column reference bit map
colRefItem
,
int indexColItem, int
The lock mode to use when scanning the table (see TransactionController).
lockMode
,
boolean
Whether or not the table is marked (in sys.systables) as always using table locking
tableLocked
,
int
Isolation level specified (or not) for scans
isolationLevel
,
int
Max memory per table
maxMemoryPerTable
,
boolean
Whether or not we are going to generate IN-list values with which to probe the inner table.
genInListVals
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getScanArgs.

Get the appropriate arguments to the scan for this type of join.

public String
halfOuterJoinResultSetMethodName()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.halfOuterJoinResultSetMethodName.

Get the name of the join result set method for the half outerjoin

public String
joinResultSetMethodName()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.joinResultSetMethodName.

Get the name of the join result set method for the join

public int
maxCapacity(int userSpecifiedCapacity, int
maximum number of bytes per table
maxMemoryPerTable
,
double
number of bytes per row
perRowUsage
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.maxCapacity.

public boolean
multiplyBaseCostByOuterRows()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.multiplyBaseCostByOuterRows.

Returns true if the base cost of scanning the conglomerate should be multiplied by the number of outer rows.

public double
nonBasePredicateSelectivity(Optimizable
The inner table of the join.
innerTable
,
OptimizablePredicateList
The original predicate list that was passed to getBasePredicates(), from which some base predicates may have been pulled.
predList
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.nonBasePredicateSelectivity.

Get the extra selectivity of the non-base predicates (those that were left in the predicate list by getBasePredicates() that are not applied to the scan of the base conglomerate.

public void
putBasePredicates(OptimizablePredicateList
The list of predicates to put the base predicates back in.
predList
,
OptimizablePredicateList
The base predicates to put back in the list.
basePredicates
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.putBasePredicates.

Put back and base predicates that were removed from the list by getBasePredicates (see above).

public String
resultSetMethodName(boolean
True means bulk fetch is being done on the inner table
bulkFetch
,
boolean
True means we are probing the inner table for rows matching a specified list of values.
multiprobe
,
boolean
True of this is a special scan to validate a check constraint.
validatingCheckConstraint
)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.resultSetMethodName.

Get the name of the result set method for base table scans

public int
scanCostType()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.scanCostType.

Get the costing type, for use with StoreCostController.getScanCost

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected boolean

Returns:

Whether or not this join strategy can be used on the outermost table of a join.
validForOutermostTable
()

Overrides org.apache.derby.impl.sql.compile.BaseJoinStrategy.validForOutermostTable.

Can this join strategy be used on the outermost table of a join.

Inherited from org.apache.derby.impl.sql.compile.BaseJoinStrategy:
bulkFetchOKfillInScanArgs1fillInScanArgs2ignoreBulkFetchisHashJoin

Constructor Detail

NestedLoopJoinStrategyback to summary
pack-priv NestedLoopJoinStrategy()

Method Detail

divideUpPredicateListsback to summary
public void divideUpPredicateLists(Optimizable innerTable, OptimizablePredicateList originalRestrictionList, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, OptimizablePredicateList requalificationRestrictionList, DataDictionary dd) throws StandardException

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.divideUpPredicateLists.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.divideUpPredicateLists.

Divide up the predicates into different lists for different phases of the operation. When this method is called, all of the predicates will be in restrictionList. The effect of this method is to remove all of the predicates from restrictionList except those that will be pushed down to the store as start/stop predicates or Qualifiers. The remaining predicates will be put into nonBaseTableRestrictionList. All predicate lists will be ordered as necessary for use with the conglomerate. Some operations (like hash join) materialize results, and so require requalification of rows when doing a non-covering index scan. The predicates to use for requalification are copied into baseTableRestrictionList.

Parameters
innerTable:Optimizable

The inner table of the join

originalRestrictionList:OptimizablePredicateList

Initially contains all predicates. This method removes predicates from this list and moves them to other lists, as appropriate.

storeRestrictionList:OptimizablePredicateList

To be filled in with predicates to be pushed down to store.

nonStoreRestrictionList:OptimizablePredicateList

To be filled in with predicates that are not pushed down to the store.

requalificationRestrictionList:OptimizablePredicateList

Copy of predicates used to re-qualify rows, if necessary.

dd:DataDictionary

The DataDictionary

Exceptions
StandardException:
Thrown on error
See Also
JoinStrategy#divideUpPredicateLists
doesMaterializationback to summary
public boolean doesMaterialization()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.doesMaterialization.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.doesMaterialization.

Is materialization built in to the join strategy?

Returns:boolean

Whether or not materialization is built in to the join strategy

See Also
JoinStrategy#doesMaterialization
estimateCostback to summary
public void estimateCost(Optimizable innerTable, OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate costEstimate)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.estimateCost.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.estimateCost.

Get the estimated cost for the join.

Parameters
innerTable:Optimizable

The inner table to join with

predList:OptimizablePredicateList

The predicate list for the join

cd:ConglomerateDescriptor

The conglomerate descriptor (if appropriate) to get the cost of

outerCost:CostEstimate

The estimated cost of the part of the plan outer to the inner table

optimizer:Optimizer

The optimizer to use to help estimate the cost

costEstimate:CostEstimate

The estimated cost of doing a single scan of the inner table, to be filled in with the cost of doing the join.

feasibleback to summary
public boolean feasible(Optimizable innerTable, OptimizablePredicateList predList, Optimizer optimizer) throws StandardException

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.feasible.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.feasible.

Is this join strategy feasible under the circumstances?

Parameters
innerTable:Optimizable

The inner table of the join

predList:OptimizablePredicateList

The predicateList for the join

optimizer:Optimizer

The optimizer to use

Returns:boolean

true means the strategy is feasible, false means it isn't

Exceptions
StandardException:
Thrown on error
See Also
JoinStrategy#feasible
getBasePredicatesback to summary
public OptimizablePredicateList getBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates, Optimizable innerTable) throws StandardException

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getBasePredicates.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.getBasePredicates.

Get the base predicates for this join strategy. The base predicates are the ones that can be used while scanning the table. For some join strategies (for example, nested loop), all predicates are base predicates. For other join strategies (for example, hash join), the base predicates are those that involve comparisons with constant expressions. Also, order the base predicates according to the order in the proposed conglomerate descriptor for the inner table.

Parameters
predList:OptimizablePredicateList

The predicate list to pull from.

basePredicates:OptimizablePredicateList

The list to put the base predicates in.

innerTable:Optimizable

The inner table of the join

Returns:OptimizablePredicateList

The base predicate list. If no predicates are pulled, it may return the source predList without doing anything.

Exceptions
StandardException:
Thrown on error
See Also
JoinStrategy#getBasePredicates
getNameback to summary
public String getName()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getName.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.getName.

Get the name of this join strategy

See Also
JoinStrategy#getName
getOperatorSymbolback to summary
public String getOperatorSymbol()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getOperatorSymbol.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.getOperatorSymbol.

Get the operator symbol used to represent this join strategy in optimizer traces

See Also
JoinStrategy#getOperatorSymbol
getScanArgsback to summary
public int getScanArgs(TransactionController tc, MethodBuilder mb, Optimizable innerTable, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, ExpressionClassBuilderInterface acbi, int bulkFetch, int resultRowTemplate, int colRefItem, int indexColItem, int lockMode, boolean tableLocked, int isolationLevel, int maxMemoryPerTable, boolean genInListVals) throws StandardException

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.getScanArgs.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.getScanArgs.

Get the appropriate arguments to the scan for this type of join.

Parameters
tc:TransactionController

The TransactionController

mb:MethodBuilder

The method to generate the arguments in

innerTable:Optimizable

The inner table of the join

storeRestrictionList:OptimizablePredicateList

The predicate list to be evaluated in the store

nonStoreRestrictionList:OptimizablePredicateList

The predicate list to be evaluated outside of the store

acbi:ExpressionClassBuilderInterface

The expression class builder for the activation class we're building

bulkFetch:int

The amount of bulk fetch to do

resultRowTemplate:int

The saved object index of a result row template

colRefItem:int

The item number of the column reference bit map

lockMode:int

The lock mode to use when scanning the table (see TransactionController).

tableLocked:boolean

Whether or not the table is marked (in sys.systables) as always using table locking

isolationLevel:int

Isolation level specified (or not) for scans

maxMemoryPerTable:int

Max memory per table

genInListVals:boolean

Whether or not we are going to generate IN-list values with which to probe the inner table.

Returns:int

Count of the expressions pushed to use as the parameters to the result set for the inner table

Exceptions
StandardException:
Thrown on error
See Also
JoinStrategy#getScanArgs
halfOuterJoinResultSetMethodNameback to summary
public String halfOuterJoinResultSetMethodName()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.halfOuterJoinResultSetMethodName.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.halfOuterJoinResultSetMethodName.

Get the name of the join result set method for the half outerjoin

See Also
JoinStrategy#halfOuterJoinResultSetMethodName
joinResultSetMethodNameback to summary
public String joinResultSetMethodName()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.joinResultSetMethodName.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.joinResultSetMethodName.

Get the name of the join result set method for the join

See Also
JoinStrategy#joinResultSetMethodName
maxCapacityback to summary
public int maxCapacity(int userSpecifiedCapacity, int maxMemoryPerTable, double perRowUsage)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.maxCapacity.

Parameters
maxMemoryPerTable:int

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.maxCapacity.

maximum number of bytes per table

perRowUsage:double

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.maxCapacity.

number of bytes per row

Returns:int

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.maxCapacity.

The maximum number of rows that can be handled by this join strategy

See Also
JoinStrategy#maxCapacity
multiplyBaseCostByOuterRowsback to summary
public boolean multiplyBaseCostByOuterRows()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.multiplyBaseCostByOuterRows.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.multiplyBaseCostByOuterRows.

Returns true if the base cost of scanning the conglomerate should be multiplied by the number of outer rows.

See Also
JoinStrategy#multiplyBaseCostByOuterRows
nonBasePredicateSelectivityback to summary
public double nonBasePredicateSelectivity(Optimizable innerTable, OptimizablePredicateList predList)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.nonBasePredicateSelectivity.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.nonBasePredicateSelectivity.

Get the extra selectivity of the non-base predicates (those that were left in the predicate list by getBasePredicates() that are not applied to the scan of the base conglomerate.

Note

For some types of join strategy, it may not remove any predicates from the original predicate list. The join strategy is expected to know when it does this, and to return 1.0 as the extra selectivity in these cases.

Parameters
innerTable:Optimizable

The inner table of the join.

predList:OptimizablePredicateList

The original predicate list that was passed to getBasePredicates(), from which some base predicates may have been pulled.

Returns:double

The extra selectivity due to non-base predicates

See Also
JoinStrategy#nonBasePredicateSelectivity
putBasePredicatesback to summary
public void putBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates) throws StandardException

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.putBasePredicates.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.putBasePredicates.

Put back and base predicates that were removed from the list by getBasePredicates (see above).

Note

Those join strategies that treat all predicates as base predicates may treat the get and put methods as no-ops.

Parameters
predList:OptimizablePredicateList

The list of predicates to put the base predicates back in.

basePredicates:OptimizablePredicateList

The base predicates to put back in the list.

Exceptions
StandardException:
Thrown on error
See Also
JoinStrategy#putBasePredicates
resultSetMethodNameback to summary
public String resultSetMethodName(boolean bulkFetch, boolean multiprobe, boolean validatingCheckConstraint)

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.resultSetMethodName.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.resultSetMethodName.

Get the name of the result set method for base table scans

Parameters
bulkFetch:boolean

True means bulk fetch is being done on the inner table

multiprobe:boolean

True means we are probing the inner table for rows matching a specified list of values.

validatingCheckConstraint:boolean

True of this is a special scan to validate a check constraint.

See Also
JoinStrategy#resultSetMethodName
scanCostTypeback to summary
public int scanCostType()

Implements org.apache.derby.iapi.sql.compile.JoinStrategy.scanCostType.

Doc from org.apache.derby.iapi.sql.compile.JoinStrategy.scanCostType.

Get the costing type, for use with StoreCostController.getScanCost

See Also
JoinStrategy#scanCostType
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
validForOutermostTableback to summary
protected boolean validForOutermostTable()

Overrides org.apache.derby.impl.sql.compile.BaseJoinStrategy.validForOutermostTable.

Can this join strategy be used on the outermost table of a join.

Returns:boolean

Whether or not this join strategy can be used on the outermost table of a join.

Annotations
@Override