org.jboss.dna.graph.query.optimize
Class ChooseJoinAlgorithm
java.lang.Object
org.jboss.dna.graph.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.
- If the condition is a
DescendantNodeJoinCondition, then the join algorithm will always be
JoinAlgorithm.NESTED_LOOP.
- 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
| |
... ...
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
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 nullplan - the plan to be optimized; never nullruleStack - the stack of rules that will be run after this rule; never null
- Returns:
- the optimized plan; never null
- See Also:
OptimizerRule.execute(org.jboss.dna.graph.query.QueryContext,
org.jboss.dna.graph.query.plan.PlanNode, java.util.LinkedList)
toString
public String toString()
-
- Overrides:
toString in class Object
- See Also:
Object.toString()
Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.