diff --git a/core/src/main/java/org/polypheny/db/algebra/BiAlg.java b/core/src/main/java/org/polypheny/db/algebra/BiAlg.java index 35b4103f94..6670f36431 100644 --- a/core/src/main/java/org/polypheny/db/algebra/BiAlg.java +++ b/core/src/main/java/org/polypheny/db/algebra/BiAlg.java @@ -37,7 +37,6 @@ import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.Value; import lombok.experimental.NonFinal; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; @@ -50,7 +49,6 @@ */ @EqualsAndHashCode(callSuper = true) @Getter -@Value @NonFinal public abstract class BiAlg extends AbstractAlgNode { diff --git a/core/src/main/java/org/polypheny/db/algebra/core/Join.java b/core/src/main/java/org/polypheny/db/algebra/core/Join.java index 07d41b6c2e..4db2fcf274 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/Join.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/Join.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.Objects; import java.util.Set; +import lombok.Getter; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.AlgWriter; import org.polypheny.db.algebra.BiAlg; @@ -69,12 +70,14 @@ */ public abstract class Join extends BiAlg { + @Getter protected final RexNode condition; protected final ImmutableSet variablesSet; /** * Values must be of enumeration {@link JoinAlgType}, except that {@link JoinAlgType#RIGHT} is disallowed. */ + @Getter protected final JoinAlgType joinType; // Next time we need to change the constructor of Join, let's change the "Set variablesStopped" parameter to "Set variablesSet". @@ -120,16 +123,6 @@ public AlgNode accept( RexShuttle shuttle ) { } - public RexNode getCondition() { - return condition; - } - - - public JoinAlgType getJoinType() { - return joinType; - } - - @Override public boolean isValid( Litmus litmus, Context context ) { if ( !super.isValid( litmus, context ) ) { @@ -260,5 +253,6 @@ public String algCompareString() { (joinType != null ? joinType.name() : "") + "&"; } + } diff --git a/core/src/main/java/org/polypheny/db/config/RuntimeConfig.java b/core/src/main/java/org/polypheny/db/config/RuntimeConfig.java index dfbe7007bf..36e203dd0c 100644 --- a/core/src/main/java/org/polypheny/db/config/RuntimeConfig.java +++ b/core/src/main/java/org/polypheny/db/config/RuntimeConfig.java @@ -837,6 +837,7 @@ public T getWithId( Class type, int id ) { } + @Getter public enum ConfigType { BOOLEAN, DECIMAL, @@ -861,7 +862,6 @@ public enum ConfigType { DOCKER_LIST( ConfigDocker.class ), PLUGIN_LIST( ConfigPlugin.class ); - @Getter private final Class clazz; diff --git a/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java b/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java index 590b95d6da..ee8ec67562 100644 --- a/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java +++ b/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java @@ -320,11 +320,11 @@ void updateImportance( AlgSubset subset, Double importance ) { void addMatch( VolcanoRuleMatch match ) { final String matchName = match.toString(); for ( PhaseMatchList matchList : matchListMap.values() ) { - if ( matchList.names.contains( matchName ) ) { + if ( !matchList.names.add( matchName ) ) { // Identical match has already been added. continue; } - matchList.names.add( matchName ); + //matchList.names.add( matchName ); String ruleClassName = match.getRule().getClass().getSimpleName(); diff --git a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java index a80ea95a6c..6b588785bc 100644 --- a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java +++ b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java @@ -186,7 +186,7 @@ public class VolcanoPlanner extends AbstractRelOptPlanner { final RuleQueue ruleQueue = new RuleQueue( this ); /** - * Holds the currently registered RelTraitDefs. + * Holds the currently registered AlgTraitDefs. */ private final List> traitDefs = new ArrayList<>(); @@ -388,6 +388,7 @@ public boolean addRule( AlgOptRule rule, VolcanoPlannerPhase phase ) { return addRule( rule ); } + @Override public boolean addRule( AlgOptRule rule ) { if ( locked ) { @@ -602,7 +603,7 @@ private void registerMetadataAlgs() { * Ensures that the subset that is the root algebra expression contains converters to all other subsets * in its equivalence set. * - * Thus the planner tries to find cheap implementations of those other subsets, which can then be converted to the root. + * Thus, the planner tries to find cheap implementations of those other subsets, which can then be converted to the root. * This is the only place in the plan where explicit converters are required; elsewhere, a consumer will be asking for * the result in a particular convention, but the root has no consumers. */ @@ -1228,7 +1229,7 @@ private AlgSubset canonize( final AlgSubset subset ) { * @param alg Algebra expression which has just been created (or maybe from the queue) * @param deferred If true, each time a rule matches, just add an entry to the queue. */ - void fireRules( AlgNode alg, boolean deferred ) { + public void fireRules( AlgNode alg, boolean deferred ) { for ( AlgOptRuleOperand operand : classOperands.get( alg.getClass() ) ) { if ( operand.matches( alg ) ) { final VolcanoRuleCall ruleCall; @@ -1249,10 +1250,19 @@ public void addRuleDuringRuntime( AlgOptRule rule ) { if ( getRuleByDescription( rule.toString() ) != null || !addRule( rule ) ) { return; } - - List> matches = new ArrayList<>(); AlgOptRuleOperand operand = rule.getOperand(); - AlgVisitor visitor = new AlgVisitor() { + + List> matches = new ArrayList<>(); + for ( AlgSet set : allSets ) { + for ( AlgNode node : set.getAlgsFromAllSubsets() ) { + if ( operand.matches( node ) ) { + matches.add( Pair.of( node, set ) ); + } + } + + } + + /*AlgVisitor visitor = new AlgVisitor() { final Set visitedSubsets = new HashSet<>(); @@ -1279,9 +1289,8 @@ public void visit( AlgNode node, int ordinal, AlgNode parent ) { } } }; - visitor.go( root ); - for ( Pair pair : matches ) { - ruleQueue.recompute( pair.right ); + visitor.go( root );*/ + for ( Pair pair : matches ) { fireRules( pair.left, true ); } diff --git a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java index dce72f93ff..0b6dd46aa0 100644 --- a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java +++ b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java @@ -117,7 +117,7 @@ public void transformTo( AlgNode alg, Map equiv ) { volcanoPlanner.listener.ruleProductionSucceeded( event ); } - // Registering the root relational expression implicitly registers its descendants. Register any explicit equivalences first, so we don't register twice and cause churn. + // Registering the root algebraic expression implicitly registers its descendants. Register any explicit equivalences first, so we don't register twice and cause churn. for ( Map.Entry entry : equiv.entrySet() ) { volcanoPlanner.ensureRegistered( entry.getKey(), entry.getValue(), this ); } diff --git a/core/src/main/java/org/polypheny/db/schema/trait/ModelTrait.java b/core/src/main/java/org/polypheny/db/schema/trait/ModelTrait.java index dbd532c8e5..16f1bbd932 100644 --- a/core/src/main/java/org/polypheny/db/schema/trait/ModelTrait.java +++ b/core/src/main/java/org/polypheny/db/schema/trait/ModelTrait.java @@ -28,6 +28,7 @@ * Model trait models the different possible "schema", also namespace models, * this is on purpose different to the {@link Convention} trait to preserve the model information on push-down of each {@link AlgNode} */ +@Getter public class ModelTrait implements AlgTrait { public static final ModelTrait RELATIONAL = new ModelTrait( NamespaceType.RELATIONAL ); @@ -36,7 +37,6 @@ public class ModelTrait implements AlgTrait { public static final ModelTrait GRAPH = new ModelTrait( NamespaceType.GRAPH ); - @Getter private final NamespaceType dataModel; diff --git a/dbms/src/test/java/org/polypheny/db/planner/PlannerTest.java b/dbms/src/test/java/org/polypheny/db/planner/PlannerTest.java index 9576809fc4..b77c35587e 100644 --- a/dbms/src/test/java/org/polypheny/db/planner/PlannerTest.java +++ b/dbms/src/test/java/org/polypheny/db/planner/PlannerTest.java @@ -35,7 +35,6 @@ import org.polypheny.db.plan.AlgOptRuleCall; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.plan.Convention; -import org.polypheny.db.plan.ConventionTraitDef; import org.polypheny.db.plan.volcano.VolcanoPlanner; import org.polypheny.db.rex.RexBuilder; import org.polypheny.db.type.PolyTypeFactoryImpl; @@ -62,40 +61,61 @@ public static void init() { public void basicTest() { VolcanoPlanner planner = new VolcanoPlanner(); + // add rule to transform to Physical planner.addRule( new PhysRule() ); - planner.addAlgTraitDef( ConventionTraitDef.INSTANCE ); + // add trait so it is known to the optimizer + planner.addAlgTraitDef( PHYS_CALLING_CONVENTION.getTraitDef() ); + + // build the nodes AlgOptCluster cluster = DummyCluster.newCluster( planner ); - AlgNode node = new NoneDummyNode( cluster, cluster.traitSetOf( Convention.NONE ) ); + AlgNode node = new LeafDummyNode( cluster, cluster.traitSetOf( Convention.NONE ) ); + AlgNode root = new SingleDummyNode( cluster, cluster.traitSetOf( Convention.NONE ), node ); - planner.setRoot( node ); + AlgNode newRoot = planner.changeTraits( root, root.getTraitSet().replace( PHYS_CALLING_CONVENTION ) ); + planner.setRoot( newRoot ); - AlgNode newAlg = planner.changeTraits( node, cluster.traitSetOf( PHYS_CALLING_CONVENTION ) ); + AlgNode newAlg = planner.findBestExp(); assert newAlg.getTraitSet().contains( PHYS_CALLING_CONVENTION ); } - public void dynamicRegister() { + @Test + public void dynamicAddRuleTest() { VolcanoPlanner planner = new VolcanoPlanner(); - planner.addRule( new PhysRule() ); - planner.addAlgTraitDef( ConventionTraitDef.INSTANCE ); + // add rule to transform to Physical + planner.addRule( new DynamicRule() ); + // add trait so it is known to the optimizer + planner.addAlgTraitDef( PHYS_CALLING_CONVENTION.getTraitDef() ); + + // build the nodes AlgOptCluster cluster = DummyCluster.newCluster( planner ); - AlgNode node = new NoneDummyNode( cluster, cluster.traitSetOf( Convention.NONE ) ); + AlgNode node = new LeafDummyNode( cluster, cluster.traitSetOf( Convention.NONE ) ); + AlgNode root = new SingleDummyNode( cluster, cluster.traitSetOf( Convention.NONE ), node ); + + AlgNode newRoot = planner.changeTraits( root, root.getTraitSet().replace( PHYS_CALLING_CONVENTION ) ); + planner.setRoot( newRoot ); + + AlgNode newAlg = planner.findBestExp(); + assert newAlg.getTraitSet().contains( PHYS_CALLING_CONVENTION ); } public static class DynamicRule extends AlgOptRule { public DynamicRule() { - super( operandJ( NoneDummyNode.class, ), description ); + super( operandJ( LeafDummyNode.class, Convention.NONE, r -> true, any() ), DynamicRule.class.getSimpleName() ); } @Override public void onMatch( AlgOptRuleCall call ) { + AlgNode alg = call.alg( 0 ); + //call.getPlanner().addRule( PhysRule.INSTANCE ); + call.getPlanner().addRule( PhysRule.INSTANCE ); } } @@ -103,8 +123,11 @@ public void onMatch( AlgOptRuleCall call ) { public static class PhysRule extends AlgOptRule { + public final static PhysRule INSTANCE = new PhysRule(); + + public PhysRule() { - super( operandJ( AbstractAlgNode.class, Convention.NONE, r -> true, any() ), AddRule.class.getSimpleName() ); + super( operandJ( AlgNode.class, Convention.NONE, r -> r instanceof LeafDummyNode || r instanceof SingleDummyNode, any() ), PhysRule.class.getSimpleName() ); } @@ -112,7 +135,13 @@ public PhysRule() { public void onMatch( AlgOptRuleCall call ) { AlgNode alg = call.alg( 0 ); - AlgNode dummy = alg.copy( alg.getTraitSet().replace( PHYS_CALLING_CONVENTION ), List.of() ); + AlgNode dummy; + if ( alg.getInputs().isEmpty() ) { + dummy = alg.copy( alg.getTraitSet().replace( PHYS_CALLING_CONVENTION ), alg.getInputs() ); + } else { + AlgNode converted = convert( alg.getInputs().get( 0 ), alg.getTraitSet().replace( PHYS_CALLING_CONVENTION ) ); + dummy = alg.copy( alg.getTraitSet().replace( PHYS_CALLING_CONVENTION ), List.of( converted ) ); + } call.transformTo( dummy ); } @@ -120,6 +149,24 @@ public void onMatch( AlgOptRuleCall call ) { } + public static class RootConverterRule extends AlgOptRule { + + public RootConverterRule() { + super( operandJ( LeafDummyNode.class, Convention.NONE, r -> true, any() ), RootConverterRule.class.getSimpleName() ); + } + + + @Override + public void onMatch( AlgOptRuleCall call ) { + AlgNode alg = call.alg( 0 ); + //AlgNode input = convert( alg.getInput( 0 ), alg.getTraitSet().replace( PHYS_CALLING_CONVENTION ) ); + + call.transformTo( new SingleDummyNode( alg.getCluster(), alg.getTraitSet().replace( PHYS_CALLING_CONVENTION ), alg ) ); + } + + } + + public static class AddRule extends AlgOptRule { public AddRule() { @@ -161,7 +208,7 @@ public AlgNode copy( AlgTraitSet traitSet, List inputs ) { @Override public AlgOptCost computeSelfCost( AlgOptPlanner planner, AlgMetadataQuery mq ) { if ( traitSet.contains( PHYS_CALLING_CONVENTION ) ) { - return planner.getCostFactory().makeCost( 1d, 1d, 1d ); + return planner.getCostFactory().makeTinyCost(); } return planner.getCostFactory().makeInfiniteCost(); } @@ -178,17 +225,17 @@ protected AlgDataType deriveRowType() { } - public static class NoneDummyNode extends AbstractAlgNode { + public static class LeafDummyNode extends AbstractAlgNode { - public NoneDummyNode( AlgOptCluster cluster, AlgTraitSet traitSet ) { + public LeafDummyNode( AlgOptCluster cluster, AlgTraitSet traitSet ) { super( cluster, traitSet ); } @Override public String algCompareString() { - return "$" + NoneDummyNode.class; + return "$" + LeafDummyNode.class; } @@ -204,14 +251,14 @@ protected AlgDataType deriveRowType() { @Override public AlgNode copy( AlgTraitSet traitSet, List inputs ) { assert inputs.isEmpty(); - return new NoneDummyNode( getCluster(), traitSet ); + return new LeafDummyNode( getCluster(), traitSet ); } @Override public AlgOptCost computeSelfCost( AlgOptPlanner planner, AlgMetadataQuery mq ) { if ( traitSet.contains( PHYS_CALLING_CONVENTION ) ) { - return planner.getCostFactory().makeCost( 1d, 1d, 1d ); + return planner.getCostFactory().makeTinyCost(); } return planner.getCostFactory().makeInfiniteCost(); } diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java index 1c9c649716..15f9d54441 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java @@ -87,9 +87,9 @@ public static JdbcConvention of( SqlDialect dialect, Expression expression, Stri @Override public void register( AlgOptPlanner planner ) { for ( AlgOptRule rule : JdbcRules.rules( this ) ) { - planner.addRule( rule ); + planner.addRuleDuringRuntime( rule ); } - planner.addRule( FilterSetOpTransposeRule.INSTANCE ); + planner.addRuleDuringRuntime( FilterSetOpTransposeRule.INSTANCE ); //planner.addRule( ProjectRemoveRule.INSTANCE ); } diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/CollationConversionTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/CollationConversionTest.java index 0bd2e0bd8b..f35a64289e 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/CollationConversionTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/CollationConversionTest.java @@ -21,7 +21,10 @@ import com.google.common.collect.ImmutableList; import java.util.List; +import lombok.Getter; +import org.junit.BeforeClass; import org.junit.Test; +import org.polypheny.db.TestHelper; import org.polypheny.db.algebra.AlgCollation; import org.polypheny.db.algebra.AlgCollationImpl; import org.polypheny.db.algebra.AlgCollationTraitDef; @@ -51,11 +54,16 @@ */ public class CollationConversionTest { + @BeforeClass + public static void init() { + TestHelper.getInstance(); + } + private static final TestRelCollationImpl LEAF_COLLATION = new TestRelCollationImpl( ImmutableList.of( new AlgFieldCollation( 0, Direction.CLUSTERED ) ) ); private static final TestRelCollationImpl ROOT_COLLATION = new TestRelCollationImpl( ImmutableList.of( new AlgFieldCollation( 0 ) ) ); - @lombok.Getter + @Getter private static final TestRelCollationTraitDef COLLATION_TRAIT_DEF = new TestRelCollationTraitDef(); diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/ComboRuleTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/ComboRuleTest.java index b909aceb15..135ae6d99f 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/ComboRuleTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/ComboRuleTest.java @@ -157,12 +157,9 @@ public boolean matches( AlgOptRuleCall call ) { return false; } - if ( call.alg( 0 ) instanceof PhysSingleAlg + return call.alg( 0 ) instanceof PhysSingleAlg && call.alg( 1 ) instanceof IntermediateNode - && call.alg( 2 ) instanceof AlgNode ) { - return true; - } - return false; + && call.alg( 2 ) != null; } diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java index fbf47b0d06..89a95f21e1 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java @@ -216,7 +216,7 @@ public void onMatch( AlgOptRuleCall call ) { LogicalAggregate alg = call.alg( 0 ); assert alg.getGroupSet().cardinality() == 1; int aggIndex = alg.getGroupSet().iterator().next(); - AlgTrait collation = AlgCollations.of( new AlgFieldCollation( aggIndex, AlgFieldCollation.Direction.ASCENDING, AlgFieldCollation.NullDirection.FIRST ) ); + AlgTrait collation = AlgCollations.of( new AlgFieldCollation( aggIndex, AlgFieldCollation.Direction.ASCENDING, AlgFieldCollation.NullDirection.FIRST ) ); AlgTraitSet desiredTraits = empty.replace( PHYSICAL ).replace( collation ); AlgNode convertedInput = convert( alg.getInput(), desiredTraits ); call.transformTo( new PhysAgg( alg.getCluster(), empty.replace( PHYSICAL ), convertedInput, alg.indicator, alg.getGroupSet(), alg.getGroupSets(), alg.getAggCallList() ) ); diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java index 96141f2ee9..c9a36314de 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java @@ -39,6 +39,7 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import java.util.List; +import lombok.Getter; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -222,7 +223,7 @@ public void testTraitPropagation() { /** * Implementation of {@link AlgTrait} for testing. */ - private static class AltTrait> implements AlgTrait { + private static class AltTrait implements AlgTrait { private final AltTraitDef traitDef; private final int ordinal; @@ -242,8 +243,8 @@ public void register( AlgOptPlanner planner ) { @Override - public T getTraitDef() { - return (T) traitDef; + public AltTraitDef getTraitDef() { + return traitDef; } public boolean equals( Object other ) { @@ -279,14 +280,14 @@ public String toString() { /** * Definition of {@link AltTrait}. */ - private static class AltTraitDef extends AlgTraitDef> { + private static class AltTraitDef extends AlgTraitDef { - private Multimap, Pair, ConverterRule>> conversionMap = HashMultimap.create(); + private final Multimap, Pair, ConverterRule>> conversions = HashMultimap.create(); @Override - public Class> getTraitClass() { - return (Class>) AltTrait.class; + public Class getTraitClass() { + return AltTrait.class; } @@ -297,7 +298,7 @@ public String getSimpleName() { @Override - public AltTrait getDefault() { + public AltTrait getDefault() { return ALT_TRAIT; } @@ -306,9 +307,9 @@ public AltTrait getDefault() { public AlgNode convert( AlgOptPlanner planner, AlgNode alg, AltTrait toTrait, boolean allowInfiniteCostConverters ) { AlgTrait fromTrait = alg.getTraitSet().getTrait( this ); - if ( conversionMap.containsKey( fromTrait ) ) { + if ( conversions.containsKey( fromTrait ) ) { final AlgMetadataQuery mq = AlgMetadataQuery.instance(); - for ( Pair, ConverterRule> traitAndRule : conversionMap.get( fromTrait ) ) { + for ( Pair, ConverterRule> traitAndRule : conversions.get( fromTrait ) ) { AlgTrait trait = traitAndRule.left; ConverterRule rule = traitAndRule.right; @@ -329,8 +330,8 @@ public AlgNode convert( AlgOptPlanner planner, AlgNode alg, AltTrait toTrait, bo @Override public boolean canConvert( AlgOptPlanner planner, AltTrait fromTrait, AltTrait toTrait ) { - if ( conversionMap.containsKey( fromTrait ) ) { - for ( Pair traitAndRule : conversionMap.get( fromTrait ) ) { + if ( conversions.containsKey( fromTrait ) ) { + for ( Pair, ConverterRule> traitAndRule : conversions.get( fromTrait ) ) { if ( traitAndRule.left == toTrait ) { return true; } @@ -347,10 +348,10 @@ public void registerConverterRule( AlgOptPlanner planner, ConverterRule converte return; } - AlgTrait fromTrait = converterRule.getInTrait(); - AlgTrait toTrait = converterRule.getOutTrait(); + AlgTrait fromTrait = converterRule.getInTrait(); + AlgTrait toTrait = converterRule.getOutTrait(); - conversionMap.put( fromTrait, Pair.of( toTrait, converterRule ) ); + conversions.put( fromTrait, Pair.of( toTrait, converterRule ) ); } } @@ -359,9 +360,10 @@ public void registerConverterRule( AlgOptPlanner planner, ConverterRule converte /** * A relational expression with zero inputs. */ + @Getter private abstract static class TestLeafRel extends AbstractAlgNode { - private String label; + private final String label; protected TestLeafRel( AlgOptCluster cluster, AlgTraitSet traits, String label ) { @@ -370,11 +372,6 @@ protected TestLeafRel( AlgOptCluster cluster, AlgTraitSet traits, String label ) } - public String getLabel() { - return label; - } - - // implement AlgNode @Override public AlgOptCost computeSelfCost( AlgOptPlanner planner, AlgMetadataQuery mq ) { @@ -586,7 +583,7 @@ public Convention getOutConvention() { @Override - public AlgTrait getOutTrait() { + public AlgTrait getOutTrait() { return getOutConvention(); } @@ -622,7 +619,7 @@ public Convention getOutConvention() { @Override - public AlgTrait getOutTrait() { + public AlgTrait getOutTrait() { return getOutConvention(); } @@ -647,7 +644,7 @@ public void onMatch( AlgOptRuleCall call ) { */ private static class AltTraitConverterRule extends ConverterRule { - private final AlgTrait toTrait; + private final AlgTrait toTrait; private AltTraitConverterRule( AltTrait fromTrait, AltTrait toTrait, String description ) { @@ -675,10 +672,10 @@ public boolean isGuaranteed() { */ private static class AltTraitConverter extends ConverterImpl { - private final AlgTrait toTrait; + private final AlgTrait toTrait; - private AltTraitConverter( AlgOptCluster cluster, AlgNode child, AlgTrait toTrait ) { + private AltTraitConverter( AlgOptCluster cluster, AlgNode child, AlgTrait toTrait ) { super( cluster, toTrait.getTraitDef(), child.getTraitSet().replace( toTrait ), child ); this.toTrait = toTrait; }