Package org.apache.calcite.plan
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
RelTraitDef represents a class of
RelTraits. Implementations of
RelTraitDef may be singletons under the following conditions:
- 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.
- Either
-
canConvert(RelOptPlanner, RelTrait, RelTrait)andconvert(RelOptPlanner, RelNode, RelTrait, boolean)do not require planner-instance-specific information, or - the RelTraitDef manages separate sets of conversion data internally. See
ConventionTraitDeffor an example of this.
-
Otherwise, a new instance of RelTraitDef must be constructed and registered with each new planner instantiated.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancanConvert(RelOptPlanner planner, T fromTrait, T toTrait) Tests whether the given RelTrait can be converted to another RelTrait.final TTakes an arbitrary RelTrait and returns the canonical representation of that RelTrait.abstract @Nullable RelNodeconvert(RelOptPlanner planner, RelNode rel, T toTrait, boolean allowInfiniteCostConverters) Converts the given RelNode to the given RelTrait.voidderegisterConverterRule(RelOptPlanner planner, ConverterRule converterRule) Provides notification that a particularConverterRulehas been de-registered from aRelOptPlanner.abstract TReturns the default member of this trait.abstract StringReturns a simple name for this RelTraitDef (for use inRelNode.explain(org.apache.calcite.rel.RelWriter)).Returns the specific RelTrait type associated with this RelTraitDef.booleanmultiple()Whether a relational expression may possess more than one instance of this trait simultaneously.voidregisterConverterRule(RelOptPlanner planner, ConverterRule converterRule) Provides notification of the registration of a particularConverterRulewith aRelOptPlanner.
-
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
Returns the specific RelTrait type associated with this RelTraitDef. -
getSimpleName
Returns a simple name for this RelTraitDef (for use inRelNode.explain(org.apache.calcite.rel.RelWriter)). -
canonize
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 conversionrel- RelNode to converttoTrait- RelTrait to convert toallowInfiniteCostConverters- flag indicating whether infinite cost converters are allowed- Returns:
- a converted RelNode or null if conversion is not possible
-
canConvert
Tests whether the given RelTrait can be converted to another RelTrait.- Parameters:
planner- the planner requesting the conversion testfromTrait- the RelTrait to convert fromtoTrait- the RelTrait to convert to- Returns:
- true if fromTrait can be converted to toTrait
-
registerConverterRule
Provides notification of the registration of a particularConverterRulewith aRelOptPlanner. The default implementation does nothing.- Parameters:
planner- the planner registering the ruleconverterRule- the registered converter rule
-
deregisterConverterRule
Provides notification that a particularConverterRulehas been de-registered from aRelOptPlanner. The default implementation does nothing.- Parameters:
planner- the planner registering the ruleconverterRule- the registered converter rule
-
getDefault
Returns the default member of this trait.
-