Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.query.optimize
Class RewriteAsRangeCriteria

    java.lang.Object
      org.modeshape.graph.query.optimize.RewriteAsRangeCriteria

All Implemented Interfaces:
  OptimizerRule

    @Immutable
    public class RewriteAsRangeCriteria

extends Object
implements OptimizerRule

An `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.

Field Summary
`protected static Constraint` | `CONFLICTING_CONSTRAINT`
`static RewriteAsRangeCriteria` | `INSTANCE`

Constructor Summary
`RewriteAsRangeCriteria()`

Method Summary
`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()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### CONFLICTING_CONSTRAINT

    protected static final Constraint CONFLICTING_CONSTRAINT

### INSTANCE

    public static final RewriteAsRangeCriteria INSTANCE

Constructor Detail

### RewriteAsRangeCriteria

    public RewriteAsRangeCriteria()

Method Detail

### execute

    public PlanNode execute(QueryContext context,
                            PlanNode plan,
                            LinkedList<OptimizerRule> ruleStack)

  Optimize the supplied plan using the supplied context, hints, and yet-to-be-run rules.

  Specified by:
    `execute` in interface `OptimizerRule`
  Parameters:
    `context` - the context in which the query is being optimized; never null
    `plan` - the plan to be optimized; never null
    `ruleStack` - the stack of rules that will be run after this rule; never null
  Returns:
    the optimized plan; never null
  See Also:
    `OptimizerRule.execute(org.modeshape.graph.query.QueryContext, org.modeshape.graph.query.plan.PlanNode, java.util.LinkedList)`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  See Also:
    `Object.toString()`

### rewrite

    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)

  Parameters:
    `context` - the query context
    `comparisons` - the list of comparisons that sould be rewritten if possible; never null
  Returns:
    the rewritten constraint, or null if no comparisons were rewritten

### nullReference

    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.

  Parameters:
    `comparisons` - the collection in which null references are to be placed
    `comparisonToNull` - the comparison that is to be found and nulled in the collection

### nullReference

    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.

  Parameters:
    `comparisons` - the collection in which null references are to be placed
    `comparisonsToNull` - the comparisons that are to be found and nulled in the collection

### compareStaticOperands

    protected int compareStaticOperands(QueryContext context,
                                        Comparison comparison1,
                                        Comparison comparison2)

  Compare the values used in the two comparisons

  Parameters:
    `context` - the query context; may not be null
    `comparison1` - the first comparison object; may not be null
    `comparison2` - the second comparison object; may not be null
  Returns:
    0 if the values are the same, less than 0 if the first comparison's value is less than the second's, or greater than 0 if the first comparison's value is greater than the second's

### getComparison

    protected Comparison getComparison(QueryContext context,
                                       Comparison comparison1,
                                       Comparison comparison2,
                                       boolean smallest)

  Get the comparison with the smallest (or largest) value.

  Parameters:
    `context` - the query context; may not be null
    `comparison1` - the first comparison object; may not be null
    `comparison2` - the second comparison object; may not be null
    `smallest` - true if the comparison with the smallest value should be returned, or false otherwise
  Returns:
    the comparison with the smallest (or largest) value

### getValue

    protected Object getValue(QueryContext context,
                              StaticOperand operand)

  Get the value associated with the static operand of the comparison. If the operand is a `variable name`, the variable value is returned.

  Parameters:
    `context` - the query context; may not be null
    `operand` - the static operand; may not be null
  Returns:
    the value of the static operand

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.