Reminiscent commented on code in PR #18784:
URL: https://github.com/apache/doris/pull/18784#discussion_r1194719404


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalPartitionTopN.java:
##########
@@ -0,0 +1,166 @@
+// 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.trees.plans.logical;
+
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.OrderExpression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.WindowExpression;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.algebra.PartitionTopN;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.nereids.util.Utils;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Logical partition-top-N plan.
+ */
+public class LogicalPartitionTopN<CHILD_TYPE extends Plan> extends 
LogicalUnary<CHILD_TYPE> implements PartitionTopN {
+    private final Expression function;
+    private final List<Expression> partitionKeys;
+    private final List<OrderExpression> orderKeys;
+    private final Boolean hasGlobalLimit;
+    private final long partitionLimit;
+
+    public LogicalPartitionTopN(WindowExpression windowExpr, Boolean 
hasGlobalLimit, long partitionLimit,
+                                CHILD_TYPE child) {
+        this(windowExpr.getFunction(), windowExpr.getPartitionKeys(), 
windowExpr.getOrderKeys(),
+                hasGlobalLimit, partitionLimit, Optional.empty(),
+                Optional.empty(), child);
+    }
+
+    public LogicalPartitionTopN(Expression function, List<Expression> 
partitionKeys, List<OrderExpression> orderKeys,
+                                Boolean hasGlobalLimit, long partitionLimit, 
CHILD_TYPE child) {
+        this(function, partitionKeys, orderKeys, hasGlobalLimit, 
partitionLimit,
+                Optional.empty(), Optional.empty(), child);
+    }
+
+    /**
+     * Constructor for LogicalPartitionTopN.
+     */
+    public LogicalPartitionTopN(Expression function, List<Expression> 
partitionKeys, List<OrderExpression> orderKeys,
+                                Boolean hasGlobalLimit, long partitionLimit, 
Optional<GroupExpression> groupExpression,
+                                Optional<LogicalProperties> logicalProperties, 
CHILD_TYPE child) {
+        super(PlanType.LOGICAL_PARTITION_TOP_N, groupExpression, 
logicalProperties, child);
+        this.function = function;
+        this.partitionKeys = ImmutableList.copyOf(partitionKeys);
+        this.orderKeys = ImmutableList.copyOf(orderKeys);
+        this.hasGlobalLimit = hasGlobalLimit;
+        this.partitionLimit = partitionLimit;
+    }
+
+    @Override
+    public List<Slot> computeOutput() {
+        return child().getOutput();
+    }
+
+    public Expression getFunction() {
+        return function;
+    }
+
+    @Override
+    public List<Expression> getPartitionKeys() {
+        return partitionKeys;
+    }
+
+    public List<OrderExpression> getOrderKeys() {
+        return orderKeys;
+    }

Review Comment:
   I think when we need the function in the interface, we can put it later? For 
now, we don't need those functions in interface.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalPartitionTopN.java:
##########
@@ -0,0 +1,166 @@
+// 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.trees.plans.logical;
+
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.OrderExpression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.WindowExpression;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.algebra.PartitionTopN;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.nereids.util.Utils;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Logical partition-top-N plan.
+ */
+public class LogicalPartitionTopN<CHILD_TYPE extends Plan> extends 
LogicalUnary<CHILD_TYPE> implements PartitionTopN {
+    private final Expression function;
+    private final List<Expression> partitionKeys;
+    private final List<OrderExpression> orderKeys;
+    private final Boolean hasGlobalLimit;
+    private final long partitionLimit;
+
+    public LogicalPartitionTopN(WindowExpression windowExpr, Boolean 
hasGlobalLimit, long partitionLimit,
+                                CHILD_TYPE child) {
+        this(windowExpr.getFunction(), windowExpr.getPartitionKeys(), 
windowExpr.getOrderKeys(),
+                hasGlobalLimit, partitionLimit, Optional.empty(),
+                Optional.empty(), child);
+    }
+
+    public LogicalPartitionTopN(Expression function, List<Expression> 
partitionKeys, List<OrderExpression> orderKeys,
+                                Boolean hasGlobalLimit, long partitionLimit, 
CHILD_TYPE child) {
+        this(function, partitionKeys, orderKeys, hasGlobalLimit, 
partitionLimit,
+                Optional.empty(), Optional.empty(), child);
+    }
+
+    /**
+     * Constructor for LogicalPartitionTopN.
+     */
+    public LogicalPartitionTopN(Expression function, List<Expression> 
partitionKeys, List<OrderExpression> orderKeys,
+                                Boolean hasGlobalLimit, long partitionLimit, 
Optional<GroupExpression> groupExpression,
+                                Optional<LogicalProperties> logicalProperties, 
CHILD_TYPE child) {
+        super(PlanType.LOGICAL_PARTITION_TOP_N, groupExpression, 
logicalProperties, child);
+        this.function = function;
+        this.partitionKeys = ImmutableList.copyOf(partitionKeys);
+        this.orderKeys = ImmutableList.copyOf(orderKeys);
+        this.hasGlobalLimit = hasGlobalLimit;
+        this.partitionLimit = partitionLimit;
+    }
+
+    @Override
+    public List<Slot> computeOutput() {
+        return child().getOutput();
+    }
+
+    public Expression getFunction() {
+        return function;
+    }

Review Comment:
   Ditto



-- 
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

Reply via email to