Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

public final Class Predicate

extends QueryTreeNode
implements OptimizablePredicate, Comparable<Predicate>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, org.apache.derby.iapi.sql.compile.OptimizablePredicate
Imports
java.util.HashSet, .Set, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.Optimizable, .OptimizablePredicate, .Visitor, org.apache.derby.iapi.store.access.ScanController, org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.util.JBitSet

A Predicate represents a top level predicate.

Field Summary

Modifier and TypeField and Description
pack-priv AndNode
pack-priv int
pack-priv int
protected boolean
pack-priv boolean
pack-priv JBitSet
private boolean
private Set<Integer>
protected boolean
protected boolean
Inherited from org.apache.derby.impl.sql.compile.QueryTreeNode:
AUTOINCREMENT_CREATE_MODIFYAUTOINCREMENT_CYCLEAUTOINCREMENT_INC_INDEXAUTOINCREMENT_IS_AUTOINCREMENT_INDEXAUTOINCREMENT_START_INDEX

Constructor Summary

AccessConstructor and Description
pack-priv
Predicate(AndNode
The top of the predicate
andNode
,
JBitSet
Bit map of referenced tables
referencedSet
,
ContextManager
The context manager
cm
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept the visitor for all visitable children of this node.

pack-priv String
binaryRelOpColRefsToString()

Get a string version of the column references for this predicate IF it's a binary relational operator.

pack-priv void
categorize()

Categorize this predicate.

pack-priv void
clearScanFlags()

Clear the start/stop position and qualifier flags

public int
compareTo(Predicate
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public boolean
compareWithKnownConstant(Optimizable
The Optimizable that we want to know whether we are comparing to a known constant.
optTable
,
boolean
Whether or not to consider parameters with defaults as known constants.
considerParameters
)

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.compareWithKnownConstant.

Is this predicate a comparison with a known constant value?

pack-priv void
copyFields(Predicate otherPred)

Copy all fields of this Predicate (except the two that are set from 'init').

public boolean
equalsComparisonWithConstantExpression(Optimizable
The Optimizable for which we want to know whether it is being equality-compared to a constant expression.
optTable
)

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.equalsComparisonWithConstantExpression.

Is this predicate an equality comparison with a constant expression?

pack-priv void
pack-priv AndNode

Returns:

AndNode The andNode.
getAndNode
()

Return the andNode.

public DataValueDescriptor
getCompareValue(Optimizable optTable)

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.getCompareValue.

Get an Object representing the known constant value that the given Optimizable is being compared to.

pack-priv int

Returns:

The equivalenceClass for this predicate.
getEquivalenceClass
()

Get the equivalenceClass for this predicate.

public int
getIndexPosition()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.getIndexPosition.

Get the position of the index column that this predicate restricts.

protected Predicate

Returns:

A new predicate whose operands have been scoped to the received childRSN.
getPredScopedForResultSet
(JBitSet
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.
parentRSNsTables
,
ResultSetNode
The result set node for which we want to create a scoped predicate.
childRSN
,
int[]
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.
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.

pack-priv boolean

Returns:

boolean Whether or not the predicate is pushable.
getPushable
()

Return the pushable.

public JBitSet
getReferencedMap()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.getReferencedMap.

Get the map of referenced tables for this OptimizablePredicate.

pack-priv JBitSet

Returns:

JBitSet The referencedSet.
getReferencedSet
()

Return the referencedSet.

pack-priv RelationalOperator

Returns:

The RelationalOperator on the left side of the AND node, if any.
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

Returns:

Underlying InListOp for this predicate (depending on the value of probePredOnly), or null if this predicate does not correspond to an IN-list in any way.
getSourceInList
(boolean
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.
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.

pack-priv int

Returns:

The start operator for a start key on this column.
getStartOperator
(Optimizable
The optimizable table, so we can tell which side of the operator the search column is on.
optTable
)

Get the start operator for this predicate for a scan.

pack-priv int
public int
hasEqualOnColumnList(int[]
the column numbers on which the user wants to check if the equality condition exists.
baseColumnPositions
,
Optimizable
the table for which baseColumnPositions are given.
optTable
)

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasEqualOnColumnList.

Returns if the predicate involves an equal operator on one of the columns specified in the baseColumnPositions.

public boolean
hasMethodCall()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasMethodCall.

Return whether or not an OptimizablePredicate contains a method call.

public boolean
hasSubquery()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.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

Returns:

Whether or not this is a join predicate.
isJoinPredicate
()

Is this predicate a join predicate?

pack-priv final boolean
pack-priv final boolean

Returns:

true if the predicate is a pushable set of OR clauses.
isPushableOrClause
(Optimizable optTable)

Is this predicate an pushable OR list?

public boolean
protected boolean

Returns:

False if there is no relational operator for this predicate OR if this predicate is an internal "probe predicate" (in which case it "looks" like we have a relational operator but in truth it's a disguised IN-list operator). True otherwise.
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.

public boolean
public boolean
pack-priv final boolean

Returns:

true if term is wither a AND of a RelationalOperator, or an OR of one or more Relational Operators.
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).

public void
markQualifier()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.markQualifier.

Tell the predicate that it is to be used as a qualifier in an index scan.

public void
markStartKey()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.markStartKey.

Tell the predicate that it is to be used as a column in the start key value for an index scan.

public void
markStopKey()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.markStopKey.

Tell the predicate that it is to be used as a column in the stop key value for an index scan.

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.printSubNodes.

Prints the sub-nodes of this object.

protected boolean

Returns:

Whether or not this predicate is eligible to be pushed into subqueries.
pushableToSubqueries
()

Determine whether or not this predicate is eligible for push-down into subqueries.

protected boolean

Returns:

True if this predicate is a scoped predicate, in which case we performed a one-sided remap. False if the predicate is not scoped; the caller can then make the calls to perform a "normal" remap on this predicate.
remapScopedPred
()

When remapping a "normal" (i.e. non-scoped) predicate both of the predicate's operands are remapped and that's it.

public double
selectivity(Optimizable
The Optimizable that this predicate restricts
optTable
)

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.selectivity.

Get a (crude) estimate of the selectivity of this predicate.

pack-priv void
setAndNode(AndNode
The new andNode.
andNode
)

Set the andNode.

pack-priv void
setEquivalenceClass(int
The equivalence class for this predicate.
equivalenceClass
)

Set the equivalence class, if any, for this predicate.

pack-priv void
setIndexPosition(int
The position of the index column that this predicate restricts.
indexPosition
)

Set the position of the index column that this predicate restricts

pack-priv void
setPushable(boolean
Whether or not the predicate is pushable.
pushable
)

Set whether or not this predicate is pushable.

pack-priv void
setTransitiveSearchClauseAdded(RelationalOperator
The search clause that we are currently considering as the source for transitive closure
ro
)

Mark this predicate as having been used to add a new predicate of the specified type via transitive closure on search clauses.

public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.toString.

Convert this object to a String.

pack-priv boolean

Returns:

Whether or not this predicate has been used to add a new search clause of the specified type via transitive closure.
transitiveSearchClauseAdded
(RelationalOperator
The search clause that we are currently considering as the source for transitive closure
ro
)

Return whether or not this predicate has been used to add a new search clause of the specified type via transitive closure.

Inherited from org.apache.derby.impl.sql.compile.QueryTreeNode:
acceptaddTagaddUDTUsagePrivaddUDTUsagePrivbindOffsetFetchbindRowMultiSetbindUserCatalogTypebindUserTypecheckReliabilitycheckReliabilityconvertDefaultNodecopyTagsFromcreateTypeDependencydebugFlushdebugPrintdisablePrivilegeCollectionformatNodeStringgenerategenerateAuthorizeCheckgetBeginOffsetgetClassFactorygetCompilerContextgetContextgetContextManagergetDataDictionarygetDependencyManagergetEndOffsetgetExecutionFactorygetGenericConstantActionFactorygetIntPropertygetLanguageConnectionContextgetLongPropertygetNullNodegetOffsetOrderedNodesgetOptimizerFactorygetOptimizerTracergetParameterTypesgetSchemaDescriptorgetSchemaDescriptorgetStatementTypegetTableDescriptorgetTypeCompilergetUDTDescisAtomicisPrivilegeCollectionRequiredisSessionSchemaisSessionSchemamakeConstantActionmakeTableNamemakeTableNamenodeHeaderoptimizerTracingIsOnorReliabilityparseSearchConditionparseStatementprintLabelreferencesSessionSchemaresolveTableToSynonymsetBeginOffsetsetEndOffsetsetRefActionInfostackPrinttaggedWithtreePrinttreePrintverifyClassExist

Field Detail

andNodeback to summary
pack-priv AndNode andNode
equivalenceClassback to summary
pack-priv int equivalenceClass
indexPositionback to summary
pack-priv int indexPosition
isQualifierback to summary
protected boolean isQualifier
pushableback to summary
pack-priv boolean pushable
referencedSetback to summary
pack-priv JBitSet referencedSet
scopedback to summary
private boolean scoped
searchClausesback to summary
private Set<Integer> searchClauses
startKeyback to summary
protected boolean startKey
stopKeyback to summary
protected boolean stopKey

Constructor Detail

Predicateback to summary
pack-priv Predicate(AndNode andNode, JBitSet referencedSet, ContextManager cm)

Constructor.

Parameters
andNode:AndNode

The top of the predicate

referencedSet:JBitSet

Bit map of referenced tables

cm:ContextManager

The context manager

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept the visitor for all visitable children of this node.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on error
binaryRelOpColRefsToStringback to summary
pack-priv String binaryRelOpColRefsToString()

Get a string version of the column references for this predicate IF it's a binary relational operator. We only print out the names of the operands if they are column references; otherwise we just print a dummy value. This is for debugging purposes only--it's a convenient way to see what columns the predicate is referencing, especially when tracing through code and printing assert failure.

categorizeback to summary
pack-priv void categorize() throws StandardException

Categorize this predicate. Initially, this means building a bit map of the referenced tables for each predicate.

Exceptions
StandardException:
Thrown on error
clearScanFlagsback to summary
pack-priv void clearScanFlags()

Clear the start/stop position and qualifier flags

compareToback to summary
public int compareTo(Predicate other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
other:Predicate

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareWithKnownConstantback to summary
public boolean compareWithKnownConstant(Optimizable optTable, boolean considerParameters)

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.compareWithKnownConstant.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.compareWithKnownConstant.

Is this predicate a comparison with a known constant value?

Parameters
optTable:Optimizable

The Optimizable that we want to know whether we are comparing to a known constant.

considerParameters:boolean

Whether or not to consider parameters with defaults as known constants.

See Also
OptimizablePredicate#compareWithKnownConstant
copyFieldsback to summary
pack-priv void copyFields(Predicate otherPred)

Copy all fields of this Predicate (except the two that are set from 'init').

equalsComparisonWithConstantExpressionback to summary
public boolean equalsComparisonWithConstantExpression(Optimizable optTable)

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.equalsComparisonWithConstantExpression.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.equalsComparisonWithConstantExpression.

Is this predicate an equality comparison with a constant expression? (IS NULL is considered to be an = comparison with a constant expression).

Parameters
optTable:Optimizable

The Optimizable for which we want to know whether it is being equality-compared to a constant expression.

See Also
OptimizablePredicate#equalsComparisonWithConstantExpression
generateExpressionOperandback to summary
pack-priv void generateExpressionOperand(Optimizable optTable, int columnPosition, ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
getAndNodeback to summary
pack-priv AndNode getAndNode()

Return the andNode.

Returns:AndNode

AndNode The andNode.

getCompareValueback to summary
public DataValueDescriptor getCompareValue(Optimizable optTable) throws StandardException

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.getCompareValue.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.getCompareValue.

Get an Object representing the known constant value that the given Optimizable is being compared to.

Exceptions
StandardException:
Thrown on error
See Also
OptimizablePredicate#getCompareValue
getEquivalenceClassback to summary
pack-priv int getEquivalenceClass()

Get the equivalenceClass for this predicate.

Returns:int

The equivalenceClass for this predicate.

getIndexPositionback to summary
public int getIndexPosition()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.getIndexPosition.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.getIndexPosition.

Get the position of the index column that this predicate restricts.

Note

This assumes that this predicate is part of an OptimizablePredicateList, and that classify() has been called on the OptimizablePredicateList.

Returns:int

The index position that this predicate restricts (zero-based)

See Also
OptimizablePredicate#getIndexPosition
getPredScopedForResultSetback to summary
protected Predicate getPredScopedForResultSet(JBitSet parentRSNsTables, ResultSetNode childRSN, int[] whichRC) throws StandardException

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. By "scoped" we mean that the operands, which shold be column references, have been mapped to the appropriate result columns in the received RSN. This is useful for pushing predicates from outer queries down into inner queries, in which case the column references need to be remapped. For example, let V1 represent select i,j from t1 UNION select i,j from t2 and V2 represent select a,b from t3 UNION select a,b from t4 Then assume we have the following query: select * from V1, V2 where V1.j = V2.b Let's further assume that this Predicate object represents the "V1.j = V2.b" operator and that the childRSN we received as a parameter represents one of the subqueries to which we want to push the predicate; let's say it's: select i,j from t1 Then this method will return a new predicate whose binary operator represents the expression "T1.j = V2.b" (that is, V1.j will be mapped to the corresponding column in T1). For more on how that mapping is made, see the "getScopedOperand()" method in BinaryRelationalOperatorNode.java. ASSUMPTION: We should only get to this method if we know that at least one operand in this predicate can and should be mapped to the received childRSN. For an example of where that check is made, see the pushOptPredicate() method in SetOperatorNode.java.

Parameters
parentRSNsTables:JBitSet

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:ResultSetNode

The result set node for which we want to create a scoped predicate.

whichRC:int[]

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.

Returns:Predicate

A new predicate whose operands have been scoped to the received childRSN.

getPushableback to summary
pack-priv boolean getPushable()

Return the pushable.

Returns:boolean

boolean Whether or not the predicate is pushable.

getReferencedMapback to summary
public JBitSet getReferencedMap()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.getReferencedMap.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.getReferencedMap.

Get the map of referenced tables for this OptimizablePredicate.

Returns:JBitSet

JBitSet Referenced table map.

See Also
org.apache.derby.iapi.sql.compile.OptimizablePredicate#getReferencedMap
getReferencedSetback to summary
pack-priv JBitSet getReferencedSet()

Return the referencedSet.

Returns:JBitSet

JBitSet The referencedSet.

getRelopback to summary
pack-priv RelationalOperator getRelop()

Get the RelationalOperator on the left side of the AND node, if there is one. If the left side is not a RelationalOperator, return null.

Returns:RelationalOperator

The RelationalOperator on the left side of the AND node, if any.

getSourceInListback to summary
protected InListOperatorNode getSourceInList()

If this predicate corresponds to an IN-list, return the underlying InListOperatorNode from which it was built. There are two forms to check for: 1. This predicate is an IN-list "probe predicate", in which case the underlying InListOpNode is stored within the binary relational operator that is the left operand of this predicate's AND node. 2. This predicate corresponds to an IN-list that could _not_ be transformed into a "probe predicate" (i.e. the IN-list contains one or more non-parameter, non-constant values). In that case the underlying InListOpNode is simply the left operand of this predicate's AND node. If this predicate does not correspond to an IN-list in any way, this method will return null.

getSourceInListback to summary
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.

Parameters
probePredOnly:boolean

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.

Returns:InListOperatorNode

Underlying InListOp for this predicate (depending on the value of probePredOnly), or null if this predicate does not correspond to an IN-list in any way.

getStartOperatorback to summary
pack-priv int getStartOperator(Optimizable optTable)

Get the start operator for this predicate for a scan.

Parameters
optTable:Optimizable

The optimizable table, so we can tell which side of the operator the search column is on.

Returns:int

The start operator for a start key on this column.

getStopOperatorback to summary
pack-priv int getStopOperator(Optimizable optTable)
hasEqualOnColumnListback to summary
public int hasEqualOnColumnList(int[] baseColumnPositions, Optimizable optTable) throws StandardException

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasEqualOnColumnList.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasEqualOnColumnList.

Returns if the predicate involves an equal operator on one of the columns specified in the baseColumnPositions.

Parameters
baseColumnPositions:int[]

the column numbers on which the user wants to check if the equality condition exists.

optTable:Optimizable

the table for which baseColumnPositions are given.

Returns:int

returns the index into baseColumnPositions of the column that has the equality operator.

hasMethodCallback to summary
public boolean hasMethodCall()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasMethodCall.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasMethodCall.

Return whether or not an OptimizablePredicate contains a method call.

Returns:boolean

boolean Whether or not an OptimizablePredicate includes a method call.

See Also
org.apache.derby.iapi.sql.compile.OptimizablePredicate#hasMethodCall
hasSubqueryback to summary
public boolean hasSubquery()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasSubquery.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.hasSubquery.

Return whether or not an OptimizablePredicate contains a subquery.

Returns:boolean

boolean Whether or not an OptimizablePredicate includes a subquery.

See Also
org.apache.derby.iapi.sql.compile.OptimizablePredicate#hasSubquery
isInListProbePredicateback to summary
protected boolean isInListProbePredicate()

Return whether or not this predicate is an IN-list probe predicate.

isJoinPredicateback to summary
protected boolean isJoinPredicate()

Is this predicate a join predicate? In order to be so, it must be a binary relational operator node that has a column reference on both sides.

Returns:boolean

Whether or not this is a join predicate.

isOrListback to summary
pack-priv final boolean isOrList()
isPushableOrClauseback to summary
pack-priv final boolean isPushableOrClause(Optimizable optTable) throws StandardException

Is this predicate an pushable OR list?

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.

Returns:boolean

true if the predicate is a pushable set of OR clauses.

Exceptions
StandardException:
Standard exception policy.
isQualifierback to summary
public boolean isQualifier()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.isQualifier.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.isQualifier.

Is this predicate a qualifier?

See Also
OptimizablePredicate#isQualifier
isRelationalOpPredicateback to summary
protected boolean isRelationalOpPredicate()

Return whether or not this predicate corresponds to a legitimate relational operator.

Returns:boolean

False if there is no relational operator for this predicate OR if this predicate is an internal "probe predicate" (in which case it "looks" like we have a relational operator but in truth it's a disguised IN-list operator). True otherwise.

isScopedForPushback to summary
protected boolean isScopedForPush()

Return whether or not this predicate is a scoped copy of another predicate.

isScopedToSourceResultSetback to summary
protected boolean isScopedToSourceResultSet() throws StandardException

Return true if this predicate is scoped AND the scoped operand is a ColumnReference that points to a source result set. If the scoped operand is not a ColumnReference that points to a source result set then it must be pointing to some kind of expression, such as a literal (ex. 'strlit'), an aggregate value (ex. "count(*)"), or the result of a function (ex. "sin(i)") or operator (ex. "i+1"). This method is used when pushing predicates to determine how far down the query tree a scoped predicate needs to be pushed to allow for successful evaluation of the scoped operand. If the scoped operand is not pointing to a source result set then it should not be pushed any further down tree. The reason is that evaluation of the expression to which the operand is pointing may depend on other values from the current level in the tree (ex. "sin(i)" depends on the value of "i", which could be a column at the predicate's current level). If we pushed the predicate further down, those values could become inaccessible, leading to execution-time errors. If, on the other hand, the scoped operand *is* pointing to a source result set, then we want to push it further down the tree until it reaches that result set, which allows evaluation of this predicate to occur as close to store as possible. This method doesn't actually do the push, it just returns "true" and then the caller can push as appropriate.

isStartKeyback to summary
public boolean isStartKey()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.isStartKey.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.isStartKey.

Is this predicate a start key?

See Also
OptimizablePredicate#isStartKey
isStopKeyback to summary
public boolean isStopKey()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.isStopKey.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.isStopKey.

Is this predicate a stop key?

See Also
OptimizablePredicate#isStopKey
isStoreQualifierback to summary
pack-priv final boolean isStoreQualifier()

Is this predicate a possible Qualifier for store?

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.

Returns:boolean

true if term is wither a AND of a RelationalOperator, or an OR of one or more Relational Operators.

Exceptions
StandardException:
Standard exception policy.
markAsScopedForPushback to summary
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).

markQualifierback to summary
public void markQualifier()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.markQualifier.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.markQualifier.

Tell the predicate that it is to be used as a qualifier in an index scan.

See Also
OptimizablePredicate#markQualifier
markStartKeyback to summary
public void markStartKey()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.markStartKey.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.markStartKey.

Tell the predicate that it is to be used as a column in the start key value for an index scan.

See Also
OptimizablePredicate#markStartKey
markStopKeyback to summary
public void markStopKey()

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.markStopKey.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.markStopKey.

Tell the predicate that it is to be used as a column in the stop key value for an index scan.

See Also
OptimizablePredicate#markStopKey
printSubNodesback to summary
pack-priv void printSubNodes(int depth)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.printSubNodes.

Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Parameters
depth:int

The depth of this node in the tree

Annotations
@Override
pushableToSubqueriesback to summary
protected boolean pushableToSubqueries() throws StandardException

Determine whether or not this predicate is eligible for push-down into subqueries. Right now the only predicates we consider to be eligible are those which 1) are Binary Relational operator nodes and 2) have a column reference on BOTH sides, each of which has a reference to a base table somewhere beneath it.

Returns:boolean

Whether or not this predicate is eligible to be pushed into subqueries.

remapScopedPredback to summary
protected boolean remapScopedPred()

When remapping a "normal" (i.e. non-scoped) predicate both of the predicate's operands are remapped and that's it. But when remapping a scoped predicate, things are slightly different. This method handles remapping of scoped predicates. We know that, for a scoped predicate, exactly one operand has been scoped for a specific target result set; the other operand is pointing to some other instance of FromTable with which the target result set is to be joined (see getScopedOperand() in BinaryRelationalOperatorNode.java). For every level of the query through which the scoped predicate is pushed, we have to perform a remap operation of the scoped operand. We do *not*, however, remap the non-scoped operand. The reason is that the non-scoped operand is already pointing to the result set against which it must be evaluated. As the scoped predicate is pushed down the query tree, the non-scoped operand should not change where it's pointing and thus should not be remapped. For example, assume we have a query whose tree has the following form: SELECT[0] / \ PRN PRN | | SELECT[4] UNION | / \ PRN SELECT[1] SELECT[2] | | | [FBT:T1] PRN PRN | | SELECT[3] [FromBaseTable:T2] | PRN | [FromBaseTable:T3] Assume also that we have some predicate "SELECT[4].i = .j". If the optimizer decides to push the predicate to the UNION node, it (the predicate) will be scoped to the UNION's children, yielding something like "SELECT[4].i = SELECT[1].j" for the left child and "SELECT[4].i = SELECT[2].j" for the right child. These scoped predicates will then be pushed to the PRNs above SELECT[3] and T2, respectively. As part of that pushing process a call to PRN.pushOptPredicate() will occur, which brings us to this method. So let's assume we're here for the scoped predicate "SELECT[4].i = SELECT[1].j". Then we want to remap the scoped operand, "SELECT[1].j", so that it will point to the correct column in "SELECT[3]". We do NOT, however, want to remap the non-scoped operand "SELECT[4].i" because that operand is already pointing to the correct result set--namely, to a column in SELECT[4]. That non-scoped operand should not change regardless of how far down the UNION subtree the scoped predicate is pushed. If we did try to remap the non-scoped operand, it would end up pointing to result sets too low in the tree, which could lead to execution-time errors. So when we remap a scoped predicate, we have to make sure we only remap the scoped operand. That's what this method does.

Returns:boolean

True if this predicate is a scoped predicate, in which case we performed a one-sided remap. False if the predicate is not scoped; the caller can then make the calls to perform a "normal" remap on this predicate.

selectivityback to summary
public double selectivity(Optimizable optTable) throws StandardException

Implements org.apache.derby.iapi.sql.compile.OptimizablePredicate.selectivity.

Doc from org.apache.derby.iapi.sql.compile.OptimizablePredicate.selectivity.

Get a (crude) estimate of the selectivity of this predicate. This is to be used when no better technique is available for estimating the selectivity - this method's estimate is a hard- wired number based on the type of predicate and the datatype (the selectivity of boolean is always 50%).

Parameters
optTable:Optimizable

The Optimizable that this predicate restricts

See Also
OptimizablePredicate#selectivity
setAndNodeback to summary
pack-priv void setAndNode(AndNode andNode)

Set the andNode.

Parameters
andNode:AndNode

The new andNode.

setEquivalenceClassback to summary
pack-priv void setEquivalenceClass(int equivalenceClass)

Set the equivalence class, if any, for this predicate.

Parameters
equivalenceClass:int

The equivalence class for this predicate.

setIndexPositionback to summary
pack-priv void setIndexPosition(int indexPosition)

Set the position of the index column that this predicate restricts

Parameters
indexPosition:int

The position of the index column that this predicate restricts.

setPushableback to summary
pack-priv void setPushable(boolean pushable)

Set whether or not this predicate is pushable. This method is intended for use when creating a copy of the predicate, ex for predicate pushdown. We choose not to add this assignment to copyFields() because the comments for that method say that it should copy all fields _except_ the two specified at init time; "pushable" is one of the two specified at init time.

Parameters
pushable:boolean

Whether or not the predicate is pushable.

setTransitiveSearchClauseAddedback to summary
pack-priv 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.

Parameters
ro:RelationalOperator

The search clause that we are currently considering as the source for transitive closure

toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.toString.

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override
transitiveSearchClauseAddedback to summary
pack-priv 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.

Note

This can only be true if this is an equijoin between 2 column references.

Parameters
ro:RelationalOperator

The search clause that we are currently considering as the source for transitive closure

Returns:boolean

Whether or not this predicate has been used to add a new search clause of the specified type via transitive closure.