Class RelTraitDef<T extends RelTrait>

java.lang.Object
org.apache.calcite.plan.RelTraitDef<T>
Type Parameters:
T - Trait that this trait definition is based upon
Direct Known Subclasses:
ConventionTraitDef, RelCollationTraitDef, RelDistributionTraitDef

public abstract class RelTraitDef<T extends RelTrait> 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.

  • Constructor Details

    • RelTraitDef

      protected RelTraitDef()
  • Method Details

    • multiple

      public boolean multiple()
      Whether a relational expression may possess more than one instance of this trait simultaneously.

      A subset has only one instance of a trait.

    • getTraitClass

      public abstract Class<T> 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(org.apache.calcite.rel.RelWriter)).
    • canonize

      public final T canonize(T 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 @Nullable RelNode convert(RelOptPlanner planner, RelNode rel, T 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 allowed
      Returns:
      a converted RelNode or null if conversion is not possible
    • canConvert

      public abstract boolean canConvert(RelOptPlanner planner, T fromTrait, T 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 convert 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 de-registered from a RelOptPlanner. The default implementation does nothing.
      Parameters:
      planner - the planner registering the rule
      converterRule - the registered converter rule
    • getDefault

      public abstract T getDefault()
      Returns the default member of this trait.