org.eigenbase.relopt
Class CallingConventionTraitDef

java.lang.Object
  extended by org.eigenbase.relopt.RelTraitDef
      extended by org.eigenbase.relopt.CallingConventionTraitDef

public class CallingConventionTraitDef
extends RelTraitDef

CallingConventionTraitDef is a RelTraitDef that defines the calling-convention trait. A new set of conversion information is created for each planner that registers at least one ConverterRule instance.

Conversion data is held in a WeakHashMap so that the JVM's garbage collector may reclaim the conversion data after the planner itself has been garbage collected. The conversion information consists of a graph of conversions (from one calling convention to another) and a map of graph arcs to ConverterRules.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/relopt/CallingConventionTraitDef.java#13 $
Author:
Stephan Zuercher

Nested Class Summary
private static class CallingConventionTraitDef.ConversionData
           
 
Field Summary
static CallingConventionTraitDef instance
           
private  WeakHashMap<RelOptPlanner,CallingConventionTraitDef.ConversionData> plannerConversionMap
          Weak-key map of RelOptPlanner to ConversionData.
 
Constructor Summary
private CallingConventionTraitDef()
           
 
Method Summary
 boolean canConvert(RelOptPlanner planner, RelTrait fromTrait, RelTrait toTrait)
          Tests whether the given RelTrait can be converted to another RelTrait.
private  RelNode changeConvention(RelNode rel, Graph.Arc arc, MultiMap<Graph.Arc,ConverterRule> mapArcToConverterRule)
          Tries to convert a relational expression to the target convention of an arc.
 RelNode convert(RelOptPlanner planner, RelNode rel, RelTrait toTrait, boolean allowInfiniteCostConverters)
          Converts the given RelNode to the given RelTrait.
 void deregisterConverterRule(RelOptPlanner planner, ConverterRule converterRule)
          Provides notification that a particular ConverterRule has been deregistered from a RelOptPlanner.
private  CallingConventionTraitDef.ConversionData getConversionData(RelOptPlanner planner)
           
 String getSimpleName()
           
 Class getTraitClass()
           
 void registerConverterRule(RelOptPlanner planner, ConverterRule converterRule)
          Provides notification of the registration of a particular ConverterRule with a RelOptPlanner.
 
Methods inherited from class org.eigenbase.relopt.RelTraitDef
canonize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final CallingConventionTraitDef instance

plannerConversionMap

private final WeakHashMap<RelOptPlanner,CallingConventionTraitDef.ConversionData> plannerConversionMap
Weak-key map of RelOptPlanner to ConversionData. The idea is that when the planner goes away, so does the map entry.

Constructor Detail

CallingConventionTraitDef

private CallingConventionTraitDef()
Method Detail

getTraitClass

public Class getTraitClass()
Specified by:
getTraitClass in class RelTraitDef
Returns:
the specific RelTrait type associated with this RelTraitDef.

getSimpleName

public String getSimpleName()
Specified by:
getSimpleName in class RelTraitDef
Returns:
a simple name for this RelTraitDef (for use in RelNode.explain(RelOptPlanWriter)).

registerConverterRule

public void registerConverterRule(RelOptPlanner planner,
                                  ConverterRule converterRule)
Description copied from class: RelTraitDef
Provides notification of the registration of a particular ConverterRule with a RelOptPlanner. The default implementation does nothing.

Overrides:
registerConverterRule in class RelTraitDef
Parameters:
planner - the planner registering the rule
converterRule - the registered converter rule

deregisterConverterRule

public void deregisterConverterRule(RelOptPlanner planner,
                                    ConverterRule converterRule)
Description copied from class: RelTraitDef
Provides notification that a particular ConverterRule has been deregistered from a RelOptPlanner. The default implementation does nothing.

Overrides:
deregisterConverterRule in class RelTraitDef
Parameters:
planner - the planner registering the rule
converterRule - the registered converter rule

convert

public RelNode convert(RelOptPlanner planner,
                       RelNode rel,
                       RelTrait toTrait,
                       boolean allowInfiniteCostConverters)
Description copied from class: RelTraitDef
Converts the given RelNode to the given RelTrait.

Specified by:
convert in class RelTraitDef
Parameters:
planner - the planner requesting the conversion
rel - RelNode to convert
toTrait - RelTrait to convert to
allowInfiniteCostConverters - flag indicating whether infinite cost converters are allowe
Returns:
a converted RelNode or null if conversion is not possible

changeConvention

private RelNode changeConvention(RelNode rel,
                                 Graph.Arc arc,
                                 MultiMap<Graph.Arc,ConverterRule> mapArcToConverterRule)
Tries to convert a relational expression to the target convention of an arc.


canConvert

public boolean canConvert(RelOptPlanner planner,
                          RelTrait fromTrait,
                          RelTrait toTrait)
Description copied from class: RelTraitDef
Tests whether the given RelTrait can be converted to another RelTrait.

Specified by:
canConvert in class RelTraitDef
Parameters:
planner - the planner requesting the conversion test
fromTrait - the RelTrait to convert from
toTrait - the RelTrait to conver to
Returns:
true if fromTrait can be converted to toTrait

getConversionData

private CallingConventionTraitDef.ConversionData getConversionData(RelOptPlanner planner)