morrySnow commented on code in PR #10657: URL: https://github.com/apache/doris/pull/10657#discussion_r916409080
########## fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Group.java: ########## @@ -135,6 +137,35 @@ public void setCostLowerBound(double costLowerBound) { this.costLowerBound = costLowerBound; } + /** + * Set or update lowestCostPlans: properties --> new Pair<>(cost, expression) + */ + public void setBestPlan(GroupExpression expression, double cost, PhysicalProperties properties) { Review Comment: ```suggestion public void updateBestPlan(GroupExpression expression, double cost, PhysicalProperties properties) { ``` furthermore, this setter, function use plan as name, but getter function use expression instead ########## fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/JobContext.java: ########## @@ -26,7 +26,7 @@ public class JobContext { private final PlannerContext plannerContext; private final PhysicalProperties requiredProperties; - private final double costUpperBound; + private double costUpperBound; Review Comment: if we need update cost upper bound, the better way is generate a new `JobContext` with new upper bound. If we only use one `JobContext` in all job of cascades, you need a stack to save cost status carefully ########## fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalDistribution.java: ########## @@ -0,0 +1,42 @@ +// 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.operators.plans.physical; + +import org.apache.doris.nereids.operators.OperatorType; +import org.apache.doris.nereids.properties.DistributionSpec; +import org.apache.doris.nereids.trees.expressions.Expression; + +import java.util.List; + +/** + * Enforcer operator. + */ +public class PhysicalDistribution extends PhysicalUnaryOperator { + + protected DistributionSpec distributionSpec; + + + public PhysicalDistribution(DistributionSpec spec) { + super(OperatorType.PHYSICAL_DISTRIBUTION); + } + + @Override + public List<Expression> getExpressions() { + return null; Review Comment: maybe we need to return an empty list ########## fe/fe-core/src/main/java/org/apache/doris/nereids/memo/GroupExpression.java: ########## @@ -44,6 +44,8 @@ public class GroupExpression { // Mapping from output properties to the corresponding best cost, statistics, and child properties. private final Map<PhysicalProperties, Pair<Double, List<PhysicalProperties>>> lowestCostTable; + // Each physical group expression maintains mapping incoming requests to the corresponding child requests. + private final Map<PhysicalProperties, PhysicalProperties> requestPropertiesMap; Review Comment: value need a list? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/memo/GroupExpression.java: ########## @@ -61,6 +63,14 @@ public GroupExpression(Operator op, List<Group> children) { this.ruleMasks = new BitSet(RuleType.SENTINEL.ordinal()); this.statDerived = false; this.lowestCostTable = Maps.newHashMap(); + this.requestPropertiesMap = Maps.newHashMap(); + } + + // TODO: rename + public PhysicalProperties getPropertyFromMap(PhysicalProperties requiredPropertySet) { Review Comment: ```suggestion public PhysicalProperties getPropertyFromMap(PhysicalProperties requiredProperties) { ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/properties/OrderKey.java: ########## @@ -42,6 +42,15 @@ public OrderKey(Expression expr, boolean isAsc, boolean nullFirst) { this.nullFirst = nullFirst; } + /** + * Whether other `OrderKey` is satisfied the current `OrderKey`. + * + * @param other another OrderKey. + */ + public boolean matches(OrderKey other) { + return expr.equals(other.expr) && isAsc == other.isAsc && nullFirst == other.nullFirst; Review Comment: we need semantic equal -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org