Class PredicateList
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.QueryTreeNodeVector<Predicate>
org.apache.derby.impl.sql.compile.PredicateList
- All Implemented Interfaces:
Iterable<Predicate>, OptimizablePredicateList, Visitable
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classInner class which helps statistics routines do their work.private static classAnother inner class which is basically a List of Predicate Wrappers. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intFields inherited from class QueryTreeNodeVector
eltClassFields inherited from class QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOptPredicate(OptimizablePredicate optPredicate) Add the given OptimizablePredicate to the end of this list.voidaddOptPredicate(OptimizablePredicate optPredicate, int position) Another flavor of addOptPredicate that inserts the given predicate at a given position.(package private) voidaddPredicate(Predicate predicate) Add a Predicate to the list.voidadjustForSortElimination(RequiredRowOrdering ordering) Walk through the predicates in this list and make any adjustments that are required to allow for proper handling of an ORDER BY clause.(package private) booleanCheck if all of the predicates in the list are pushable.(package private) booleanCheck if all the predicates reference a givenFromBaseTable.private voidcalculateWeight(PredicateList.PredicateWrapperList[] pwList, int numUsefulPredicates) (package private) voidCategorize the predicates in the list.(package private) voidcheckTopPredicatesForEqualsConditions(int tableNumber, boolean[] eqOuterCols, int[] tableNumbers, JBitSet[] tableColMap, boolean resultColTable) Update the array of columns in = conditions with constants or correlation or join columns.private intchooseLongestMatch(PredicateList.PredicateWrapperList[] predArray, List<Predicate> ret, int numWorkingPredicates) choose the statistic which has the maximum match with the predicates. value is returned in ret.voidclassify(Optimizable optTable, ConglomerateDescriptor cd) Classify the predicates in this list according to the given table and conglomerate.(package private) booleanconstantColumn(ColumnReference colRef) voidNon-destructive copy of all of the predicates from this list to the other list.private void(package private) voiddecrementLevel(FromList fromList, int decrement) Decrement the level of any CRs from the subquery's FROM list that are interesting to transitive closure.(package private) voidEliminate 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.private voidfinishKey(ExpressionClassBuilder acb, MethodBuilder mb, MethodBuilder exprFun, LocalField rowField) Finish generating a start or stop keyprivate LocalFieldgenerateIndexableRow(ExpressionClassBuilder acb, int numberOfColumns) Generate the indexable row for a start key or stop key.(package private) voidIf 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.voidgenerateQualifiers(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable, boolean absolute) Generate the qualifiers for a scan.private voidgenerateSetColumn(ExpressionClassBuilder acb, MethodBuilder exprFun, int columnNumber, Predicate pred, Optimizable optTable, LocalField rowField, boolean isStartKey) Generate the code to set the value from a predicate in an index column.private voidgenerateSingleQualifierCode(MethodBuilder consMB, Optimizable optTable, boolean absolute, ExpressionClassBuilder acb, RelationalOperator or_node, LocalField qualField, int array_idx_1, int array_idx_2) voidgenerateStartKey(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable) Generate the start key for a heap or index scan.voidgenerateStopKey(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable) Generate the stop key for a heap or index scan.getOptPredicate(int index) Return the nth OptimizablePredicate in the list.(package private) PredicateListgetPushablePredicates(JBitSet referencedTableMap) Build a list of pushable predicates, if any, that satisfy the referencedTableMap.inthasEqualityPredicateOnOrderedColumn(Optimizable optTable, int columnNumber, boolean isNullOkay) Check into the predicate list if the passed column has an equijoin predicate on it.booleanhasOptimizableEqualityPredicate(Optimizable optTable, int columnNumber, boolean isNullOkay) Is there an optimizable equality predicate on the specified column?booleanhasOptimizableEquijoin(Optimizable optTable, int columnNumber) Is there an optimizable equijoin on the specified column?private static booleanCheck if a node is representing a constant or a parameter.booleanisRedundantPredicate(int predNum) Return whether or not the specified entry in the list is a redundant predicate.(package private) voidjoinClauseTransitiveClosure(int numTables, FromList fromList, CompilerContext cc) Perform transitive closure on join clauses.voidMark all of the predicates as Qualifiers and set the numberOfQualifiers to reflect this.(package private) voidMark all of the RCs and the RCs in their RC/VCN chain referenced in the predicate list as referenced.private voidprivate voidorderUsefulPredicates(Optimizable optTable, ConglomerateDescriptor cd, boolean pushPreds, boolean nonMatchingIndexScan, boolean coveringIndexScan) (package private) voidpullExpressions(int numTables, ValueNode searchClause) Break apart the search clause into matching a PredicateList where each top level predicate is a separate element in the list.(package private) voidpushExpressionsIntoSelect(SelectNode select, boolean copyPredicate) Push all predicates, which can be pushed, into the underlying select.voidpushUsefulPredicates(Optimizable optTable) Determine which predicates in this list are useful for limiting the scan on the given table using its best conglomerate.voidputOptimizableEqualityPredicateFirst(Optimizable optTable, int columnNumber) Find the optimizable equality predicate on the specified column and make it the first predicate in this list.(package private) voidRemap all ColumnReferences in this tree to be clones of the underlying expression.final voidremoveOptPredicate(int predCtr) Remove the OptimizablePredicate at the specified index (0-based) from the list.final voidAnother version of removeOptPredicate that takes the Predicate to be removed, rather than the position of the Predicate.(package private) voidRemove redundant predicates.(package private) ValueNodeRebuild a constant expression tree from the remaining constant predicates and delete those entries from the PredicateList.(package private) ValueNodeRebuild an expression tree from the remaining predicates and delete those entries from the PredicateList.booleanCan we use the same key for both the start and stop key.(package private) voidsearchClauseTransitiveClosure(int numTables, boolean hashJoinSpecified) Perform transitive closure on search clauses.doubleselectivity(Optimizable optTable) calculate the selectivity for a set of predicates.private doubleselectivityNoStatistics(Optimizable optTable) Compute selectivity the old fashioned way.voidSets 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.intstartOperator(Optimizable optTable) Get the start operator for the given Optimizable for a heap or index scan.intstopOperator(Optimizable optTable) Get the stop operator for the given Optimizable for a heap or index scan.voidtransferAllPredicates(OptimizablePredicateList otherList) Transfer all the predicates from this list to the given list.protected voidtransferNonQualifiers(Optimizable optTable, PredicateList otherPL) Transfer the non-qualifiers from this predicate list to the specified predicate list.voidtransferPredicates(OptimizablePredicateList otherList, JBitSet referencedTableMap, Optimizable table) Transfer the predicates whose referenced set is contained by the specified referencedTableMap from this list to the other list.booleanuseful(Optimizable optTable, ConglomerateDescriptor cd) Return true if this predicate list is useful for limiting the scan on the given table using the given conglomerate.(package private) voidxorReferencedSet(JBitSet fromMap) XOR fromMap with the referenced table map in every remaining Predicate in the list.Methods inherited from class QueryTreeNodeVector
acceptChildren, addElement, destructiveAppend, elementAt, indexOf, insertElementAt, iterator, nondestructiveAppend, printSubNodes, removeAllElements, removeElement, removeElementAt, setElementAt, sizeMethods inherited from class QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, toString, treePrint, treePrint, verifyClassExistMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface OptimizablePredicateList
size
-
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
-
PredicateList
PredicateList(ContextManager cm)
-
-
Method Details
-
getOptPredicate
Description copied from interface:OptimizablePredicateListReturn the nth OptimizablePredicate in the list.- Specified by:
getOptPredicatein interfaceOptimizablePredicateList- Parameters:
index- "index" (0 based) into the list.- Returns:
- OptimizablePredicate The nth OptimizablePredicate in the list.
- See Also:
-
removeOptPredicate
Description copied from interface:OptimizablePredicateListRemove the OptimizablePredicate at the specified index (0-based) from the list.- Specified by:
removeOptPredicatein interfaceOptimizablePredicateList- Parameters:
predCtr- The index.- Throws:
StandardException- Thrown on error- See Also:
-
removeOptPredicate
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
Description copied from interface:OptimizablePredicateListAdd the given OptimizablePredicate to the end of this list.- Specified by:
addOptPredicatein interfaceOptimizablePredicateList- Parameters:
optPredicate- The predicate to add- See Also:
-
addOptPredicate
Another flavor of addOptPredicate that inserts the given predicate at a given position. This is not yet part of any interface. -
useful
Description copied from interface:OptimizablePredicateListReturn true if this predicate list is useful for limiting the scan on the given table using the given conglomerate.- Specified by:
usefulin interfaceOptimizablePredicateList- Parameters:
optTable- An Optimizable for the table in questioncd- 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
Description copied from interface:OptimizablePredicateListDetermine 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:
pushUsefulPredicatesin interfaceOptimizablePredicateList- Parameters:
optTable- An Optimizable for the table in question- Throws:
StandardException- Thrown on error- See Also:
-
classify
Description copied from interface:OptimizablePredicateListClassify 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:
classifyin interfaceOptimizablePredicateList- 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:OptimizablePredicateListMark 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:
markAllPredicatesQualifiersin interfaceOptimizablePredicateList- See Also:
-
hasEqualityPredicateOnOrderedColumn
public int hasEqualityPredicateOnOrderedColumn(Optimizable optTable, int columnNumber, boolean isNullOkay) throws StandardException Description copied from interface:OptimizablePredicateListCheck into the predicate list if the passed column has an equijoin predicate on it.- Specified by:
hasEqualityPredicateOnOrderedColumnin interfaceOptimizablePredicateList- 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:OptimizablePredicateListIs there an optimizable equality predicate on the specified column?- Specified by:
hasOptimizableEqualityPredicatein interfaceOptimizablePredicateList- 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:OptimizablePredicateListIs there an optimizable equijoin on the specified column?- Specified by:
hasOptimizableEquijoinin interfaceOptimizablePredicateList- 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:OptimizablePredicateListFind 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:
putOptimizableEqualityPredicateFirstin interfaceOptimizablePredicateList- 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
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 forotherPL- ParameterList for non-qualifiers- Throws:
StandardException- Thrown on error
-
categorize
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
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
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
Remap all ColumnReferences in this tree to be clones of the underlying expression.- Throws:
StandardException- Thrown on error
-
pullExpressions
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 StatementsearchClause- The search clause to operate on.- Throws:
StandardException- Thrown on error
-
xorReferencedSet
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
Check if a node is representing a constant or a parameter.- Parameters:
node- the node to check- Returns:
trueif the node is a constant or a parameter,falseotherwise
-
pushExpressionsIntoSelect
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
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
Check if all the predicates reference a givenFromBaseTable.- Parameters:
fbt- theFromBaseTableto check for- Returns:
trueif the table is referenced by all predicates,falseotherwise
-
getPushablePredicates
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
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 queryfromList- 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 queryhashJoinSpecified- 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:OptimizablePredicateListTransfer 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:
transferPredicatesin interfaceOptimizablePredicateList- Parameters:
otherList- The predicateList to xfer toreferencedTableMap- The table map to check againsttable- The table to order the new predicates against- Throws:
StandardException- Thrown on error- See Also:
-
transferAllPredicates
Description copied from interface:OptimizablePredicateListTransfer all the predicates from this list to the given list.- Specified by:
transferAllPredicatesin interfaceOptimizablePredicateList- Throws:
StandardException- Thrown on error- See Also:
-
copyPredicatesToOtherList
Description copied from interface:OptimizablePredicateListNon-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:
copyPredicatesToOtherListin interfaceOptimizablePredicateList- Parameters:
otherList- The predicateList to xfer to- Throws:
StandardException- Thrown on error- See Also:
-
isRedundantPredicate
public boolean isRedundantPredicate(int predNum) Description copied from interface:OptimizablePredicateListReturn 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:
isRedundantPredicatein interfaceOptimizablePredicateList- Parameters:
predNum- The entry in the list- Returns:
- Whether or not the specified entry in the list is a redundant predicate.
- See Also:
-
setPredicatesAndProperties
Description copied from interface:OptimizablePredicateListSets 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:
setPredicatesAndPropertiesin interfaceOptimizablePredicateList- Parameters:
otherList- The list to set the same as this one.- Throws:
StandardException- Thrown on error- See Also:
-
startOperator
Description copied from interface:OptimizablePredicateListGet the start operator for the given Optimizable for a heap or index scan.- Specified by:
startOperatorin interfaceOptimizablePredicateList- See Also:
-
generateStopKey
public void generateStopKey(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable) throws StandardException Description copied from interface:OptimizablePredicateListGenerate the stop key for a heap or index scan.- Specified by:
generateStopKeyin interfaceOptimizablePredicateList- Parameters:
acbi- The ExpressionClassBuilderInterface for the class we're buildingmb- the method the generated code is to go intooptTable- The Optimizable table the stop key is for- Throws:
StandardException- Thrown on error- See Also:
-
stopOperator
Description copied from interface:OptimizablePredicateListGet the stop operator for the given Optimizable for a heap or index scan.- Specified by:
stopOperatorin interfaceOptimizablePredicateList- 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
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 buildingmb- 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:OptimizablePredicateListGenerate 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:
generateQualifiersin interfaceOptimizablePredicateList- Parameters:
acbi- The ExpressionClassBuilderInterface for the class we are buildingmb- The method the generated code is going intooptTable- The Optimizable table the Qualifiers are onabsolute- 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:OptimizablePredicateListGenerate the start key for a heap or index scan.- Specified by:
generateStartKeyin interfaceOptimizablePredicateList- Parameters:
acbi- The ExpressionClassBuilderInterface for the class we're buildingmb- The method the generated code is to go intooptTable- The Optimizable table the start key is for- Throws:
StandardException- Thrown on error- See Also:
-
sameStartStopPosition
Description copied from interface:OptimizablePredicateListCan 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:
sameStartStopPositionin interfaceOptimizablePredicateList- 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
Generate the indexable row for a start key or stop key.- Parameters:
acb- The ActivationClassBuilder for the class we're buildingnumberOfColumns- 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 buildingexprFun- The MethodBuilder for the method we're buildingcolumnNumber- 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 columnoptTable- The Optimizable table the column is inrowField- The field that holds the indexable rowisStartKey- 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 buildingexprFun- The MethodBuilder for the method we're buildingrowField- The name of the field that holds the indexable row
-
constantColumn
-
adjustForSortElimination
Description copied from interface:OptimizablePredicateListWalk 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:
adjustForSortEliminationin interfaceOptimizablePredicateList- Throws:
StandardException- See Also:
-
selectivity
Description copied from interface:OptimizablePredicateListcalculate 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:
selectivityin interfaceOptimizablePredicateList- Parameters:
optTable- the Optimizable that the predicate list restricts.- Throws:
StandardException- See Also:
-
calculateWeight
-
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
Compute selectivity the old fashioned way.- Throws:
StandardException
-