java.lang.Object
org.apache.derby.impl.sql.compile.BaseJoinStrategy
org.apache.derby.impl.sql.compile.HashJoinStrategy
- All Implemented Interfaces:
- org.apache.derby.iapi.sql.compile.JoinStrategy
- public class HashJoinStrategy
- extends BaseJoinStrategy
|
Method Summary |
void |
divideUpPredicateLists(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList originalRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList storeRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList nonStoreRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList requalificationRestrictionList,
org.apache.derby.iapi.sql.dictionary.DataDictionary dd)
Divide up the predicates into different lists for different phases
of the operation. |
boolean |
doesMaterialization()
Is materialization built in to the join strategy? |
void |
estimateCost(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
org.apache.derby.iapi.sql.compile.CostEstimate outerCost,
org.apache.derby.iapi.sql.compile.Optimizer optimizer,
org.apache.derby.iapi.sql.compile.CostEstimate costEstimate)
Get the estimated cost for the join. |
boolean |
feasible(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.Optimizer optimizer)
Is this join strategy feasible under the circumstances? |
private int[] |
findHashKeyColumns(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList)
Find the hash key columns, if any, to use with this join. |
org.apache.derby.iapi.sql.compile.OptimizablePredicateList |
getBasePredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList basePredicates,
org.apache.derby.iapi.sql.compile.Optimizable innerTable)
Get the base predicates for this join strategy. |
java.lang.String |
getName()
Get the name of this join strategy |
int |
getScanArgs(org.apache.derby.iapi.store.access.TransactionController tc,
org.apache.derby.iapi.services.compiler.MethodBuilder mb,
org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList storeRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList nonStoreRestrictionList,
org.apache.derby.iapi.sql.compile.ExpressionClassBuilderInterface acbi,
int bulkFetch,
org.apache.derby.iapi.services.compiler.MethodBuilder resultRowAllocator,
int colRefItem,
int indexColItem,
int lockMode,
boolean tableLocked,
int isolationLevel,
int maxMemoryPerTable)
Get the appropriate arguments to the scan for this type of join. |
java.lang.String |
halfOuterJoinResultSetMethodName()
Get the name of the join result set method for the half outerjoin |
boolean |
ignoreBulkFetch()
Should we just ignore bulk fetch with this join strategy? |
boolean |
isHashJoin()
Is this a form of hash join? |
java.lang.String |
joinResultSetMethodName()
Get the name of the join result set method for the join |
int |
maxCapacity(int userSpecifiedCapacity,
int maxMemoryPerTable,
double perRowUsage)
|
boolean |
multiplyBaseCostByOuterRows()
Returns true if the base cost of scanning the conglomerate should be
multiplied by the number of outer rows. |
double |
nonBasePredicateSelectivity(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList)
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. |
void |
putBasePredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList basePredicates)
Put back and base predicates that were removed from the list by
getBasePredicates (see above). |
java.lang.String |
resultSetMethodName(boolean bulkFetch)
Get the name of the result set method for base table scans |
int |
scanCostType()
Get the costing type, for use with StoreCostController.getScanCost |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
HashJoinStrategy
public HashJoinStrategy()
feasible
public boolean feasible(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.Optimizer optimizer)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Is this join strategy feasible under the circumstances?
ignoreBulkFetch
public boolean ignoreBulkFetch()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Should we just ignore bulk fetch with this join strategy?
- Specified by:
ignoreBulkFetch in interface org.apache.derby.iapi.sql.compile.JoinStrategy- Overrides:
ignoreBulkFetch in class BaseJoinStrategy
multiplyBaseCostByOuterRows
public boolean multiplyBaseCostByOuterRows()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Returns true if the base cost of scanning the conglomerate should be
multiplied by the number of outer rows.
getBasePredicates
public org.apache.derby.iapi.sql.compile.OptimizablePredicateList getBasePredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList basePredicates,
org.apache.derby.iapi.sql.compile.Optimizable innerTable)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- 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.
nonBasePredicateSelectivity
public double nonBasePredicateSelectivity(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList)
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- 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.
putBasePredicates
public void putBasePredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList basePredicates)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- 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.
estimateCost
public void estimateCost(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
org.apache.derby.iapi.sql.compile.CostEstimate outerCost,
org.apache.derby.iapi.sql.compile.Optimizer optimizer,
org.apache.derby.iapi.sql.compile.CostEstimate costEstimate)
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Get the estimated cost for the join.
maxCapacity
public int maxCapacity(int userSpecifiedCapacity,
int maxMemoryPerTable,
double perRowUsage)
getName
public java.lang.String getName()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Get the name of this join strategy
scanCostType
public int scanCostType()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Get the costing type, for use with StoreCostController.getScanCost
resultSetMethodName
public java.lang.String resultSetMethodName(boolean bulkFetch)
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Get the name of the result set method for base table scans
joinResultSetMethodName
public java.lang.String joinResultSetMethodName()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Get the name of the join result set method for the join
halfOuterJoinResultSetMethodName
public java.lang.String halfOuterJoinResultSetMethodName()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Get the name of the join result set method for the half outerjoin
getScanArgs
public int getScanArgs(org.apache.derby.iapi.store.access.TransactionController tc,
org.apache.derby.iapi.services.compiler.MethodBuilder mb,
org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList storeRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList nonStoreRestrictionList,
org.apache.derby.iapi.sql.compile.ExpressionClassBuilderInterface acbi,
int bulkFetch,
org.apache.derby.iapi.services.compiler.MethodBuilder resultRowAllocator,
int colRefItem,
int indexColItem,
int lockMode,
boolean tableLocked,
int isolationLevel,
int maxMemoryPerTable)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Get the appropriate arguments to the scan for this type of join.
divideUpPredicateLists
public void divideUpPredicateLists(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList originalRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList storeRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList nonStoreRestrictionList,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList requalificationRestrictionList,
org.apache.derby.iapi.sql.dictionary.DataDictionary dd)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- 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.
isHashJoin
public boolean isHashJoin()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Is this a form of hash join?
- Specified by:
isHashJoin in interface org.apache.derby.iapi.sql.compile.JoinStrategy- Overrides:
isHashJoin in class BaseJoinStrategy
doesMaterialization
public boolean doesMaterialization()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.JoinStrategy
- Is materialization built in to the join strategy?
findHashKeyColumns
private int[] findHashKeyColumns(org.apache.derby.iapi.sql.compile.Optimizable innerTable,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList)
throws org.apache.derby.iapi.error.StandardException
- Find the hash key columns, if any, to use with this join.
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object
- Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method
never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string
concatenation with this object. If the result is
null, string concatenation will instead
use "null".
The default implementation returns
getClass().getName() + "@" +
Integer.toHexString(hashCode()).