You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/18 13:01:49 UTC

[GitHub] [doris] jackwener opened a new pull request, #13449: [WIP-feature](Nereids): join reorder greedy and Graph for join cluster.

jackwener opened a new pull request, #13449:
URL: https://github.com/apache/doris/pull/13449

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [x] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [x] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [x] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [x] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [x] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13449: [feature](Nereids): HyperGraph data struct.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13449:
URL: https://github.com/apache/doris/pull/13449#issuecomment-1289944530

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] jackwener closed pull request #13449: [feature](Nereids): HyperGraph data struct.

Posted by GitBox <gi...@apache.org>.
jackwener closed pull request #13449: [feature](Nereids): HyperGraph data struct.
URL: https://github.com/apache/doris/pull/13449


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] XieJiann commented on a diff in pull request #13449: [WIP-feature](Nereids): join reorder greedy and Graph for join cluster.

Posted by GitBox <gi...@apache.org>.
XieJiann commented on code in PR #13449:
URL: https://github.com/apache/doris/pull/13449#discussion_r998881394


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/join/JoinReorderGreedy.java:
##########
@@ -0,0 +1,136 @@
+// 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.doris.nereids.rules.join;
+
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Greedy Heuristics Join Reorder.
+ */
+public class JoinReorderGreedy {
+
+    HyperGraph graph;
+
+    public JoinReorderGreedy(HyperGraph graph) {
+        this.graph = graph;
+    }
+
+    /**
+     * A Group Plan which contains multiple plans.
+     */
+    public class PlanGroupSet {
+        List<Integer> nodes = Lists.newArrayList();
+        BitSet nodesBitSet = new BitSet(32);
+        List<List<Integer>> edges = Lists.newArrayList();
+        double lowestCost = Double.MAX_VALUE;
+        long rowCount = -1;
+
+        public PlanGroupSet(Integer firstInput) {
+            this.nodes.add(firstInput);
+            this.nodesBitSet.set(firstInput);
+        }
+
+        public void addPlan(int newPlan, double lowestCost) {
+            this.edges.add(graph.findEdges(nodesBitSet, newPlan));
+            this.nodes.add(newPlan);
+            this.nodesBitSet.set(newPlan);
+            this.lowestCost = lowestCost;
+        }
+
+        /**
+         * Convert to Plan tree.
+         */
+        public Plan toPlan() {
+            Plan left;
+            left = graph.plan(nodes.get(0));
+            for (int i = 1; i < nodes.size(); i++) {
+                int rightIndex = nodes.get(i);
+                List<Integer> edgeIndex = edges.get(i - 1);
+                left = new LogicalJoin<>(
+                        graph.joinTypes(edgeIndex.get(0)),
+                        graph.conditions(edgeIndex),
+                        left,
+                        graph.plan(rightIndex)
+                );
+            }
+
+            return left;
+        }
+    }
+
+    /**
+     * do greedy.
+     */
+    public PlanGroupSet greedy() {
+        List<PlanGroupSet> result = new ArrayList<>(graph.nodes().size());
+        for (int i = 0; i < graph.nodes().size(); i++) {
+            // i as starting left plannode.
+            // For each starting left plannode, do greedy selection。
+            PlanGroupSet leftPlanGroupSet = new PlanGroupSet(i);
+            result.add(leftPlanGroupSet);
+
+            findLowestCostRight(leftPlanGroupSet);
+        }
+
+        return result.stream()
+                .min(Comparator.comparingDouble(a -> a.lowestCost))
+                .orElseThrow(() -> new RuntimeException("don't exist best plan."));
+    }
+
+    private void findLowestCostRight(PlanGroupSet leftPlans) {
+        if (leftPlans.nodes.size() == graph.nodes().size()) {
+            return;
+        }
+        BitSet rightCandidates = leftPlans.nodes.stream()
+                .map(left -> graph.nodes().get(left).simpleNeighborhood)
+                .reduce(new BitSet(), (lhs, rhs) -> {
+                    lhs.or(rhs);
+                    return lhs;
+                });
+        rightCandidates.andNot(leftPlans.nodesBitSet);
+
+        int right = -1;
+        double lowestCost = Double.MAX_VALUE;
+
+        for (int rightCandidate = rightCandidates.nextSetBit(0); rightCandidate != -1;
+                rightCandidate = rightCandidates.nextSetBit(rightCandidate + 1)) {
+            double cost = getCost(leftPlans, right);
+            if (cost <= lowestCost) {
+                right = rightCandidate;
+            }

Review Comment:
   We can stop this recursion if the cost is greater than the cost of previous PlanGroupSet



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13449: [feature](Nereids): HyperGraph data struct.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13449:
URL: https://github.com/apache/doris/pull/13449#issuecomment-1289944504

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] XieJiann commented on a diff in pull request #13449: [WIP-feature](Nereids): join reorder greedy and Graph for join cluster.

Posted by GitBox <gi...@apache.org>.
XieJiann commented on code in PR #13449:
URL: https://github.com/apache/doris/pull/13449#discussion_r998881394


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/join/JoinReorderGreedy.java:
##########
@@ -0,0 +1,136 @@
+// 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.doris.nereids.rules.join;
+
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Greedy Heuristics Join Reorder.
+ */
+public class JoinReorderGreedy {
+
+    HyperGraph graph;
+
+    public JoinReorderGreedy(HyperGraph graph) {
+        this.graph = graph;
+    }
+
+    /**
+     * A Group Plan which contains multiple plans.
+     */
+    public class PlanGroupSet {
+        List<Integer> nodes = Lists.newArrayList();
+        BitSet nodesBitSet = new BitSet(32);
+        List<List<Integer>> edges = Lists.newArrayList();
+        double lowestCost = Double.MAX_VALUE;
+        long rowCount = -1;
+
+        public PlanGroupSet(Integer firstInput) {
+            this.nodes.add(firstInput);
+            this.nodesBitSet.set(firstInput);
+        }
+
+        public void addPlan(int newPlan, double lowestCost) {
+            this.edges.add(graph.findEdges(nodesBitSet, newPlan));
+            this.nodes.add(newPlan);
+            this.nodesBitSet.set(newPlan);
+            this.lowestCost = lowestCost;
+        }
+
+        /**
+         * Convert to Plan tree.
+         */
+        public Plan toPlan() {
+            Plan left;
+            left = graph.plan(nodes.get(0));
+            for (int i = 1; i < nodes.size(); i++) {
+                int rightIndex = nodes.get(i);
+                List<Integer> edgeIndex = edges.get(i - 1);
+                left = new LogicalJoin<>(
+                        graph.joinTypes(edgeIndex.get(0)),
+                        graph.conditions(edgeIndex),
+                        left,
+                        graph.plan(rightIndex)
+                );
+            }
+
+            return left;
+        }
+    }
+
+    /**
+     * do greedy.
+     */
+    public PlanGroupSet greedy() {
+        List<PlanGroupSet> result = new ArrayList<>(graph.nodes().size());
+        for (int i = 0; i < graph.nodes().size(); i++) {
+            // i as starting left plannode.
+            // For each starting left plannode, do greedy selection。
+            PlanGroupSet leftPlanGroupSet = new PlanGroupSet(i);
+            result.add(leftPlanGroupSet);
+
+            findLowestCostRight(leftPlanGroupSet);
+        }
+
+        return result.stream()
+                .min(Comparator.comparingDouble(a -> a.lowestCost))
+                .orElseThrow(() -> new RuntimeException("don't exist best plan."));
+    }
+
+    private void findLowestCostRight(PlanGroupSet leftPlans) {
+        if (leftPlans.nodes.size() == graph.nodes().size()) {
+            return;
+        }
+        BitSet rightCandidates = leftPlans.nodes.stream()
+                .map(left -> graph.nodes().get(left).simpleNeighborhood)
+                .reduce(new BitSet(), (lhs, rhs) -> {
+                    lhs.or(rhs);
+                    return lhs;
+                });
+        rightCandidates.andNot(leftPlans.nodesBitSet);
+
+        int right = -1;
+        double lowestCost = Double.MAX_VALUE;
+
+        for (int rightCandidate = rightCandidates.nextSetBit(0); rightCandidate != -1;
+                rightCandidate = rightCandidates.nextSetBit(rightCandidate + 1)) {
+            double cost = getCost(leftPlans, right);
+            if (cost <= lowestCost) {
+                right = rightCandidate;
+            }

Review Comment:
   We can stop this recursion if the cost is greater than the lower cost of previous PlanGroupSet



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] XieJiann commented on a diff in pull request #13449: [WIP-feature](Nereids): join reorder greedy and Graph for join cluster.

Posted by GitBox <gi...@apache.org>.
XieJiann commented on code in PR #13449:
URL: https://github.com/apache/doris/pull/13449#discussion_r998881394


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/join/JoinReorderGreedy.java:
##########
@@ -0,0 +1,136 @@
+// 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.doris.nereids.rules.join;
+
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Greedy Heuristics Join Reorder.
+ */
+public class JoinReorderGreedy {
+
+    HyperGraph graph;
+
+    public JoinReorderGreedy(HyperGraph graph) {
+        this.graph = graph;
+    }
+
+    /**
+     * A Group Plan which contains multiple plans.
+     */
+    public class PlanGroupSet {
+        List<Integer> nodes = Lists.newArrayList();
+        BitSet nodesBitSet = new BitSet(32);
+        List<List<Integer>> edges = Lists.newArrayList();
+        double lowestCost = Double.MAX_VALUE;
+        long rowCount = -1;
+
+        public PlanGroupSet(Integer firstInput) {
+            this.nodes.add(firstInput);
+            this.nodesBitSet.set(firstInput);
+        }
+
+        public void addPlan(int newPlan, double lowestCost) {
+            this.edges.add(graph.findEdges(nodesBitSet, newPlan));
+            this.nodes.add(newPlan);
+            this.nodesBitSet.set(newPlan);
+            this.lowestCost = lowestCost;
+        }
+
+        /**
+         * Convert to Plan tree.
+         */
+        public Plan toPlan() {
+            Plan left;
+            left = graph.plan(nodes.get(0));
+            for (int i = 1; i < nodes.size(); i++) {
+                int rightIndex = nodes.get(i);
+                List<Integer> edgeIndex = edges.get(i - 1);
+                left = new LogicalJoin<>(
+                        graph.joinTypes(edgeIndex.get(0)),
+                        graph.conditions(edgeIndex),
+                        left,
+                        graph.plan(rightIndex)
+                );
+            }
+
+            return left;
+        }
+    }
+
+    /**
+     * do greedy.
+     */
+    public PlanGroupSet greedy() {
+        List<PlanGroupSet> result = new ArrayList<>(graph.nodes().size());
+        for (int i = 0; i < graph.nodes().size(); i++) {
+            // i as starting left plannode.
+            // For each starting left plannode, do greedy selection。
+            PlanGroupSet leftPlanGroupSet = new PlanGroupSet(i);
+            result.add(leftPlanGroupSet);
+
+            findLowestCostRight(leftPlanGroupSet);
+        }
+
+        return result.stream()
+                .min(Comparator.comparingDouble(a -> a.lowestCost))
+                .orElseThrow(() -> new RuntimeException("don't exist best plan."));
+    }
+
+    private void findLowestCostRight(PlanGroupSet leftPlans) {
+        if (leftPlans.nodes.size() == graph.nodes().size()) {
+            return;
+        }
+        BitSet rightCandidates = leftPlans.nodes.stream()
+                .map(left -> graph.nodes().get(left).simpleNeighborhood)
+                .reduce(new BitSet(), (lhs, rhs) -> {
+                    lhs.or(rhs);
+                    return lhs;
+                });
+        rightCandidates.andNot(leftPlans.nodesBitSet);
+
+        int right = -1;
+        double lowestCost = Double.MAX_VALUE;
+
+        for (int rightCandidate = rightCandidates.nextSetBit(0); rightCandidate != -1;
+                rightCandidate = rightCandidates.nextSetBit(rightCandidate + 1)) {
+            double cost = getCost(leftPlans, right);
+            if (cost <= lowestCost) {
+                right = rightCandidate;
+            }

Review Comment:
   We can stop this recursion if the cost is greater than the cost of previous plan in PlanGroupSet



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] hello-stephen commented on pull request #13449: [feature](Nereids): HyperGraph data struct.

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13449:
URL: https://github.com/apache/doris/pull/13449#issuecomment-1289219335

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 40.65 seconds
    load time: 591 seconds
    storage size: 17154768746 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221024233420_clickbench_pr_33271.html


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] jackwener commented on a diff in pull request #13449: [WIP-feature](Nereids): join reorder greedy and Graph for join cluster.

Posted by GitBox <gi...@apache.org>.
jackwener commented on code in PR #13449:
URL: https://github.com/apache/doris/pull/13449#discussion_r1000079412


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/join/JoinReorderGreedy.java:
##########
@@ -0,0 +1,136 @@
+// 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.doris.nereids.rules.join;
+
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Greedy Heuristics Join Reorder.
+ */
+public class JoinReorderGreedy {
+
+    HyperGraph graph;
+
+    public JoinReorderGreedy(HyperGraph graph) {
+        this.graph = graph;
+    }
+
+    /**
+     * A Group Plan which contains multiple plans.
+     */
+    public class PlanGroupSet {
+        List<Integer> nodes = Lists.newArrayList();
+        BitSet nodesBitSet = new BitSet(32);
+        List<List<Integer>> edges = Lists.newArrayList();
+        double lowestCost = Double.MAX_VALUE;
+        long rowCount = -1;
+
+        public PlanGroupSet(Integer firstInput) {
+            this.nodes.add(firstInput);
+            this.nodesBitSet.set(firstInput);
+        }
+
+        public void addPlan(int newPlan, double lowestCost) {
+            this.edges.add(graph.findEdges(nodesBitSet, newPlan));
+            this.nodes.add(newPlan);
+            this.nodesBitSet.set(newPlan);
+            this.lowestCost = lowestCost;
+        }
+
+        /**
+         * Convert to Plan tree.
+         */
+        public Plan toPlan() {
+            Plan left;
+            left = graph.plan(nodes.get(0));
+            for (int i = 1; i < nodes.size(); i++) {
+                int rightIndex = nodes.get(i);
+                List<Integer> edgeIndex = edges.get(i - 1);
+                left = new LogicalJoin<>(
+                        graph.joinTypes(edgeIndex.get(0)),
+                        graph.conditions(edgeIndex),
+                        left,
+                        graph.plan(rightIndex)
+                );
+            }
+
+            return left;
+        }
+    }
+
+    /**
+     * do greedy.
+     */
+    public PlanGroupSet greedy() {
+        List<PlanGroupSet> result = new ArrayList<>(graph.nodes().size());
+        for (int i = 0; i < graph.nodes().size(); i++) {
+            // i as starting left plannode.
+            // For each starting left plannode, do greedy selection。
+            PlanGroupSet leftPlanGroupSet = new PlanGroupSet(i);
+            result.add(leftPlanGroupSet);
+
+            findLowestCostRight(leftPlanGroupSet);
+        }
+
+        return result.stream()
+                .min(Comparator.comparingDouble(a -> a.lowestCost))
+                .orElseThrow(() -> new RuntimeException("don't exist best plan."));
+    }
+
+    private void findLowestCostRight(PlanGroupSet leftPlans) {
+        if (leftPlans.nodes.size() == graph.nodes().size()) {
+            return;
+        }
+        BitSet rightCandidates = leftPlans.nodes.stream()
+                .map(left -> graph.nodes().get(left).simpleNeighborhood)
+                .reduce(new BitSet(), (lhs, rhs) -> {
+                    lhs.or(rhs);
+                    return lhs;
+                });
+        rightCandidates.andNot(leftPlans.nodesBitSet);
+
+        int right = -1;
+        double lowestCost = Double.MAX_VALUE;
+
+        for (int rightCandidate = rightCandidates.nextSetBit(0); rightCandidate != -1;
+                rightCandidate = rightCandidates.nextSetBit(rightCandidate + 1)) {
+            double cost = getCost(leftPlans, right);
+            if (cost <= lowestCost) {
+                right = rightCandidate;
+            }

Review Comment:
   It's just children compare children, no means that whole plans.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org