Top Description Methods
org.apache.derby.iapi.sql.compile

public Interface OptimizablePredicate

Known Direct Implementers
org.apache.derby.impl.sql.compile.Predicate
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.util.JBitSet

OptimizablePredicate provides services for optimizing predicates in a query.

Method Summary

Modifier and TypeMethod and Description
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
)

Is this predicate a comparison with a known constant value?

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

Is this predicate an equality comparison with a constant expression?

public DataValueDescriptor
getCompareValue(Optimizable optTable)

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

public int

Returns:

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

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

public JBitSet

Returns:

JBitSet Referenced table map.
getReferencedMap
()

Get the map of referenced tables for this OptimizablePredicate.

public int

Returns:

returns the index into baseColumnPositions of the column that has the equality operator.
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
)

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

public boolean

Returns:

boolean Whether or not an OptimizablePredicate includes a method call.
hasMethodCall
()

Return whether or not an OptimizablePredicate contains a method call.

public boolean

Returns:

boolean Whether or not an OptimizablePredicate includes a subquery.
hasSubquery
()

Return whether or not an OptimizablePredicate contains a subquery.

public boolean
isQualifier()

Is this predicate a qualifier?

public boolean
isStartKey()

Is this predicate a start key?

public boolean
isStopKey()

Is this predicate a stop key?

public void
markQualifier()

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

public void
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()

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

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

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

Method Detail

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

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.

equalsComparisonWithConstantExpressionback to summary
public boolean equalsComparisonWithConstantExpression(Optimizable optTable)

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.

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

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

Exceptions
StandardException:
Thrown on error
getIndexPositionback to summary
public int 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)

getReferencedMapback to summary
public JBitSet getReferencedMap()

Get the map of referenced tables for this OptimizablePredicate.

Returns:JBitSet

JBitSet Referenced table map.

hasEqualOnColumnListback to summary
public int hasEqualOnColumnList(int[] baseColumnPositions, Optimizable optTable) throws StandardException

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()

Return whether or not an OptimizablePredicate contains a method call.

Returns:boolean

boolean Whether or not an OptimizablePredicate includes a method call.

hasSubqueryback to summary
public boolean hasSubquery()

Return whether or not an OptimizablePredicate contains a subquery.

Returns:boolean

boolean Whether or not an OptimizablePredicate includes a subquery.

isQualifierback to summary
public boolean isQualifier()

Is this predicate a qualifier?

isStartKeyback to summary
public boolean isStartKey()

Is this predicate a start key?

isStopKeyback to summary
public boolean isStopKey()

Is this predicate a stop key?

markQualifierback to summary
public void markQualifier()

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

markStartKeyback to summary
public void markStartKey()

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

markStopKeyback to summary
public void markStopKey()

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

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

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