| java.lang.Object org.apache.derby.impl.sql.compile.QueryTreeNode org.apache.derby.impl.sql.compile.QueryTreeNodeVector org.apache.derby.impl.sql.compile.PredicateList
PredicateList | public class PredicateList extends QueryTreeNodeVector implements OptimizablePredicateList(Code) | | 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.
author: Jerry Brenner |
Method Summary | |
public void | addOptPredicate(OptimizablePredicate optPredicate) | public void | addOptPredicate(OptimizablePredicate optPredicate, int position) Another flavor of addOptPredicate that inserts the given predicate
at a given position. | public void | addPredicate(Predicate predicate) Add a Predicate to the list. | boolean | allPushable() Check if all of the predicates in the list are pushable. | public void | categorize() Categorize the predicates in the list. | void | checkTopPredicatesForEqualsConditions(int tableNumber, boolean[] eqOuterCols, int[] tableNumbers, JBitSet[] tableColMap, boolean resultColTable) Update the array of columns in = conditions with constants
or correlation or join columns. | public void | classify(Optimizable optTable, ConglomerateDescriptor cd) | boolean | constantColumn(ColumnReference colRef) | public void | copyPredicatesToOtherList(OptimizablePredicateList otherList) | void | decrementLevel(FromList fromList, int decrement) Decrement the level of any CRs from the subquery's
FROM list that are interesting to transitive closure. | public 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. | public void | generateQualifiers(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable, boolean absolute) | public void | generateStartKey(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable) | public void | generateStopKey(ExpressionClassBuilderInterface acbi, MethodBuilder mb, Optimizable optTable) | public OptimizablePredicate | getOptPredicate(int index) | PredicateList | getPushablePredicates(JBitSet referencedTableMap) Build a list of pushable predicates, if any,
that satisfy the referencedTableMap. | public boolean | hasOptimizableEqualityPredicate(Optimizable optTable, int columnNumber, boolean isNullOkay) | public boolean | hasOptimizableEquijoin(Optimizable optTable, int columnNumber) | public boolean | isRedundantPredicate(int predNum) | void | joinClauseTransitiveClosure(int numTables, FromList fromList, CompilerContext cc) Perform transitive closure on join clauses. | public void | markAllPredicatesQualifiers() | void | markReferencedColumns() Mark all of the RCs and the RCs in their RC/VCN chain
referenced in the predicate list as referenced. | public void | printSubNodes(int depth) Prints the sub-nodes of this object. | void | pullExpressions(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. | void | pushExpressionsIntoSelect(SelectNode select, boolean copyPredicate) Push all predicates, which can be pushed, into the underlying select. | public void | pushUsefulPredicates(Optimizable optTable) | public void | putOptimizableEqualityPredicateFirst(Optimizable optTable, int columnNumber) | public void | remapColumnReferencesToExpressions() Remap all ColumnReferences in this tree to be clones of the
underlying expression. | final public void | removeOptPredicate(int predCtr) | final public void | removeOptPredicate(OptimizablePredicate pred) Another version of removeOptPredicate that takes the Predicate to be
removed, rather than the position of the Predicate. | void | removeRedundantPredicates() Remove redundant predicates. | public ValueNode | 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. | public ValueNode | 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. | public boolean | sameStartStopPosition() | void | searchClauseTransitiveClosure(int numTables, boolean hashJoinSpecified) Perform transitive closure on search clauses. | public double | selectivity(Optimizable optTable) | public void | setPredicatesAndProperties(OptimizablePredicateList otherList) | public int | startOperator(Optimizable optTable) | public int | stopOperator(Optimizable optTable) | public void | transferAllPredicates(OptimizablePredicateList otherList) | protected void | transferNonQualifiers(Optimizable optTable, PredicateList otherPL) Transfer the non-qualifiers from this predicate list to the specified
predicate list. | public void | transferPredicates(OptimizablePredicateList otherList, JBitSet referencedTableMap, Optimizable table) | public boolean | useful(Optimizable optTable, ConglomerateDescriptor cd) | public void | xorReferencedSet(JBitSet fromMap) XOR fromMap with the referenced table map in every remaining
Predicate in the list. |
PredicateList | public PredicateList()(Code) | | |
addOptPredicate | public void addOptPredicate(OptimizablePredicate optPredicate, int position)(Code) | | Another flavor of addOptPredicate that inserts the given predicate
at a given position. This is not yet part of any interface.
|
allPushable | boolean allPushable()(Code) | | Check if all of the predicates in the list are pushable.
Whether or not all of the predicates in the list are pushable. |
categorize | public void categorize() throws StandardException(Code) | | Categorize the predicates in the list. Initially, this means
building a bit map of the referenced tables for each predicate.
exception: StandardException - Thrown on error |
checkTopPredicatesForEqualsConditions | void checkTopPredicatesForEqualsConditions(int tableNumber, boolean[] eqOuterCols, int[] tableNumbers, JBitSet[] tableColMap, boolean resultColTable) throws StandardException(Code) | | 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 whichthe columns of interest come from. Parameters: eqOuterCols - Array of booleans for noting which columnsare in = predicates with constants orcorrelation columns. Parameters: tableNumbers - Array of table numbers in this query block. Parameters: resultColTable - tableNumber is the table the result columns arecoming from exception: StandardException - Thrown on error |
decrementLevel | void decrementLevel(FromList fromList, int decrement)(Code) | | 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. Parameters: decrement - Decrement size. |
eliminateBooleanTrueAndBooleanTrue | public void eliminateBooleanTrueAndBooleanTrue()(Code) | | 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.
|
getPushablePredicates | PredicateList getPushablePredicates(JBitSet referencedTableMap) throws StandardException(Code) | | Build a list of pushable predicates, if any,
that satisfy the referencedTableMap.
Parameters: referencedTableMap - The referenced table map A list of pushable predicates, if any,that satisfy the referencedTableMap. exception: StandardException - Thrown on error |
joinClauseTransitiveClosure | void joinClauseTransitiveClosure(int numTables, FromList fromList, CompilerContext cc) throws StandardException(Code) | | Perform transitive closure on join clauses. For each table in the query,
we build a list of equijoin clauses of the form:
<=>
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.
Parameters: numTables - The number of tables in the query Parameters: fromList - The FromList in question. Parameters: cc - The CompilerContext to use exception: StandardException - Thrown on error |
markReferencedColumns | void markReferencedColumns() throws StandardException(Code) | | Mark all of the RCs and the RCs in their RC/VCN chain
referenced in the predicate list as referenced.
exception: StandardException - Thrown on error |
printSubNodes | public void printSubNodes(int depth)(Code) | | Prints the sub-nodes of this object. See QueryTreeNode.java for
how tree printing is supposed to work.
Parameters: depth - The depth of this node in the tree |
pullExpressions | void pullExpressions(int numTables, ValueNode searchClause) throws StandardException(Code) | | 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 Parameters: searchClause - The search clause to operate on. exception: StandardException - Thrown on error |
pushExpressionsIntoSelect | void pushExpressionsIntoSelect(SelectNode select, boolean copyPredicate) throws StandardException(Code) | | 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. Parameters: copyPredicate - Whether to make a copy of the predicatebefore pushing exception: StandardException - Thrown on error |
remapColumnReferencesToExpressions | public void remapColumnReferencesToExpressions() throws StandardException(Code) | | Remap all ColumnReferences in this tree to be clones of the
underlying expression.
exception: StandardException - Thrown on error |
removeOptPredicate | final public void removeOptPredicate(OptimizablePredicate pred)(Code) | | 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).
|
removeRedundantPredicates | void removeRedundantPredicates()(Code) | | 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.)
|
restoreConstantPredicates | public ValueNode restoreConstantPredicates() throws StandardException(Code) | | 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
ValueNode The rebuilt expression tree. |
restorePredicates | public ValueNode restorePredicates() throws StandardException(Code) | | 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
ValueNode The rebuilt expression tree. |
searchClauseTransitiveClosure | void searchClauseTransitiveClosure(int numTables, boolean hashJoinSpecified) throws StandardException(Code) | | 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 Parameters: hashJoinSpecified - Whether or not user specified a hash join exception: StandardException - Thrown on error |
transferNonQualifiers | protected void transferNonQualifiers(Optimizable optTable, PredicateList otherPL) throws StandardException(Code) | | 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 Parameters: otherPL - ParameterList for non-qualifiers exception: StandardException - Thrown on error |
xorReferencedSet | public void xorReferencedSet(JBitSet fromMap)(Code) | | 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. |
Methods inherited from org.apache.derby.impl.sql.compile.QueryTreeNode | public Visitable accept(Visitor v) throws StandardException(Code)(Java Doc) public QueryTreeNode bind() throws StandardException(Code)(Java Doc) public DataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor) throws StandardException(Code)(Java Doc) protected static void debugFlush()(Code)(Java Doc) public static void debugPrint(String outputString)(Code)(Java Doc) public void disablePrivilegeCollection()(Code)(Java Doc) public String executeSchemaName()(Code)(Java Doc) public String executeStatementName()(Code)(Java Doc) public static String formatNodeString(String nodeString, int depth)(Code)(Java Doc) public boolean foundString(String[] list, String search)(Code)(Java Doc) public GeneratedClass generate(ByteArray ignored) throws StandardException(Code)(Java Doc) protected void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException(Code)(Java Doc) void generateAuthorizeCheck(ActivationClassBuilder acb, MethodBuilder mb, int sqlOperation)(Code)(Java Doc) public int getBeginOffset()(Code)(Java Doc) final protected ClassFactory getClassFactory()(Code)(Java Doc) final protected CompilerContext getCompilerContext()(Code)(Java Doc) final public ContextManager getContextManager()(Code)(Java Doc) public Object getCursorInfo() throws StandardException(Code)(Java Doc) final public DataDictionary getDataDictionary()(Code)(Java Doc) final public DependencyManager getDependencyManager()(Code)(Java Doc) public int getEndOffset()(Code)(Java Doc) final public ExecutionFactory getExecutionFactory()(Code)(Java Doc) final public GenericConstantActionFactory getGenericConstantActionFactory()(Code)(Java Doc) protected int getIntProperty(String value, String key) throws StandardException(Code)(Java Doc) final protected LanguageConnectionContext getLanguageConnectionContext()(Code)(Java Doc) final public NodeFactory getNodeFactory()(Code)(Java Doc) protected int getNodeType()(Code)(Java Doc) public ConstantNode getNullNode(TypeId typeId, ContextManager cm) throws StandardException(Code)(Java Doc) public DataTypeDescriptor[] getParameterTypes() throws StandardException(Code)(Java Doc) public long getRowEstimate()(Code)(Java Doc) public String getSPSName()(Code)(Java Doc) final SchemaDescriptor getSchemaDescriptor(String schemaName) throws StandardException(Code)(Java Doc) final SchemaDescriptor getSchemaDescriptor(String schemaName, boolean raiseError) throws StandardException(Code)(Java Doc) protected int getStatementType()(Code)(Java Doc) final protected TableDescriptor getTableDescriptor(String tableName, SchemaDescriptor schema) throws StandardException(Code)(Java Doc) final protected TypeCompiler getTypeCompiler(TypeId typeId)(Code)(Java Doc) public void init(Object arg1) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14) throws StandardException(Code)(Java Doc) public boolean isAtomic() throws StandardException(Code)(Java Doc) protected boolean isInstanceOf(int nodeType)(Code)(Java Doc) public boolean isPrivilegeCollectionRequired()(Code)(Java Doc) final boolean isSessionSchema(SchemaDescriptor sd)(Code)(Java Doc) final boolean isSessionSchema(String schemaName)(Code)(Java Doc) public ConstantAction makeConstantAction() throws StandardException(Code)(Java Doc) public ResultDescription makeResultDescription() throws StandardException(Code)(Java Doc) public TableName makeTableName(String schemaName, String flatName) throws StandardException(Code)(Java Doc) public boolean needsSavepoint()(Code)(Java Doc) protected String nodeHeader()(Code)(Java Doc) public QueryTreeNode optimize() throws StandardException(Code)(Java Doc) public static QueryTreeNode parseQueryText(CompilerContext compilerContext, String queryText, Object[] paramDefaults, LanguageConnectionContext lcc) throws StandardException(Code)(Java Doc) public void printLabel(int depth, String label)(Code)(Java Doc) public void printSubNodes(int depth)(Code)(Java Doc) public boolean referencesSessionSchema() throws StandardException(Code)(Java Doc) public TableName resolveTableToSynonym(TableName tabName) throws StandardException(Code)(Java Doc) public void setBeginOffset(int beginOffset)(Code)(Java Doc) public void setContextManager(ContextManager cm)(Code)(Java Doc) public void setEndOffset(int endOffset)(Code)(Java Doc) public void setNodeType(int nodeType)(Code)(Java Doc) public void setRefActionInfo(long fkIndexConglomId, int[] fkColArray, String parentResultSetId, boolean dependentScan)(Code)(Java Doc) public String toString()(Code)(Java Doc) public void treePrint()(Code)(Java Doc) public void treePrint(int depth)(Code)(Java Doc) String verifyClassExist(String javaClassName, boolean convertCase) throws StandardException(Code)(Java Doc)
|
|
|