Class PredicateList

All Implemented Interfaces:
Iterable<Predicate>, OptimizablePredicateList, Visitable

class PredicateList extends QueryTreeNodeVector<Predicate> implements OptimizablePredicateList
A PredicateList represents the list of top level predicates. Each top level predicate consists of an AndNode whose leftOperand is the top level predicate and whose rightOperand is true. It extends QueryTreeNodeVector.
  • Field Details

    • numberOfStartPredicates

      private int numberOfStartPredicates
    • numberOfStopPredicates

      private int numberOfStopPredicates
    • numberOfQualifiers

      private int numberOfQualifiers
    • QUALIFIER_ORDER_EQUALS

      private static final int QUALIFIER_ORDER_EQUALS
      See Also:
    • QUALIFIER_ORDER_OTHER_RELOP

      private static final int QUALIFIER_ORDER_OTHER_RELOP
      See Also:
    • QUALIFIER_ORDER_NOT_EQUALS

      private static final int QUALIFIER_ORDER_NOT_EQUALS
      See Also:
    • QUALIFIER_ORDER_NON_QUAL

      private static final int QUALIFIER_ORDER_NON_QUAL
      See Also:
    • QUALIFIER_ORDER_OR_CLAUSE

      private static final int QUALIFIER_ORDER_OR_CLAUSE
      See Also:
    • QUALIFIER_NUM_CATEGORIES

      private static final int QUALIFIER_NUM_CATEGORIES
      See Also:
  • Constructor Details

  • Method Details

    • getOptPredicate

      public OptimizablePredicate getOptPredicate(int index)
      Description copied from interface: OptimizablePredicateList
      Return the nth OptimizablePredicate in the list.
      Specified by:
      getOptPredicate in interface OptimizablePredicateList
      Parameters:
      index - "index" (0 based) into the list.
      Returns:
      OptimizablePredicate The nth OptimizablePredicate in the list.
      See Also:
    • removeOptPredicate

      public final void removeOptPredicate(int predCtr) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Remove the OptimizablePredicate at the specified index (0-based) from the list.
      Specified by:
      removeOptPredicate in interface OptimizablePredicateList
      Parameters:
      predCtr - The index.
      Throws:
      StandardException - Thrown on error
      See Also:
    • removeOptPredicate

      public final void removeOptPredicate(OptimizablePredicate pred)
      Another version of removeOptPredicate that takes the Predicate to be removed, rather than the position of the Predicate. This is not part any interface (yet).
    • addOptPredicate

      public void addOptPredicate(OptimizablePredicate optPredicate)
      Description copied from interface: OptimizablePredicateList
      Add the given OptimizablePredicate to the end of this list.
      Specified by:
      addOptPredicate in interface OptimizablePredicateList
      Parameters:
      optPredicate - The predicate to add
      See Also:
    • addOptPredicate

      public void addOptPredicate(OptimizablePredicate optPredicate, int position)
      Another flavor of addOptPredicate that inserts the given predicate at a given position. This is not yet part of any interface.
    • useful

      public boolean useful(Optimizable optTable, ConglomerateDescriptor cd) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Return true if this predicate list is useful for limiting the scan on the given table using the given conglomerate.
      Specified by:
      useful in interface OptimizablePredicateList
      Parameters:
      optTable - An Optimizable for the table in question
      cd - A ConglomerateDescriptor for the conglomerate in question
      Returns:
      true if this predicate list can limit the scan
      Throws:
      StandardException - Thrown on error
      See Also:
    • pushUsefulPredicates

      public void pushUsefulPredicates(Optimizable optTable) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Determine which predicates in this list are useful for limiting the scan on the given table using its best conglomerate. Remove those predicates from this list and push them down to the given Optimizable table. The predicates are pushed down in the order of the index columns that they qualify. Also, the predicates are "marked" as start predicates, stop predicates, or qualifier predicates. Finally, the start and stop operators are set in the given Optimizable.
      Specified by:
      pushUsefulPredicates in interface OptimizablePredicateList
      Parameters:
      optTable - An Optimizable for the table in question
      Throws:
      StandardException - Thrown on error
      See Also:
    • classify

      public void classify(Optimizable optTable, ConglomerateDescriptor cd) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Classify the predicates in this list according to the given table and conglomerate. Each predicate can be a start key, stop key, and/or qualifier, or it can be none of the above. This method also orders the predicates to match the order of the columns in a keyed conglomerate. No ordering is done for heaps.
      Specified by:
      classify in interface OptimizablePredicateList
      Parameters:
      optTable - The Optimizable table for which to classify the predicates in this list.
      cd - The ConglomerateDescriptor for which to classify the predicates in this list.
      Throws:
      StandardException - Thrown on error
      See Also:
    • markAllPredicatesQualifiers

      public void markAllPredicatesQualifiers()
      Description copied from interface: OptimizablePredicateList
      Mark all of the predicates as Qualifiers and set the numberOfQualifiers to reflect this. This is useful for hash joins where all of the predicates in the list to be evaluated during the probe into the hash table on a next are qualifiers.
      Specified by:
      markAllPredicatesQualifiers in interface OptimizablePredicateList
      See Also:
    • hasEqualityPredicateOnOrderedColumn

      public int hasEqualityPredicateOnOrderedColumn(Optimizable optTable, int columnNumber, boolean isNullOkay) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Check into the predicate list if the passed column has an equijoin predicate on it.
      Specified by:
      hasEqualityPredicateOnOrderedColumn in interface OptimizablePredicateList
      Parameters:
      optTable -
      columnNumber -
      isNullOkay -
      Returns:
      the position of the predicate in the list which corresponds to the equijoin. If no quijoin predicate found, then the return value will be -1
      Throws:
      StandardException - Thrown on error
      See Also:
    • hasOptimizableEqualityPredicate

      public boolean hasOptimizableEqualityPredicate(Optimizable optTable, int columnNumber, boolean isNullOkay) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Is there an optimizable equality predicate on the specified column?
      Specified by:
      hasOptimizableEqualityPredicate in interface OptimizablePredicateList
      Parameters:
      optTable - The optimizable the column comes from.
      columnNumber - The column number within the base table.
      isNullOkay - boolean, whether or not the IS NULL operator satisfies the search
      Returns:
      Whether or not there is an optimizable equality predicate on the specified column.
      Throws:
      StandardException - Thrown on error
      See Also:
    • hasOptimizableEquijoin

      public boolean hasOptimizableEquijoin(Optimizable optTable, int columnNumber) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Is there an optimizable equijoin on the specified column?
      Specified by:
      hasOptimizableEquijoin in interface OptimizablePredicateList
      Parameters:
      optTable - The optimizable the column comes from.
      columnNumber - The column number within the base table.
      Returns:
      Whether or not there is an optimizable equijoin on the specified column.
      Throws:
      StandardException - Thrown on error
      See Also:
    • putOptimizableEqualityPredicateFirst

      public void putOptimizableEqualityPredicateFirst(Optimizable optTable, int columnNumber) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Find the optimizable equality predicate on the specified column and make it the first predicate in this list. This is useful for hash joins where Qualifier[0] is assumed to be on the hash key.
      Specified by:
      putOptimizableEqualityPredicateFirst in interface OptimizablePredicateList
      Parameters:
      optTable - The optimizable the column comes from.
      columnNumber - The column number within the base table.
      Throws:
      StandardException - Thrown on error
      See Also:
    • orderUsefulPredicates

      private void orderUsefulPredicates(Optimizable optTable, ConglomerateDescriptor cd, boolean pushPreds, boolean nonMatchingIndexScan, boolean coveringIndexScan) throws StandardException
      Throws:
      StandardException
    • addPredicate

      void addPredicate(Predicate predicate) throws StandardException
      Add a Predicate to the list.
      Parameters:
      predicate - A Predicate to add to the list
      Throws:
      StandardException - Thrown on error
    • transferNonQualifiers

      protected void transferNonQualifiers(Optimizable optTable, PredicateList otherPL) throws StandardException
      Transfer the non-qualifiers from this predicate list to the specified predicate list. This is useful for arbitrary hash join, where we need to separate the 2 as the qualifiers get applied when probing the hash table and the non-qualifiers get * applied afterwards.
      Parameters:
      optTable - The optimizable that we want qualifiers for
      otherPL - ParameterList for non-qualifiers
      Throws:
      StandardException - Thrown on error
    • categorize

      void categorize() throws StandardException
      Categorize the predicates in the list. Initially, this means building a bit map of the referenced tables for each predicate.
      Throws:
      StandardException - Thrown on error
    • eliminateBooleanTrueAndBooleanTrue

      void eliminateBooleanTrueAndBooleanTrue()
      Eliminate predicates of the form: AndNode / \ true BooleanConstantNode true BooleanConstantNode This is useful when checking for a NOP PRN as the Like transformation on c1 like 'ASDF%' can leave one of these predicates in the list.
    • restoreConstantPredicates

      ValueNode restoreConstantPredicates() throws StandardException
      Rebuild a constant expression tree from the remaining constant predicates and delete those entries from the PredicateList. The rightOperand of every top level AndNode is always a true BooleanConstantNode, so we can blindly overwrite that pointer. Optimizations: We take this opportunity to eliminate: AndNode / \ true BooleanConstantNode true BooleanConstantNode We remove the AndNode if the predicate list is a single AndNode: AndNode / \ LeftOperand RightOperand becomes: LeftOperand If the leftOperand of any AndNode is False, then the entire expression will be False. The expression simple becomes: false BooleanConstantNode
      Returns:
      ValueNode The rebuilt expression tree.
      Throws:
      StandardException
    • restorePredicates

      ValueNode restorePredicates() throws StandardException
      Rebuild an expression tree from the remaining predicates and delete those entries from the PredicateList. The rightOperand of every top level AndNode is always a true BooleanConstantNode, so we can blindly overwrite that pointer. Optimizations: We take this opportunity to eliminate: AndNode / \ true BooleanConstantNode true BooleanConstantNode We remove the AndNode if the predicate list is a single AndNode: AndNode / \ LeftOperand RightOperand becomes: LeftOperand If the leftOperand of any AndNode is False, then the entire expression will be False. The expression simple becomes: false BooleanConstantNode
      Returns:
      ValueNode The rebuilt expression tree.
      Throws:
      StandardException
    • remapColumnReferencesToExpressions

      void remapColumnReferencesToExpressions() throws StandardException
      Remap all ColumnReferences in this tree to be clones of the underlying expression.
      Throws:
      StandardException - Thrown on error
    • pullExpressions

      void pullExpressions(int numTables, ValueNode searchClause) throws StandardException
      Break apart the search clause into matching a PredicateList where each top level predicate is a separate element in the list. Build a bit map to represent the FromTables referenced within each top level predicate. NOTE: We want the rightOperand of every AndNode to be true, in order to simplify the algorithm for putting the predicates back into the tree. (As we put an AndNode back into the tree, we can ignore it's rightOperand.)
      Parameters:
      numTables - Number of tables in the DML Statement
      searchClause - The search clause to operate on.
      Throws:
      StandardException - Thrown on error
    • xorReferencedSet

      void xorReferencedSet(JBitSet fromMap)
      XOR fromMap with the referenced table map in every remaining Predicate in the list. This is useful when pushing down multi-table predicates.
      Parameters:
      fromMap - The JBitSet to XOR with.
    • countScanFlags

      private void countScanFlags()
    • isConstantOrParameterNode

      private static boolean isConstantOrParameterNode(ValueNode node)
      Check if a node is representing a constant or a parameter.
      Parameters:
      node - the node to check
      Returns:
      true if the node is a constant or a parameter, false otherwise
    • pushExpressionsIntoSelect

      void pushExpressionsIntoSelect(SelectNode select, boolean copyPredicate) throws StandardException
      Push all predicates, which can be pushed, into the underlying select. A predicate can be pushed into an underlying select if the source of every ColumnReference in the predicate is itself a ColumnReference. This is useful when attempting to push predicates into non-flattenable views or derived tables or into unions.
      Parameters:
      select - The underlying SelectNode.
      copyPredicate - Whether to make a copy of the predicate before pushing
      Throws:
      StandardException - Thrown on error
    • markReferencedColumns

      void markReferencedColumns() throws StandardException
      Mark all of the RCs and the RCs in their RC/VCN chain referenced in the predicate list as referenced.
      Throws:
      StandardException - Thrown on error
    • checkTopPredicatesForEqualsConditions

      void checkTopPredicatesForEqualsConditions(int tableNumber, boolean[] eqOuterCols, int[] tableNumbers, JBitSet[] tableColMap, boolean resultColTable) throws StandardException
      Update the array of columns in = conditions with constants or correlation or join columns. This is useful when doing subquery flattening on the basis of an equality condition.
      Parameters:
      tableNumber - The tableNumber of the table from which the columns of interest come from.
      eqOuterCols - Array of booleans for noting which columns are in = predicates with constants or correlation columns.
      tableNumbers - Array of table numbers in this query block.
      resultColTable - tableNumber is the table the result columns are coming from
      Throws:
      StandardException - Thrown on error
    • allPushable

      boolean allPushable()
      Check if all of the predicates in the list are pushable.
      Returns:
      Whether or not all of the predicates in the list are pushable.
    • allReference

      boolean allReference(FromBaseTable fbt)
      Check if all the predicates reference a given FromBaseTable.
      Parameters:
      fbt - the FromBaseTable to check for
      Returns:
      true if the table is referenced by all predicates, false otherwise
    • getPushablePredicates

      PredicateList getPushablePredicates(JBitSet referencedTableMap) throws StandardException
      Build a list of pushable predicates, if any, that satisfy the referencedTableMap.
      Parameters:
      referencedTableMap - The referenced table map
      Returns:
      A list of pushable predicates, if any, that satisfy the referencedTableMap.
      Throws:
      StandardException - Thrown on error
    • decrementLevel

      void decrementLevel(FromList fromList, int decrement)
      Decrement the level of any CRs from the subquery's FROM list that are interesting to transitive closure.
      Parameters:
      fromList - The subquery's FROM list.
      decrement - Decrement size.
    • joinClauseTransitiveClosure

      void joinClauseTransitiveClosure(int numTables, FromList fromList, CompilerContext cc) throws StandardException
      Perform transitive closure on join clauses. For each table in the query, we build a list of equijoin clauses of the form: ColumnReference relop ColumnReference Each join clause is put on 2 lists since it joins 2 tables. We then walk the array of lists. We first walk it as the outer list. For each equijoin predicate, we assign an equivalence class if it does not yet have one. We then walk the predicate list (as middle) for the other table, searching for other equijoins with the middle table number and column number. All such predicates are assigned the same equivalence class. We then walk the predicate list (as inner) for the other side of the middle predicate to see if we can find an equijoin between outer and inner. If so, then we simply assign it to the same equivalence class. If not, then we add the new equijoin clause. Note that an equijoin predicate between two tables CANNOT be used for transitive closure, if either of the tables is in the fromlist for NOT EXISTS. In that case, the join predicate actually specifies that the rows from the indicated table must NOT exist, and therefore those non-existent rows cannot be transitively joined to the other matching tables. See DERBY-3033 for a description of a situation in which this actually arises.
      Parameters:
      numTables - The number of tables in the query
      fromList - The FromList in question.
      cc - The CompilerContext to use
      Throws:
      StandardException - Thrown on error
    • searchClauseTransitiveClosure

      void searchClauseTransitiveClosure(int numTables, boolean hashJoinSpecified) throws StandardException
      Perform transitive closure on search clauses. We build a list of search clauses of the form: [] We also build a list of equijoin conditions of form: = where both columns are from different tables in the same query block. For each search clause in the list, we search the equijoin list to see if there is an equijoin clause on the same column. If so, then we search the search clause list for a search condition on the column being joined against with the same relation operator and constant. If a match is found, then there is no need to add a new predicate. Otherwise, we add a new search condition on the column being joined with. In either case, if the relational operator in the search clause is an "=" then we mark the equijoin clause as being redundant. Redundant equijoin clauses will be removed at the end of the search as they are * unnecessary.
      Parameters:
      numTables - The number of tables in the query
      hashJoinSpecified - Whether or not user specified a hash join
      Throws:
      StandardException - Thrown on error
    • removeRedundantPredicates

      void removeRedundantPredicates()
      Remove redundant predicates. A redundant predicate has an equivalence class (!= -1) and there are other predicates in the same equivalence class after it in the list. (Actually, we remove all of the predicates in the same equivalence class that appear after this one.)
    • transferPredicates

      public void transferPredicates(OptimizablePredicateList otherList, JBitSet referencedTableMap, Optimizable table) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Transfer the predicates whose referenced set is contained by the specified referencedTableMap from this list to the other list. This is useful when splitting out a set of predicates from a larger set, like when generating a HashScanResultSet.
      Specified by:
      transferPredicates in interface OptimizablePredicateList
      Parameters:
      otherList - The predicateList to xfer to
      referencedTableMap - The table map to check against
      table - The table to order the new predicates against
      Throws:
      StandardException - Thrown on error
      See Also:
    • transferAllPredicates

      public void transferAllPredicates(OptimizablePredicateList otherList) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Transfer all the predicates from this list to the given list.
      Specified by:
      transferAllPredicates in interface OptimizablePredicateList
      Throws:
      StandardException - Thrown on error
      See Also:
    • copyPredicatesToOtherList

      public void copyPredicatesToOtherList(OptimizablePredicateList otherList) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Non-destructive copy of all of the predicates from this list to the other list. This is useful when splitting out a set of predicates from a larger set, like when generating a HashScanResultSet.
      Specified by:
      copyPredicatesToOtherList in interface OptimizablePredicateList
      Parameters:
      otherList - The predicateList to xfer to
      Throws:
      StandardException - Thrown on error
      See Also:
    • isRedundantPredicate

      public boolean isRedundantPredicate(int predNum)
      Description copied from interface: OptimizablePredicateList
      Return whether or not the specified entry in the list is a redundant predicate. This is useful for selectivity calculations because we do not want redundant predicates included in the selectivity calculation.
      Specified by:
      isRedundantPredicate in interface OptimizablePredicateList
      Parameters:
      predNum - The entry in the list
      Returns:
      Whether or not the specified entry in the list is a redundant predicate.
      See Also:
    • setPredicatesAndProperties

      public void setPredicatesAndProperties(OptimizablePredicateList otherList) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Sets the given list to have the same elements as this one, and the same properties as this one (number of qualifiers and start and stop predicates.
      Specified by:
      setPredicatesAndProperties in interface OptimizablePredicateList
      Parameters:
      otherList - The list to set the same as this one.
      Throws:
      StandardException - Thrown on error
      See Also:
    • startOperator

      public int startOperator(Optimizable optTable)
      Description copied from interface: OptimizablePredicateList
      Get the start operator for the given Optimizable for a heap or index scan.
      Specified by:
      startOperator in interface OptimizablePredicateList
      See Also:
    • generateStopKey

      public void generateStopKey(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Generate the stop key for a heap or index scan.
      Specified by:
      generateStopKey in interface OptimizablePredicateList
      Parameters:
      acbi - The ExpressionClassBuilderInterface for the class we're building
      mb - the method the generated code is to go into
      optTable - The Optimizable table the stop key is for
      Throws:
      StandardException - Thrown on error
      See Also:
    • stopOperator

      public int stopOperator(Optimizable optTable)
      Description copied from interface: OptimizablePredicateList
      Get the stop operator for the given Optimizable for a heap or index scan.
      Specified by:
      stopOperator in interface OptimizablePredicateList
      See Also:
    • generateSingleQualifierCode

      private void generateSingleQualifierCode(MethodBuilder consMB, Optimizable optTable, boolean absolute, ExpressionClassBuilder acb, RelationalOperator or_node, LocalField qualField, int array_idx_1, int array_idx_2) throws StandardException
      Throws:
      StandardException
    • generateInListValues

      void generateInListValues(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
      If there is an IN-list probe predicate in this list then generate the corresponding IN-list values as a DataValueDescriptor array, to be used for probing at execution time. Also generate a boolean value indicating whether or not the values are already in sorted order. Assumption is that by the time we get here there is at most one IN-list probe predicate in this list.
      Parameters:
      acb - The ActivationClassBuilder for the class we're building
      mb - The MethodBuilder for the method we're building
      Throws:
      StandardException
    • generateQualifiers

      public void generateQualifiers(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable, boolean absolute) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Generate the qualifiers for a scan. This method generates an array of Qualifiers, and fills them in with calls to the factory method for generating Qualifiers in the constructor for the activation. It stores the array of Qualifiers in a field in the activation, and returns a reference to that field. If there are no qualifiers, it initializes the array of Qualifiers to null.
      Specified by:
      generateQualifiers in interface OptimizablePredicateList
      Parameters:
      acbi - The ExpressionClassBuilderInterface for the class we are building
      mb - The method the generated code is going into
      optTable - The Optimizable table the Qualifiers are on
      absolute - Generate absolute column positions if true, else relative column positions (within the underlying row)
      Throws:
      StandardException - Thrown on error
      See Also:
    • orderQualifiers

      private void orderQualifiers()
    • generateStartKey

      public void generateStartKey(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Generate the start key for a heap or index scan.
      Specified by:
      generateStartKey in interface OptimizablePredicateList
      Parameters:
      acbi - The ExpressionClassBuilderInterface for the class we're building
      mb - The method the generated code is to go into
      optTable - The Optimizable table the start key is for
      Throws:
      StandardException - Thrown on error
      See Also:
    • sameStartStopPosition

      public boolean sameStartStopPosition() throws StandardException
      Description copied from interface: OptimizablePredicateList
      Can we use the same key for both the start and stop key. This is possible when doing an exact match on an index where there are no other sargable predicates.
      Specified by:
      sameStartStopPosition in interface OptimizablePredicateList
      Returns:
      Whether or not we can use the same key for both the start and stop key.
      Throws:
      StandardException - Thrown on error
      See Also:
    • generateIndexableRow

      private LocalField generateIndexableRow(ExpressionClassBuilder acb, int numberOfColumns)
      Generate the indexable row for a start key or stop key.
      Parameters:
      acb - The ActivationClassBuilder for the class we're building
      numberOfColumns - The number of columns in the key
      Returns:
      The field that holds the indexable row
    • generateSetColumn

      private void generateSetColumn(ExpressionClassBuilder acb, MethodBuilder exprFun, int columnNumber, Predicate pred, Optimizable optTable, LocalField rowField, boolean isStartKey) throws StandardException
      Generate the code to set the value from a predicate in an index column.
      Parameters:
      acb - The ActivationClassBuilder for the class we're building
      exprFun - The MethodBuilder for the method we're building
      columnNumber - The position number of the column we're setting the value in (zero-based)
      pred - The Predicate with the value to put in the index column
      optTable - The Optimizable table the column is in
      rowField - The field that holds the indexable row
      isStartKey - Are we generating start or stop key? This information is useful for "in"'s dynamic start/stop key, bug 3858
      Throws:
      StandardException - Thrown on error
    • finishKey

      private void finishKey(ExpressionClassBuilder acb, MethodBuilder mb, MethodBuilder exprFun, LocalField rowField)
      Finish generating a start or stop key
      Parameters:
      acb - The ActivationClassBuilder for the class we're building
      exprFun - The MethodBuilder for the method we're building
      rowField - The name of the field that holds the indexable row
    • constantColumn

      boolean constantColumn(ColumnReference colRef)
    • adjustForSortElimination

      public void adjustForSortElimination(RequiredRowOrdering ordering) throws StandardException
      Description copied from interface: OptimizablePredicateList
      Walk through the predicates in this list and make any adjustments that are required to allow for proper handling of an ORDER BY clause.
      Specified by:
      adjustForSortElimination in interface OptimizablePredicateList
      Throws:
      StandardException
      See Also:
    • selectivity

      public double selectivity(Optimizable optTable) throws StandardException
      Description copied from interface: OptimizablePredicateList
      calculate the selectivity for a set of predicates. If statistics exist for the predicates this method uses the statistics. If statistics do not exist, then simply call selectivity for each of the predicates and return the result.
      Specified by:
      selectivity in interface OptimizablePredicateList
      Parameters:
      optTable - the Optimizable that the predicate list restricts.
      Throws:
      StandardException
      See Also:
    • calculateWeight

      private void calculateWeight(PredicateList.PredicateWrapperList[] pwList, int numUsefulPredicates)
    • chooseLongestMatch

      private int chooseLongestMatch(PredicateList.PredicateWrapperList[] predArray, List<Predicate> ret, int numWorkingPredicates)
      choose the statistic which has the maximum match with the predicates. value is returned in ret.
    • selectivityNoStatistics

      private double selectivityNoStatistics(Optimizable optTable) throws StandardException
      Compute selectivity the old fashioned way.
      Throws:
      StandardException