Sh-Zh-7 commented on code in PR #16953:
URL: https://github.com/apache/iotdb/pull/16953#discussion_r2709517598


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/RowNumberNode.java:
##########
@@ -0,0 +1,212 @@
+/*
+ * 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.iotdb.db.queryengine.plan.relational.planner.node;
+
+import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode;
+import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId;
+import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeType;
+import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanVisitor;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.SingleChildProcessNode;
+import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableList;
+import org.apache.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+public class RowNumberNode extends SingleChildProcessNode {
+  private final List<Symbol> partitionBy;
+  /*
+   * This flag indicates that the node depends on the row order established by 
the subplan.
+   * It is taken into account while adding local exchanges to the plan, 
ensuring that sorted order
+   * of data will be respected.
+   * Note: if the subplan doesn't produce sorted output, this flag doesn't 
change the resulting plan.
+   * Note: this flag is used for planning of queries involving ORDER BY and 
OFFSET.
+   */
+  private final boolean orderSensitive;
+  private final Optional<Integer> maxRowCountPerPartition;
+  private final Symbol rowNumberSymbol;
+
+  public RowNumberNode(
+      PlanNodeId id,
+      List<Symbol> partitionBy,
+      boolean orderSensitive,
+      Symbol rowNumberSymbol,
+      Optional<Integer> maxRowCountPerPartition) {
+    super(id);
+
+    this.partitionBy = ImmutableList.copyOf(partitionBy);
+    this.orderSensitive = orderSensitive;
+    this.rowNumberSymbol = rowNumberSymbol;
+    this.maxRowCountPerPartition = maxRowCountPerPartition;
+  }
+
+  public RowNumberNode(
+      PlanNodeId id,
+      PlanNode child,
+      List<Symbol> partitionBy,
+      boolean orderSensitive,
+      Symbol rowNumberSymbol,
+      Optional<Integer> maxRowCountPerPartition) {
+    super(id, child);
+
+    this.partitionBy = ImmutableList.copyOf(partitionBy);
+    this.orderSensitive = orderSensitive;
+    this.rowNumberSymbol = rowNumberSymbol;
+    this.maxRowCountPerPartition = maxRowCountPerPartition;
+  }
+
+  public Symbol getRowNumberSymbol() {
+    return rowNumberSymbol;
+  }
+
+  public Optional<Integer> getMaxRowCountPerPartition() {
+    return maxRowCountPerPartition;
+  }
+
+  public boolean isOrderSensitive() {
+    return orderSensitive;
+  }
+
+  @Override
+  public PlanNode clone() {
+    return new RowNumberNode(
+        getPlanNodeId(), partitionBy, orderSensitive, rowNumberSymbol, 
maxRowCountPerPartition);
+  }
+

Review Comment:
   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