java.lang.Comparable<Predicate>
, OptimizablePredicate
, Visitable
public final class Predicate extends QueryTreeNode implements OptimizablePredicate, java.lang.Comparable<Predicate>
Modifier and Type | Field | Description |
---|---|---|
(package private) AndNode |
andNode |
|
(package private) int |
equivalenceClass |
|
(package private) int |
indexPosition |
|
protected boolean |
isQualifier |
|
(package private) boolean |
pushable |
|
(package private) JBitSet |
referencedSet |
|
private boolean |
scoped |
|
private java.util.Set<java.lang.Integer> |
searchClauses |
|
protected boolean |
startKey |
|
protected boolean |
stopKey |
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
Constructor | Description |
---|---|
Predicate(AndNode andNode,
JBitSet referencedSet,
ContextManager cm) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
(package private) void |
acceptChildren(Visitor v) |
Accept the visitor for all visitable children of this node.
|
(package private) java.lang.String |
binaryRelOpColRefsToString() |
Get a string version of the column references for this predicate
IF it's a binary relational operator.
|
(package private) void |
categorize() |
Categorize this predicate.
|
(package private) void |
clearScanFlags() |
Clear the start/stop position and qualifier flags
|
int |
compareTo(Predicate other) |
|
boolean |
compareWithKnownConstant(Optimizable optTable,
boolean considerParameters) |
Is this predicate a comparison with a known constant value?
|
(package private) void |
copyFields(Predicate otherPred) |
Copy all fields of this Predicate (except the two that
are set from 'init').
|
boolean |
equalsComparisonWithConstantExpression(Optimizable optTable) |
Is this predicate an equality comparison with a constant expression?
|
(package private) void |
generateExpressionOperand(Optimizable optTable,
int columnPosition,
ExpressionClassBuilder acb,
MethodBuilder mb) |
|
(package private) AndNode |
getAndNode() |
Return the andNode.
|
DataValueDescriptor |
getCompareValue(Optimizable optTable) |
Get an Object representing the known constant value that the given
Optimizable is being compared to.
|
(package private) int |
getEquivalenceClass() |
Get the equivalenceClass for this predicate.
|
int |
getIndexPosition() |
Get the position of the index column that this predicate restricts.
|
protected Predicate |
getPredScopedForResultSet(JBitSet parentRSNsTables,
ResultSetNode childRSN,
int[] whichRC) |
If this predicate's operator is a BinaryRelationalOperatorNode,
then look at the operands and return a new, equivalent predicate
that is "scoped" to the received ResultSetNode.
|
(package private) boolean |
getPushable() |
Return the pushable.
|
JBitSet |
getReferencedMap() |
Get the map of referenced tables for this OptimizablePredicate.
|
(package private) JBitSet |
getReferencedSet() |
Return the referencedSet.
|
(package private) RelationalOperator |
getRelop() |
Get the RelationalOperator on the left side of the AND node, if
there is one.
|
protected InListOperatorNode |
getSourceInList() |
If this predicate corresponds to an IN-list, return the underlying
InListOperatorNode from which it was built.
|
protected InListOperatorNode |
getSourceInList(boolean probePredOnly) |
Does the work of getSourceInList() above, but can also be called
directly with an argument to indicate whether or not we should
limit ourselves to probe predicates.
|
(package private) int |
getStartOperator(Optimizable optTable) |
Get the start operator for this predicate for a scan.
|
(package private) int |
getStopOperator(Optimizable optTable) |
|
int |
hasEqualOnColumnList(int[] baseColumnPositions,
Optimizable optTable) |
Returns if the predicate involves an equal operator on one of the
columns specified in the baseColumnPositions.
|
boolean |
hasMethodCall() |
Return whether or not an OptimizablePredicate contains a method call.
|
boolean |
hasSubquery() |
Return whether or not an OptimizablePredicate contains a subquery.
|
protected boolean |
isInListProbePredicate() |
Return whether or not this predicate is an IN-list probe
predicate.
|
protected boolean |
isJoinPredicate() |
Is this predicate a join predicate?
|
(package private) boolean |
isOrList() |
|
(package private) boolean |
isPushableOrClause(Optimizable optTable) |
Is this predicate an pushable OR list?
|
boolean |
isQualifier() |
Is this predicate a qualifier?
|
protected boolean |
isRelationalOpPredicate() |
Return whether or not this predicate corresponds to a legitimate
relational operator.
|
protected boolean |
isScopedForPush() |
Return whether or not this predicate is a scoped copy of
another predicate.
|
protected boolean |
isScopedToSourceResultSet() |
Return true if this predicate is scoped AND the scoped
operand is a ColumnReference that points to a source result
set.
|
boolean |
isStartKey() |
Is this predicate a start key?
|
boolean |
isStopKey() |
Is this predicate a stop key?
|
(package private) boolean |
isStoreQualifier() |
Is this predicate a possible Qualifier for store?
|
protected void |
markAsScopedForPush() |
Indicate that this predicate is a scoped copy of some other
predicate (i.e. it was created as the result of a call to
getPredScopedForResultSet() on some other predicate).
|
void |
markQualifier() |
Tell the predicate that it is to be used as a qualifier in an index
scan.
|
void |
markStartKey() |
Tell the predicate that it is to be used as a column in the start key
value for an index scan.
|
void |
markStopKey() |
Tell the predicate that it is to be used as a column in the stop key
value for an index scan.
|
(package private) void |
printSubNodes(int depth) |
Prints the sub-nodes of this object.
|
protected boolean |
pushableToSubqueries() |
Determine whether or not this predicate is eligible for
push-down into subqueries.
|
protected boolean |
remapScopedPred() |
When remapping a "normal" (i.e. non-scoped) predicate both
of the predicate's operands are remapped and that's it.
|
double |
selectivity(Optimizable optTable) |
Get a (crude) estimate of the selectivity of this predicate.
|
(package private) void |
setAndNode(AndNode andNode) |
Set the andNode.
|
(package private) void |
setEquivalenceClass(int equivalenceClass) |
Set the equivalence class, if any, for this predicate.
|
(package private) void |
setIndexPosition(int indexPosition) |
Set the position of the index column that this predicate restricts
|
(package private) void |
setPushable(boolean pushable) |
Set whether or not this predicate is pushable.
|
(package private) void |
setTransitiveSearchClauseAdded(RelationalOperator ro) |
Mark this predicate as having been used to add a new predicate
of the specified type via transitive closure on search clauses.
|
java.lang.String |
toString() |
Convert this object to a String.
|
(package private) boolean |
transitiveSearchClauseAdded(RelationalOperator ro) |
Return whether or not this predicate has been used
to add a new search clause of the specified type via transitive closure.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
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, treePrint, treePrint, verifyClassExist
AndNode andNode
boolean pushable
JBitSet referencedSet
int equivalenceClass
int indexPosition
protected boolean startKey
protected boolean stopKey
protected boolean isQualifier
private java.util.Set<java.lang.Integer> searchClauses
private boolean scoped
Predicate(AndNode andNode, JBitSet referencedSet, ContextManager cm)
andNode
- The top of the predicatereferencedSet
- Bit map of referenced tablescm
- The context managerpublic JBitSet getReferencedMap()
OptimizablePredicate
getReferencedMap
in interface OptimizablePredicate
OptimizablePredicate.getReferencedMap()
public boolean hasSubquery()
OptimizablePredicate
hasSubquery
in interface OptimizablePredicate
OptimizablePredicate.hasSubquery()
public boolean hasMethodCall()
OptimizablePredicate
hasMethodCall
in interface OptimizablePredicate
OptimizablePredicate.hasMethodCall()
public void markStartKey()
OptimizablePredicate
markStartKey
in interface OptimizablePredicate
OptimizablePredicate.markStartKey()
public boolean isStartKey()
OptimizablePredicate
isStartKey
in interface OptimizablePredicate
OptimizablePredicate.isStartKey()
public void markStopKey()
OptimizablePredicate
markStopKey
in interface OptimizablePredicate
OptimizablePredicate.markStopKey()
public boolean isStopKey()
OptimizablePredicate
isStopKey
in interface OptimizablePredicate
OptimizablePredicate.isStopKey()
public void markQualifier()
OptimizablePredicate
markQualifier
in interface OptimizablePredicate
OptimizablePredicate.markQualifier()
public boolean isQualifier()
OptimizablePredicate
isQualifier
in interface OptimizablePredicate
OptimizablePredicate.isQualifier()
public boolean compareWithKnownConstant(Optimizable optTable, boolean considerParameters)
OptimizablePredicate
compareWithKnownConstant
in interface OptimizablePredicate
optTable
- The Optimizable that we want to know whether we
are comparing to a known constant.considerParameters
- Whether or not to consider parameters with defaults
as known constants.OptimizablePredicate.compareWithKnownConstant(org.apache.derby.iapi.sql.compile.Optimizable, boolean)
public int hasEqualOnColumnList(int[] baseColumnPositions, Optimizable optTable) throws StandardException
OptimizablePredicate
hasEqualOnColumnList
in interface OptimizablePredicate
baseColumnPositions
- the column numbers on which the user wants
to check if the equality condition exists.optTable
- the table for which baseColumnPositions are given.StandardException
public DataValueDescriptor getCompareValue(Optimizable optTable) throws StandardException
OptimizablePredicate
getCompareValue
in interface OptimizablePredicate
StandardException
- Thrown on errorOptimizablePredicate.getCompareValue(org.apache.derby.iapi.sql.compile.Optimizable)
public boolean equalsComparisonWithConstantExpression(Optimizable optTable)
OptimizablePredicate
equalsComparisonWithConstantExpression
in interface OptimizablePredicate
optTable
- The Optimizable for which we want to know whether
it is being equality-compared to a constant expression.OptimizablePredicate.equalsComparisonWithConstantExpression(org.apache.derby.iapi.sql.compile.Optimizable)
public double selectivity(Optimizable optTable) throws StandardException
OptimizablePredicate
selectivity
in interface OptimizablePredicate
optTable
- The Optimizable that this predicate restrictsStandardException
OptimizablePredicate.selectivity(org.apache.derby.iapi.sql.compile.Optimizable)
public int getIndexPosition()
OptimizablePredicate
getIndexPosition
in interface OptimizablePredicate
OptimizablePredicate.getIndexPosition()
public int compareTo(Predicate other)
compareTo
in interface java.lang.Comparable<Predicate>
AndNode getAndNode()
void setAndNode(AndNode andNode)
andNode
- The new andNode.boolean getPushable()
void setPushable(boolean pushable)
pushable
- Whether or not the predicate is pushable.JBitSet getReferencedSet()
void setEquivalenceClass(int equivalenceClass)
equivalenceClass
- The equivalence class for this predicate.int getEquivalenceClass()
void categorize() throws StandardException
StandardException
- Thrown on errorRelationalOperator getRelop()
final boolean isOrList()
final boolean isStoreQualifier()
Current 2 types of predicates can be pushed to store: 1) RelationalOperator - represented with by left operand as instance of RelationalOperator. 2) A single And'd term of a list of OR terms represented by left operand as instance of OrNode. More checking specific operator's terms to see if they are finally pushable to store. In the final push at execution each term of the AND or OR must be a Relational operator with a column reference on one side and a constant on the other.
StandardException
- Standard exception policy.final boolean isPushableOrClause(Optimizable optTable) throws StandardException
Does the predicate represent a AND'd list of OR term's, all of which are pushable. To be pushable each of OR terms must be a legal qualifier, which is a column reference on one side of a Relational operator and a constant on the other.
StandardException
- Standard exception policy.boolean transitiveSearchClauseAdded(RelationalOperator ro)
ro
- The search clause that we are currently considering
as the source for transitive closurevoid setTransitiveSearchClauseAdded(RelationalOperator ro)
ro
- The search clause that we are currently considering
as the source for transitive closureint getStartOperator(Optimizable optTable)
optTable
- The optimizable table, so we can tell which side of
the operator the search column is on.int getStopOperator(Optimizable optTable)
void setIndexPosition(int indexPosition)
indexPosition
- The position of the index column that this
predicate restricts.void clearScanFlags()
void generateExpressionOperand(Optimizable optTable, int columnPosition, ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
StandardException
public java.lang.String toString()
toString
in class QueryTreeNode
java.lang.String binaryRelOpColRefsToString()
void printSubNodes(int depth)
printSubNodes
in class QueryTreeNode
depth
- The depth of this node in the treevoid acceptChildren(Visitor v) throws StandardException
acceptChildren
in class QueryTreeNode
v
- the visitorStandardException
- on errorvoid copyFields(Predicate otherPred)
protected boolean pushableToSubqueries() throws StandardException
StandardException
protected boolean isJoinPredicate()
protected Predicate getPredScopedForResultSet(JBitSet parentRSNsTables, ResultSetNode childRSN, int[] whichRC) throws StandardException
parentRSNsTables
- Set of all table numbers referenced by
the ResultSetNode that is _parent_ to the received childRSN.
We need this to make sure we don't scope the operands to a
ResultSetNode to which they don't apply.childRSN
- The result set node for which we want to create
a scoped predicate.whichRC
- If not -1 then this tells us which ResultColumn
in the received childRSN we need to use for the scoped predicate;
if -1 then the column position of the scoped column reference
will be stored in this array and passed back to the caller.StandardException
protected void markAsScopedForPush()
protected boolean isScopedForPush()
protected boolean remapScopedPred()
protected boolean isScopedToSourceResultSet() throws StandardException
StandardException
protected boolean isRelationalOpPredicate()
protected boolean isInListProbePredicate()
protected InListOperatorNode getSourceInList()
protected InListOperatorNode getSourceInList(boolean probePredOnly)
probePredOnly
- If true, only get the source IN list for this
predicate *if* it is an IN-list probe predicate. If false,
return the underlying InListOperatorNode (if it exists) regardless
of whether this is a probe predicate or an un-transformed IN-list
pred.Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.