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

## org.modeshape.jcr.query.optimize
Class ChooseJoinAlgorithm

    java.lang.Object
      org.modeshape.jcr.query.optimize.ChooseJoinAlgorithm

All Implemented Interfaces:
  OptimizerRule

    @Immutable
    public class ChooseJoinAlgorithm

extends Object
implements OptimizerRule

An `optimizer rule` that choose the appropriate join algorithm and sets up any prerequisites, based upon the `JoinCondition`.

There are two static instances that can be used (or the equivalent can be instantiated or subclassed using the constructor): one that only uses `nested-loop`, and another that will attempt to use `merge` where possible. Both instances ignore any existing `PlanNode.Property.JOIN_ALGORITHM` property value set on the JOIN node.

For example, the `USE_ONLY_NESTED_JOIN_ALGORITHM` instance will convert this simple tree:

              ...
               |
             JOIN
            /     \
          ...     ...

into this:

              ...
               |
             JOIN (JOIN_ALGORITHM=NESTED_LOOP)
            /     \
          ...     ...

On the other hand, the `USE_BEST_JOIN_ALGORITHM` instance will do a couple of different things, depending upon the input plan.

1. If the condition is a `DescendantNodeJoinCondition`, then the join algorithm will always be `JoinAlgorithm.NESTED_LOOP`.
2. Otherwise, the rule will use the `JoinAlgorithm.MERGE` algorithm and will change this structure:

                 ...
                  |
                JOIN
               /     \
             ...     ...

   into this:

                 ...
                  |
                JOIN (JOIN_ALGORITHM=MERGE)
               /     \
              /       \
        DUP_REMOVE  DUP_REMOVE
            |           |
           SORT       SORT
            |           |
           ...         ...

Field Summary
`static ChooseJoinAlgorithm` | `USE_BEST_JOIN_ALGORITHM`
`static ChooseJoinAlgorithm` | `USE_ONLY_NESTED_JOIN_ALGORITHM`

Constructor Summary
`protected` | `ChooseJoinAlgorithm(boolean useOnlyNested)`

Method Summary
`protected void` | `createOrderBysForJoinCondition(JoinCondition condition, Set<SelectorName> leftSelectors, List<Object> leftSortBy, Set<SelectorName> rightSelectors, List<Object> rightSortBy)`
`PlanNode` | `execute(QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack)` Optimize the supplied plan using the supplied context, hints, and yet-to-be-run rules.
`String` | `toString()`

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

Field Detail

### USE_ONLY_NESTED_JOIN_ALGORITHM

    public static final ChooseJoinAlgorithm USE_ONLY_NESTED_JOIN_ALGORITHM

### USE_BEST_JOIN_ALGORITHM

    public static final ChooseJoinAlgorithm USE_BEST_JOIN_ALGORITHM

Constructor Detail

### ChooseJoinAlgorithm

    protected ChooseJoinAlgorithm(boolean useOnlyNested)

Method Detail

### execute

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

  Description copied from interface: `OptimizerRule`
  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

### createOrderBysForJoinCondition

    protected void createOrderBysForJoinCondition(JoinCondition condition,
                                                  Set<SelectorName> leftSelectors,
                                                  List<Object> leftSortBy,
                                                  Set<SelectorName> rightSelectors,
                                                  List<Object> rightSortBy)

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

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

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