From 4754ccf16b88a7a17d44189fdde554d09d329021 Mon Sep 17 00:00:00 2001 From: morrySnow <101034200+morrySnow@users.noreply.github.com> Date: Mon, 24 Oct 2022 10:33:24 +0800 Subject: [PATCH] [refactor](Nereids) remove useless explaration job in cascades framework (#13545) --- .../nereids/jobs/cascades/ApplyRuleJob.java | 7 -- .../cascades/ExploreGroupExpressionJob.java | 66 ------------------- .../jobs/cascades/ExploreGroupJob.java | 53 --------------- 3 files changed, 126 deletions(-) delete mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupExpressionJob.java delete mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupJob.java diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ApplyRuleJob.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ApplyRuleJob.java index 15d044cc92..f596635fc2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ApplyRuleJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ApplyRuleJob.java @@ -36,7 +36,6 @@ import java.util.List; public class ApplyRuleJob extends Job { private final GroupExpression groupExpression; private final Rule rule; - private final boolean exploredOnly; /** * Constructor of ApplyRuleJob. @@ -49,7 +48,6 @@ public class ApplyRuleJob extends Job { super(JobType.APPLY_RULE, context); this.groupExpression = groupExpression; this.rule = rule; - this.exploredOnly = false; } @Override @@ -73,11 +71,6 @@ public class ApplyRuleJob extends Job { GroupExpression newGroupExpression = result.correspondingExpression; if (newPlan instanceof LogicalPlan) { - if (exploredOnly) { - pushJob(new ExploreGroupExpressionJob(newGroupExpression, context)); - pushJob(new DeriveStatsJob(newGroupExpression, context)); - continue; - } pushJob(new OptimizeGroupExpressionJob(newGroupExpression, context)); pushJob(new DeriveStatsJob(newGroupExpression, context)); } else { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupExpressionJob.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupExpressionJob.java deleted file mode 100644 index bc2f4df9cf..0000000000 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupExpressionJob.java +++ /dev/null @@ -1,66 +0,0 @@ -// 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.jobs.cascades; - -import org.apache.doris.nereids.jobs.Job; -import org.apache.doris.nereids.jobs.JobContext; -import org.apache.doris.nereids.jobs.JobType; -import org.apache.doris.nereids.memo.Group; -import org.apache.doris.nereids.memo.GroupExpression; -import org.apache.doris.nereids.pattern.Pattern; -import org.apache.doris.nereids.rules.Rule; - -import java.util.Comparator; -import java.util.List; - -/** - * Job to explore {@link GroupExpression} in {@link org.apache.doris.nereids.memo.Memo}. - */ -public class ExploreGroupExpressionJob extends Job { - private final GroupExpression groupExpression; - - /** - * Constructor for ExplorePlanJob. - * - * @param groupExpression {@link GroupExpression} to be explored - * @param context context of current job - */ - public ExploreGroupExpressionJob(GroupExpression groupExpression, JobContext context) { - super(JobType.EXPLORE_PLAN, context); - this.groupExpression = groupExpression; - } - - @Override - public void execute() { - // TODO: enable exploration job after we test it - List explorationRules = getRuleSet().getExplorationRules(); - List validRules = getValidRules(groupExpression, explorationRules); - validRules.sort(Comparator.comparingInt(o -> o.getRulePromise().promise())); - - for (Rule rule : validRules) { - pushJob(new ApplyRuleJob(groupExpression, rule, context)); - for (int i = 0; i < rule.getPattern().children().size(); ++i) { - Pattern childPattern = rule.getPattern().child(i); - if (childPattern.arity() > 0 && !childPattern.isGroup()) { - Group child = groupExpression.child(i); - pushJob(new ExploreGroupJob(child, context)); - } - } - } - } -} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupJob.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupJob.java deleted file mode 100644 index 1c5844dc07..0000000000 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ExploreGroupJob.java +++ /dev/null @@ -1,53 +0,0 @@ -// 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.jobs.cascades; - -import org.apache.doris.nereids.jobs.Job; -import org.apache.doris.nereids.jobs.JobContext; -import org.apache.doris.nereids.jobs.JobType; -import org.apache.doris.nereids.memo.Group; -import org.apache.doris.nereids.memo.GroupExpression; - -/** - * Job to explore {@link Group} in {@link org.apache.doris.nereids.memo.Memo}. - */ -public class ExploreGroupJob extends Job { - private final Group group; - - /** - * Constructor for ExploreGroupJob. - * - * @param group {@link Group} to be explored - * @param context context of current job - */ - public ExploreGroupJob(Group group, JobContext context) { - super(JobType.EXPLORE_PLAN_SET, context); - this.group = group; - } - - @Override - public void execute() { - if (group.isExplored()) { - return; - } - for (GroupExpression groupExpression : group.getLogicalExpressions()) { - pushJob(new ExploreGroupExpressionJob(groupExpression, context)); - } - group.setExplored(true); - } -}