@Immutable public class RewriteAsRangeCriteria extends Object implements OptimizerRule
optimizer rule
that rewrites two AND-ed
Constraint
s that constraint a dynamic
operand to a range of values as a single Between
constraint. This rule also collapses and removes any constraints that
are unnecessary because other constraints are more restrictive or because they cancel out other constraints.Modifier and Type | Field and Description |
---|---|
protected static Constraint |
CONFLICTING_CONSTRAINT |
static RewriteAsRangeCriteria |
INSTANCE |
Constructor and Description |
---|
RewriteAsRangeCriteria() |
Modifier and Type | Method and Description |
---|---|
protected int |
compareStaticOperands(QueryContext context,
Comparison comparison1,
Comparison comparison2)
Compare the values used in the two comparisons
|
PlanNode |
execute(QueryContext context,
PlanNode plan,
LinkedList<OptimizerRule> ruleStack)
Optimize the supplied plan using the supplied context, hints, and yet-to-be-run rules.
|
protected Comparison |
getComparison(QueryContext context,
Comparison comparison1,
Comparison comparison2,
boolean smallest)
Get the comparison with the smallest (or largest) value.
|
protected Object |
getValue(QueryContext context,
StaticOperand operand)
Get the value associated with the static operand of the comparison.
|
protected void |
nullReference(List<Comparison> comparisons,
Comparison comparisonToNull)
Find all occurrences of the comparison object in the supplied list and null the list's reference to it.
|
protected void |
nullReference(List<Comparison> comparisons,
Iterable<Comparison> comparisonsToNull)
Find all references in the supplied list that match those supplied and set them to null.
|
protected Constraint |
rewrite(QueryContext context,
List<Comparison> comparisons)
Rewrite the supplied comparisons, returning the new constraint and nulling in the supplied list those comparisons that were
rewritten (and leaving those that were not rewritten)
|
String |
toString() |
protected static final Constraint CONFLICTING_CONSTRAINT
public static final RewriteAsRangeCriteria INSTANCE
public PlanNode execute(QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack)
OptimizerRule
execute
in interface OptimizerRule
context
- the context in which the query is being optimized; never nullplan
- the plan to be optimized; never nullruleStack
- the stack of rules that will be run after this rule; never nullprotected Constraint rewrite(QueryContext context, List<Comparison> comparisons)
context
- the query contextcomparisons
- the list of comparisons that sould be rewritten if possible; never nullprotected void nullReference(List<Comparison> comparisons, Comparison comparisonToNull)
comparisons
- the collection in which null references are to be placedcomparisonToNull
- the comparison that is to be found and nulled in the collectionprotected void nullReference(List<Comparison> comparisons, Iterable<Comparison> comparisonsToNull)
comparisons
- the collection in which null references are to be placedcomparisonsToNull
- the comparisons that are to be found and nulled in the collectionprotected int compareStaticOperands(QueryContext context, Comparison comparison1, Comparison comparison2)
context
- the query context; may not be nullcomparison1
- the first comparison object; may not be nullcomparison2
- the second comparison object; may not be nullprotected Comparison getComparison(QueryContext context, Comparison comparison1, Comparison comparison2, boolean smallest)
context
- the query context; may not be nullcomparison1
- the first comparison object; may not be nullcomparison2
- the second comparison object; may not be nullsmallest
- true if the comparison with the smallest value should be returned, or false otherwiseprotected Object getValue(QueryContext context, StaticOperand operand)
variable
name
, the variable value is returned.context
- the query context; may not be nulloperand
- the static operand; may not be nullCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.