Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.sql.compile
Interface JoinStrategy  view JoinStrategy download JoinStrategy.java


public interface JoinStrategy

A JoinStrategy represents a strategy like nested loop, hash join, merge join, etc. It tells the optimizer whether the strategy is feasible in a given situation, how much the strategy costs, whether the strategy requires the data from the source result sets to be ordered, etc.


Method Summary
 boolean bulkFetchOK()
          Is it OK to use bulk fetch with this join strategy?
 void divideUpPredicateLists(Optimizable innerTable, OptimizablePredicateList originalRestrictionList, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, 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(Optimizable innerTable, OptimizablePredicateList predList, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate costEstimate)
          Get the estimated cost for the join.
 boolean feasible(Optimizable innerTable, OptimizablePredicateList predList, Optimizer optimizer)
          Is this join strategy feasible under the circumstances?
 OptimizablePredicateList getBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates, 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, Optimizable innerTable, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, ExpressionClassBuilderInterface acb, 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(Optimizable innerTable, 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(OptimizablePredicateList predList, 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
 

Method Detail

feasible

public boolean feasible(Optimizable innerTable,
                        OptimizablePredicateList predList,
                        Optimizer optimizer)
                 throws org.apache.derby.iapi.error.StandardException
Is this join strategy feasible under the circumstances?


bulkFetchOK

public boolean bulkFetchOK()
Is it OK to use bulk fetch with this join strategy?


ignoreBulkFetch

public boolean ignoreBulkFetch()
Should we just ignore bulk fetch with this join strategy?


multiplyBaseCostByOuterRows

public boolean multiplyBaseCostByOuterRows()
Returns true if the base cost of scanning the conglomerate should be multiplied by the number of outer rows.


getBasePredicates

public OptimizablePredicateList getBasePredicates(OptimizablePredicateList predList,
                                                  OptimizablePredicateList basePredicates,
                                                  Optimizable innerTable)
                                           throws org.apache.derby.iapi.error.StandardException
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(Optimizable innerTable,
                                          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. 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(OptimizablePredicateList predList,
                              OptimizablePredicateList basePredicates)
                       throws org.apache.derby.iapi.error.StandardException
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(Optimizable innerTable,
                         OptimizablePredicateList predList,
                         org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
                         CostEstimate outerCost,
                         Optimizer optimizer,
                         CostEstimate costEstimate)
                  throws org.apache.derby.iapi.error.StandardException
Get the estimated cost for the join.


maxCapacity

public int maxCapacity(int userSpecifiedCapacity,
                       int maxMemoryPerTable,
                       double perRowUsage)

getName

public java.lang.String getName()
Get the name of this join strategy


scanCostType

public int scanCostType()
Get the costing type, for use with StoreCostController.getScanCost


resultSetMethodName

public java.lang.String resultSetMethodName(boolean bulkFetch)
Get the name of the result set method for base table scans


joinResultSetMethodName

public java.lang.String joinResultSetMethodName()
Get the name of the join result set method for the join


halfOuterJoinResultSetMethodName

public java.lang.String halfOuterJoinResultSetMethodName()
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,
                       Optimizable innerTable,
                       OptimizablePredicateList storeRestrictionList,
                       OptimizablePredicateList nonStoreRestrictionList,
                       ExpressionClassBuilderInterface acb,
                       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
Get the appropriate arguments to the scan for this type of join.


divideUpPredicateLists

public void divideUpPredicateLists(Optimizable innerTable,
                                   OptimizablePredicateList originalRestrictionList,
                                   OptimizablePredicateList storeRestrictionList,
                                   OptimizablePredicateList nonStoreRestrictionList,
                                   OptimizablePredicateList requalificationRestrictionList,
                                   org.apache.derby.iapi.sql.dictionary.DataDictionary dd)
                            throws org.apache.derby.iapi.error.StandardException
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()
Is this a form of hash join?


doesMaterialization

public boolean doesMaterialization()
Is materialization built in to the join strategy?