org.modeshape.jcr.query.optimize

## Class RuleBasedOptimizer

- java.lang.Object
- - org.modeshape.jcr.query.optimize.RuleBasedOptimizer

- All Implemented Interfaces:
    Optimizer

      @Immutable
      public class RuleBasedOptimizer
      extends Object
      implements Optimizer

  Optimizer implementation that optimizes a query using a stack of rules. Subclasses can override the `populateRuleStack(LinkedList, PlanHints)` method to define the stack of rules they'd like to use, including the use of custom rules.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RuleBasedOptimizer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PlanNode` | `optimize(QueryContext context, PlanNode plan)` Optimize the supplied query plan and produce an executable processor plan.
    `protected void` | `populateIndexingRules(LinkedList<OptimizerRule> ruleStack, PlanHints hints)` Method that is used to add the indexing rules to the rule stack.
    `protected void` | `populateRuleStack(LinkedList<OptimizerRule> ruleStack, PlanHints hints)` Method that is used to create the initial rule stack.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RuleBasedOptimizer

          public RuleBasedOptimizer()

  - ### Method Detail

    - #### optimize

          public PlanNode optimize(QueryContext context,
                          PlanNode plan)

      Description copied from interface: `Optimizer`
      Optimize the supplied query plan and produce an executable processor plan.
      Specified by:
        `optimize` in interface `Optimizer`
      Parameters:
        `context` - the context in which the query is being optimized
        `plan` - the query plan to be optimized
      Returns:
        the optimized query plan; never null

    - #### populateRuleStack

          protected void populateRuleStack(LinkedList<OptimizerRule> ruleStack,
                               PlanHints hints)

      Method that is used to create the initial rule stack. This method can be overridden by subclasses
      Parameters:
        `ruleStack` - the stack where the rules should be placed; never null
        `hints` - the plan hints

    - #### populateIndexingRules

          protected void populateIndexingRules(LinkedList<OptimizerRule> ruleStack,
                                   PlanHints hints)

      Method that is used to add the indexing rules to the rule stack. This method can be overridden by subclasses when custom indexing rules are to be used. By default, this method simply adds the `AddIndexes` rule.
      Parameters:
        `ruleStack` - the stack where the rules should be placed; never null
        `hints` - the plan hints

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