Package org.apache.calcite.plan
Class ConventionTraitDef
- java.lang.Object
-
- org.apache.calcite.plan.RelTraitDef<Convention>
-
- org.apache.calcite.plan.ConventionTraitDef
-
public class ConventionTraitDef extends RelTraitDef<Convention>
Definition of the the convention trait. A new set of conversion information is created for each planner that registers at least oneConverterRule
instance.Conversion data is held in a
LoadingCache
with weak keys 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 toConverterRule
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ConventionTraitDef.ConversionData
Workspace for converting from one convention to another.
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.cache.LoadingCache<RelOptPlanner,ConventionTraitDef.ConversionData>
conversionCache
Weak-key cache of RelOptPlanner to ConversionData.static ConventionTraitDef
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description private
ConventionTraitDef()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvert(RelOptPlanner planner, Convention fromConvention, Convention toConvention)
Tests whether the given RelTrait can be converted to another RelTrait.private RelNode
changeConvention(RelNode rel, Convention source, Convention target, com.google.common.collect.Multimap<Pair<Convention,Convention>,ConverterRule> mapArcToConverterRule)
Tries to convert a relational expression to the target convention of an arc.RelNode
convert(RelOptPlanner planner, RelNode rel, Convention toConvention, boolean allowInfiniteCostConverters)
Converts the given RelNode to the given RelTrait.void
deregisterConverterRule(RelOptPlanner planner, ConverterRule converterRule)
Provides notification that a particularConverterRule
has been de-registered from aRelOptPlanner
.private ConventionTraitDef.ConversionData
getConversionData(RelOptPlanner planner)
Convention
getDefault()
Returns the default member of this trait.java.lang.String
getSimpleName()
java.lang.Class<Convention>
getTraitClass()
void
registerConverterRule(RelOptPlanner planner, ConverterRule converterRule)
Provides notification of the registration of a particularConverterRule
with aRelOptPlanner
.-
Methods inherited from class org.apache.calcite.plan.RelTraitDef
canConvert, canonize, multiple
-
-
-
-
Field Detail
-
INSTANCE
public static final ConventionTraitDef INSTANCE
-
conversionCache
private final com.google.common.cache.LoadingCache<RelOptPlanner,ConventionTraitDef.ConversionData> conversionCache
Weak-key cache of RelOptPlanner to ConversionData. The idea is that when the planner goes away, so does the cache entry.
-
-
Method Detail
-
getTraitClass
public java.lang.Class<Convention> getTraitClass()
- Specified by:
getTraitClass
in classRelTraitDef<Convention>
- Returns:
- the specific RelTrait type associated with this RelTraitDef.
-
getSimpleName
public java.lang.String getSimpleName()
- Specified by:
getSimpleName
in classRelTraitDef<Convention>
- Returns:
- a simple name for this RelTraitDef (for use in
RelNode.explain(org.apache.calcite.rel.RelWriter)
).
-
getDefault
public Convention getDefault()
Description copied from class:RelTraitDef
Returns the default member of this trait.- Specified by:
getDefault
in classRelTraitDef<Convention>
-
registerConverterRule
public void registerConverterRule(RelOptPlanner planner, ConverterRule converterRule)
Description copied from class:RelTraitDef
Provides notification of the registration of a particularConverterRule
with aRelOptPlanner
. The default implementation does nothing.- Overrides:
registerConverterRule
in classRelTraitDef<Convention>
- Parameters:
planner
- the planner registering the ruleconverterRule
- the registered converter rule
-
deregisterConverterRule
public void deregisterConverterRule(RelOptPlanner planner, ConverterRule converterRule)
Description copied from class:RelTraitDef
Provides notification that a particularConverterRule
has been de-registered from aRelOptPlanner
. The default implementation does nothing.- Overrides:
deregisterConverterRule
in classRelTraitDef<Convention>
- Parameters:
planner
- the planner registering the ruleconverterRule
- the registered converter rule
-
convert
public RelNode convert(RelOptPlanner planner, RelNode rel, Convention toConvention, boolean allowInfiniteCostConverters)
Description copied from class:RelTraitDef
Converts the given RelNode to the given RelTrait.- Specified by:
convert
in classRelTraitDef<Convention>
- Parameters:
planner
- the planner requesting the conversionrel
- RelNode to converttoConvention
- RelTrait to convert toallowInfiniteCostConverters
- flag indicating whether infinite cost converters are allowed- Returns:
- a converted RelNode or null if conversion is not possible
-
changeConvention
private RelNode changeConvention(RelNode rel, Convention source, Convention target, com.google.common.collect.Multimap<Pair<Convention,Convention>,ConverterRule> mapArcToConverterRule)
Tries to convert a relational expression to the target convention of an arc.
-
canConvert
public boolean canConvert(RelOptPlanner planner, Convention fromConvention, Convention toConvention)
Description copied from class:RelTraitDef
Tests whether the given RelTrait can be converted to another RelTrait.- Specified by:
canConvert
in classRelTraitDef<Convention>
- Parameters:
planner
- the planner requesting the conversion testfromConvention
- the RelTrait to convert fromtoConvention
- the RelTrait to convert to- Returns:
- true if fromTrait can be converted to toTrait
-
getConversionData
private ConventionTraitDef.ConversionData getConversionData(RelOptPlanner planner)
-
-