org.eigenbase.relopt
Class RelTraitDef

java.lang.Object
  extended by org.eigenbase.relopt.RelTraitDef
Direct Known Subclasses:
CallingConventionTraitDef, VolcanoPlannerTraitTest.AltTraitDef

public abstract class RelTraitDef
extends Object

RelTraitDef represents a class of RelTraits. Implementations of RelTraitDef may be singletons under the following conditions:

  1. if the set of all possible associated RelTraits is finite and fixed (e.g. all RelTraits for this RelTraitDef are known at compile time). For example, the CallingConvention trait meets this requirement, because CallingConvention is effectively an enumeration.
  2. Either

Otherwise, a new instance of RelTraitDef must be constructed and registered with each new planner instantiated.

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

Field Summary
private  WeakHashMap<RelTrait,WeakReference<RelTrait>> canonicalMap
           
 
Constructor Summary
RelTraitDef()
           
 
Method Summary
abstract  boolean canConvert(RelOptPlanner planner, RelTrait fromTrait, RelTrait toTrait)
          Tests whether the given RelTrait can be converted to another RelTrait.
 RelTrait canonize(RelTrait trait)
          Takes an arbitrary RelTrait and returns the canonical representation of that RelTrait.
abstract  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.
abstract  String getSimpleName()
           
abstract  Class getTraitClass()
           
 void registerConverterRule(RelOptPlanner planner, ConverterRule converterRule)
          Provides notification of the registration of a particular ConverterRule with a RelOptPlanner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canonicalMap

private final WeakHashMap<RelTrait,WeakReference<RelTrait>> canonicalMap
Constructor Detail

RelTraitDef

public RelTraitDef()
Method Detail

getTraitClass

public abstract Class getTraitClass()
Returns:
the specific RelTrait type associated with this RelTraitDef.

getSimpleName

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

canonize

public final RelTrait canonize(RelTrait trait)
Takes an arbitrary RelTrait and returns the canonical representation of that RelTrait. Canonized RelTrait objects may always be compared using the equality operator (==).

If an equal RelTrait has already been canonized and is still in use, it will be returned. Otherwise, the given RelTrait is made canonical and returned.

Parameters:
trait - a possibly non-canonical RelTrait
Returns:
a canonical RelTrait.

convert

public abstract RelNode convert(RelOptPlanner planner,
                                RelNode rel,
                                RelTrait toTrait,
                                boolean allowInfiniteCostConverters)
Converts the given RelNode to the given RelTrait.

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

canConvert

public abstract boolean canConvert(RelOptPlanner planner,
                                   RelTrait fromTrait,
                                   RelTrait toTrait)
Tests whether the given RelTrait can be converted to another RelTrait.

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

registerConverterRule

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

Parameters:
planner - the planner registering the rule
converterRule - the registered converter rule

deregisterConverterRule

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

Parameters:
planner - the planner registering the rule
converterRule - the registered converter rule