swuferhong commented on code in PR #21530:
URL: https://github.com/apache/flink/pull/21530#discussion_r1065276259


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/logical/FlinkJoinReorderRule.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.rules.logical;
+
+import org.apache.flink.table.api.config.OptimizerConfigOptions;
+import org.apache.flink.table.planner.utils.ShortcutUtils;
+
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.RelRule;
+import org.apache.calcite.rel.core.RelFactories;
+import org.apache.calcite.rel.rules.LoptOptimizeJoinRule;
+import org.apache.calcite.rel.rules.MultiJoin;
+import org.apache.calcite.rel.rules.TransformationRule;
+import org.apache.calcite.tools.RelBuilder;
+import org.apache.calcite.tools.RelBuilderFactory;
+
+/**
+ * Flink join reorder rule, which can change the join order of input relNode 
tree.
+ *
+ * <p>It is triggered by the ({@link MultiJoin}).
+ *
+ * <p>In this rule, there are two specific join reorder strategies can be 
chosen, one is {@link
+ * LoptOptimizeJoinRule}, another is {@link FlinkBushyJoinReorderRule}. Which 
rule is selected
+ * depends on the parameter {@link
+ * OptimizerConfigOptions#TABLE_OPTIMIZER_BUSHY_JOIN_REORDER_THRESHOLD}.
+ */
+public class FlinkJoinReorderRule extends RelRule<FlinkJoinReorderRule.Config>
+        implements TransformationRule {
+
+    public static final FlinkJoinReorderRule INSTANCE =
+            FlinkJoinReorderRule.Config.DEFAULT.toRule();
+
+    private static final LoptOptimizeJoinRule LOPT_JOIN_REORDER =
+            LoptOptimizeJoinRule.Config.DEFAULT.toRule();
+
+    private static final FlinkBushyJoinReorderRule BUSHY_JOIN_REORDER =
+            FlinkBushyJoinReorderRule.Config.DEFAULT.toRule();
+
+    /** Creates an SparkJoinReorderRule. */
+    protected FlinkJoinReorderRule(FlinkJoinReorderRule.Config config) {
+        super(config);
+    }
+
+    @Deprecated // to be removed before 2.0
+    public FlinkJoinReorderRule(RelBuilderFactory relBuilderFactory) {
+        this(
+                FlinkJoinReorderRule.Config.DEFAULT
+                        .withRelBuilderFactory(relBuilderFactory)
+                        .as(FlinkJoinReorderRule.Config.class));
+    }
+
+    @Deprecated // to be removed before 2.0
+    public FlinkJoinReorderRule(
+            RelFactories.JoinFactory joinFactory,
+            RelFactories.ProjectFactory projectFactory,
+            RelFactories.FilterFactory filterFactory) {
+        this(RelBuilder.proto(joinFactory, projectFactory, filterFactory));
+    }
+
+    @Override
+    public void onMatch(RelOptRuleCall call) {
+        final MultiJoin multiJoinRel = call.rel(0);
+        int numJoinInputs = multiJoinRel.getInputs().size();
+        int dpThreshold =

Review Comment:
   > nit: rename to bushyTreeThreshold ?
   
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to