org.eigenbase.test
Class MockRelOptPlanner

java.lang.Object
  extended by org.eigenbase.relopt.AbstractRelOptPlanner
      extended by org.eigenbase.test.MockRelOptPlanner
All Implemented Interfaces:
RelOptPlanner

public class MockRelOptPlanner
extends AbstractRelOptPlanner

MockRelOptPlanner is a mock implementation of the RelOptPlanner interface.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/test/MockRelOptPlanner.java#18 $
Author:
John V. Sichi

Nested Class Summary
private  class MockRelOptPlanner.MockRuleCall
           
 
Field Summary
private  RelNode root
           
private  RelOptRule rule
           
private  RelNode transformationResult
           
 
Fields inherited from interface org.eigenbase.relopt.RelOptPlanner
tracer
 
Constructor Summary
MockRelOptPlanner()
           
 
Method Summary
 boolean addRule(RelOptRule rule)
          Registers a rule.
 RelNode changeTraits(RelNode rel, RelTraitSet toTraits)
          Changes a relational expression to an equivalent one with a different set of traits.
 RelNode ensureRegistered(RelNode rel, RelNode equivRel)
          Registers a relational expression if it is not already registered.
 RelNode findBestExp()
          Finds the most efficient expression to implement this query.
 RelNode getRoot()
          Returns the root node of this query.
 boolean isRegistered(RelNode rel)
          Determines whether a relational expression has been registered.
private  boolean match(RelOptRuleOperand operand, RelNode rel, List<RelNode> bindings)
          Matches a relational expression to a rule.
private  boolean matchRecursive(RelNode rel, RelNode parent, int ordinalInParent)
          Recursively matches a rule.
 RelNode register(RelNode rel, RelNode equivRel)
          Registers a relational expression in the expression bank.
 boolean removeRule(RelOptRule rule)
          Removes a rule.
 void setRoot(RelNode rel)
          Sets the root node of this query.
 
Methods inherited from class org.eigenbase.relopt.AbstractRelOptPlanner
addListener, addRelTraitDef, checkCancel, chooseDelegate, fireRule, getCost, getJavaRelImplementor, getListener, getRelMetadataTimestamp, getRuleByDescription, isRuleExcluded, makeCost, makeHugeCost, makeInfiniteCost, makeTinyCost, makeZeroCost, mapRuleDescription, notifyChosen, notifyDiscard, notifyEquivalence, notifyTransformation, registerMetadataProviders, registerSchema, setCancelFlag, setImportance, setRuleDescExclusionFilter, unmapRuleDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

private RelNode root

rule

private RelOptRule rule

transformationResult

private RelNode transformationResult
Constructor Detail

MockRelOptPlanner

public MockRelOptPlanner()
Method Detail

setRoot

public void setRoot(RelNode rel)
Description copied from interface: RelOptPlanner
Sets the root node of this query.

Parameters:
rel - Relational expression

getRoot

public RelNode getRoot()
Description copied from interface: RelOptPlanner
Returns the root node of this query.

Returns:
Root node

addRule

public boolean addRule(RelOptRule rule)
Description copied from interface: RelOptPlanner
Registers a rule. If the rule has already been registered, does nothing. This method should determine if the given rule is a ConverterRule and pass the ConverterRule to all registered RelTraitDef instances.

Returns:
whether the rule was added, as per Collection.add(E)

removeRule

public boolean removeRule(RelOptRule rule)
Description copied from interface: RelOptPlanner
Removes a rule.

Returns:
true if the rule was present, as per Collection.remove(Object)

changeTraits

public RelNode changeTraits(RelNode rel,
                            RelTraitSet toTraits)
Description copied from interface: RelOptPlanner
Changes a relational expression to an equivalent one with a different set of traits.

Parameters:
rel - Relational expression, may or may not have been registered
toTraits - Trait set to convert relational expression to
Returns:
Relational expression with desired traits. Never null, but may be abstract

findBestExp

public RelNode findBestExp()
Description copied from interface: RelOptPlanner
Finds the most efficient expression to implement this query.


matchRecursive

private boolean matchRecursive(RelNode rel,
                               RelNode parent,
                               int ordinalInParent)
Recursively matches a rule.

Parameters:
rel - Relational expression
parent - Parent relational expression
ordinalInParent - Ordinal of relational expression among its siblings
Returns:
whether match occurred

match

private boolean match(RelOptRuleOperand operand,
                      RelNode rel,
                      List<RelNode> bindings)
Matches a relational expression to a rule.

Parameters:
operand - Root operand of rule
rel - Relational expression
bindings - Bindings, populated on successful match
Returns:
whether relational expression matched rule

register

public RelNode register(RelNode rel,
                        RelNode equivRel)
Description copied from interface: RelOptPlanner
Registers a relational expression in the expression bank.

After it has been registered, you may not modify it.

The expression must not already have been registered. If you are not sure whether it has been registered, call RelOptPlanner.ensureRegistered(RelNode,RelNode).

Parameters:
rel - Relational expression to register (must not already be registered)
equivRel - Relational expression it is equivalent to (may be null)
Returns:
the same expression, or an equivalent existing expression

ensureRegistered

public RelNode ensureRegistered(RelNode rel,
                                RelNode equivRel)
Description copied from interface: RelOptPlanner
Registers a relational expression if it is not already registered.

Parameters:
rel - Relational expression to register
equivRel - Relational expression it is equivalent to (may be null)
Returns:
Registered relational expression

isRegistered

public boolean isRegistered(RelNode rel)
Description copied from interface: RelOptPlanner
Determines whether a relational expression has been registered.

Parameters:
rel - expression to test
Returns:
whether rel has been registered