Class NestedLoopJoinStrategy

java.lang.Object
org.apache.derby.impl.sql.compile.BaseJoinStrategy
org.apache.derby.impl.sql.compile.NestedLoopJoinStrategy
All Implemented Interfaces:
JoinStrategy

class NestedLoopJoinStrategy extends BaseJoinStrategy
  • Constructor Details

    • NestedLoopJoinStrategy

      NestedLoopJoinStrategy()
  • Method Details

    • feasible

      public boolean feasible(Optimizable innerTable, OptimizablePredicateList predList, Optimizer optimizer) throws StandardException
      Description copied from interface: JoinStrategy
      Is this join strategy feasible under the circumstances?
      Parameters:
      innerTable - The inner table of the join
      predList - The predicateList for the join
      optimizer - The optimizer to use
      Returns:
      true means the strategy is feasible, false means it isn't
      Throws:
      StandardException - Thrown on error
      See Also:
    • multiplyBaseCostByOuterRows

      public boolean multiplyBaseCostByOuterRows()
      Description copied from interface: JoinStrategy
      Returns true if the base cost of scanning the conglomerate should be multiplied by the number of outer rows.
      See Also:
    • getBasePredicates

      public OptimizablePredicateList getBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates, Optimizable innerTable) throws StandardException
      Description copied from interface: 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.
      Parameters:
      predList - The predicate list to pull from.
      basePredicates - The list to put the base predicates in.
      innerTable - The inner table of the join
      Returns:
      The base predicate list. If no predicates are pulled, it may return the source predList without doing anything.
      Throws:
      StandardException - Thrown on error
      See Also:
    • nonBasePredicateSelectivity

      public double nonBasePredicateSelectivity(Optimizable innerTable, OptimizablePredicateList predList)
      Description copied from interface: 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.
      Parameters:
      innerTable - The inner table of the join.
      predList - The original predicate list that was passed to getBasePredicates(), from which some base predicates may have been pulled.
      Returns:
      The extra selectivity due to non-base predicates
      See Also:
    • putBasePredicates

      public void putBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates) throws StandardException
      Description copied from interface: 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.
      Parameters:
      predList - The list of predicates to put the base predicates back in.
      basePredicates - The base predicates to put back in the list.
      Throws:
      StandardException - Thrown on error
      See Also:
    • estimateCost

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

      public int maxCapacity(int userSpecifiedCapacity, int maxMemoryPerTable, double perRowUsage)
      Parameters:
      userSpecifiedCapacity -
      maxMemoryPerTable - maximum number of bytes per table
      perRowUsage - number of bytes per row
      Returns:
      The maximum number of rows that can be handled by this join strategy
      See Also:
    • getName

      public String getName()
      Description copied from interface: JoinStrategy
      Get the name of this join strategy
      See Also:
    • scanCostType

      public int scanCostType()
      Description copied from interface: JoinStrategy
      Get the costing type, for use with StoreCostController.getScanCost
      See Also:
    • getOperatorSymbol

      public String getOperatorSymbol()
      Description copied from interface: JoinStrategy
      Get the operator symbol used to represent this join strategy in optimizer traces
      See Also:
    • resultSetMethodName

      public String resultSetMethodName(boolean bulkFetch, boolean multiprobe, boolean validatingCheckConstraint)
      Description copied from interface: JoinStrategy
      Get the name of the result set method for base table scans
      Parameters:
      bulkFetch - True means bulk fetch is being done on the inner table
      multiprobe - True means we are probing the inner table for rows matching a specified list of values.
      validatingCheckConstraint - True of this is a special scan to validate a check constraint.
      See Also:
    • joinResultSetMethodName

      public String joinResultSetMethodName()
      Description copied from interface: JoinStrategy
      Get the name of the join result set method for the join
      See Also:
    • halfOuterJoinResultSetMethodName

      public String halfOuterJoinResultSetMethodName()
      Description copied from interface: JoinStrategy
      Get the name of the join result set method for the half outerjoin
      See Also:
    • getScanArgs

      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
      Description copied from interface: JoinStrategy
      Get the appropriate arguments to the scan for this type of join.
      Parameters:
      tc - The TransactionController
      mb - The method to generate the arguments in
      innerTable - The inner table of the join
      storeRestrictionList - The predicate list to be evaluated in the store
      nonStoreRestrictionList - The predicate list to be evaluated outside of the store
      acbi - The expression class builder for the activation class we're building
      bulkFetch - The amount of bulk fetch to do
      resultRowTemplate - The saved object index of a result row template
      colRefItem - The item number of the column reference bit map
      lockMode - The lock mode to use when scanning the table (see TransactionController).
      tableLocked - Whether or not the table is marked (in sys.systables) as always using table locking
      isolationLevel - Isolation level specified (or not) for scans
      maxMemoryPerTable - Max memory per table
      genInListVals - Whether or not we are going to generate IN-list values with which to probe the inner table.
      Returns:
      Count of the expressions pushed to use as the parameters to the result set for the inner table
      Throws:
      StandardException - Thrown on error
      See Also:
    • divideUpPredicateLists

      public void divideUpPredicateLists(Optimizable innerTable, OptimizablePredicateList originalRestrictionList, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, OptimizablePredicateList requalificationRestrictionList, DataDictionary dd) throws StandardException
      Description copied from interface: 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.
      Parameters:
      innerTable - The inner table of the join
      originalRestrictionList - Initially contains all predicates. This method removes predicates from this list and moves them to other lists, as appropriate.
      storeRestrictionList - To be filled in with predicates to be pushed down to store.
      nonStoreRestrictionList - To be filled in with predicates that are not pushed down to the store.
      requalificationRestrictionList - Copy of predicates used to re-qualify rows, if necessary.
      dd - The DataDictionary
      Throws:
      StandardException - Thrown on error
      See Also:
    • doesMaterialization

      public boolean doesMaterialization()
      Description copied from interface: JoinStrategy
      Is materialization built in to the join strategy?
      Returns:
      Whether or not materialization is built in to the join strategy
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • validForOutermostTable

      protected boolean validForOutermostTable()
      Can this join strategy be used on the outermost table of a join.
      Overrides:
      validForOutermostTable in class BaseJoinStrategy
      Returns:
      Whether or not this join strategy can be used on the outermost table of a join.