JackieTien97 commented on code in PR #14465:
URL: https://github.com/apache/iotdb/pull/14465#discussion_r1891430623
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/PlanNodeType.java:
##########
@@ -641,6 +649,14 @@ public static PlanNode deserialize(ByteBuffer buffer,
short nodeType) {
return EnforceSingleRowNode.deserialize(buffer);
case 1021:
return InformationSchemaTableScanNode.deserialize(buffer);
+ case 1022:
+ return TreeDeviceViewScanNode.deserialize(buffer);
Review Comment:
throw exception? We should never do TreeDeviceViewScanNode deserialize
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/TreeDeviceViewScanNode.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * 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.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.relational.metadata.AlignedDeviceEntry;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnSchema;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.QualifiedObjectName;
+import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.db.queryengine.plan.statement.component.Ordering;
+
+import org.apache.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TreeDeviceViewScanNode extends DeviceTableScanNode {
+ protected final String treeDBName;
+ protected final Map<String, String> measurementColumnNameMap;
+
+ public TreeDeviceViewScanNode(
+ PlanNodeId id,
+ QualifiedObjectName qualifiedObjectName,
+ List<Symbol> outputSymbols,
+ Map<Symbol, ColumnSchema> assignments,
+ Map<Symbol, Integer> idAndAttributeIndexMap,
+ String treeDBName,
+ Map<String, String> measurementColumnNameMap) {
+ super(id, qualifiedObjectName, outputSymbols, assignments,
idAndAttributeIndexMap);
+ this.treeDBName = treeDBName;
+ this.measurementColumnNameMap = measurementColumnNameMap;
+ }
+
+ public TreeDeviceViewScanNode(
+ PlanNodeId id,
+ QualifiedObjectName qualifiedObjectName,
+ List<Symbol> outputSymbols,
+ Map<Symbol, ColumnSchema> assignments,
+ List<DeviceEntry> deviceEntries,
+ Map<Symbol, Integer> idAndAttributeIndexMap,
+ Ordering scanOrder,
+ Expression timePredicate,
+ Expression pushDownPredicate,
+ long pushDownLimit,
+ long pushDownOffset,
+ boolean pushLimitToEachDevice,
+ boolean containsNonAlignedDevice,
+ String treeDBName,
+ Map<String, String> measurementColumnNameMap) {
+ super(
+ id,
+ qualifiedObjectName,
+ outputSymbols,
+ assignments,
+ deviceEntries,
+ idAndAttributeIndexMap,
+ scanOrder,
+ timePredicate,
+ pushDownPredicate,
+ pushDownLimit,
+ pushDownOffset,
+ pushLimitToEachDevice,
+ containsNonAlignedDevice);
+ this.treeDBName = treeDBName;
+ this.measurementColumnNameMap = measurementColumnNameMap;
+ }
+
+ public String getTreeDBName() {
+ return treeDBName;
+ }
+
+ public Map<String, String> getMeasurementColumnNameMap() {
+ return measurementColumnNameMap;
+ }
+
+ @Override
+ public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+ return visitor.visitTreeDeviceViewScan(this, context);
+ }
+
+ @Override
+ public TreeDeviceViewScanNode clone() {
+ return new TreeDeviceViewScanNode(
+ getPlanNodeId(),
+ qualifiedObjectName,
+ outputSymbols,
+ assignments,
+ deviceEntries,
+ idAndAttributeIndexMap,
+ scanOrder,
+ timePredicate,
+ pushDownPredicate,
+ pushDownLimit,
+ pushDownOffset,
+ pushLimitToEachDevice,
+ containsNonAlignedDevice,
+ treeDBName,
+ measurementColumnNameMap);
+ }
+
+ @Override
+ protected void serializeAttributes(ByteBuffer byteBuffer) {
Review Comment:
throw exception for these serde methods? remember to add some comments to
explain
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/AggregationTreeDeviceViewScanNode.java:
##########
@@ -0,0 +1,435 @@
+/*
+ * 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.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.relational.metadata.AlignedDeviceEntry;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnSchema;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.QualifiedObjectName;
+import org.apache.iotdb.db.queryengine.plan.relational.planner.Assignments;
+import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.db.queryengine.plan.statement.component.Ordering;
+
+import org.apache.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+public class AggregationTreeDeviceViewScanNode extends
AggregationTableScanNode {
+ private final String treeDBName;
+ private final Map<String, String> measurementColumnNameMap;
+
+ public AggregationTreeDeviceViewScanNode(
+ PlanNodeId id,
+ QualifiedObjectName qualifiedObjectName,
+ List<Symbol> outputSymbols,
+ Map<Symbol, ColumnSchema> assignments,
+ List<DeviceEntry> deviceEntries,
+ Map<Symbol, Integer> idAndAttributeIndexMap,
+ Ordering scanOrder,
+ Expression timePredicate,
+ Expression pushDownPredicate,
+ long pushDownLimit,
+ long pushDownOffset,
+ boolean pushLimitToEachDevice,
+ boolean containsNonAlignedDevice,
+ Assignments projection,
+ Map<Symbol, AggregationNode.Aggregation> aggregations,
+ AggregationNode.GroupingSetDescriptor groupingSets,
+ List<Symbol> preGroupedSymbols,
+ AggregationNode.Step step,
+ Optional<Symbol> groupIdSymbol,
+ String treeDBName,
+ Map<String, String> measurementColumnNameMap) {
+ super(
+ id,
+ qualifiedObjectName,
+ outputSymbols,
+ assignments,
+ deviceEntries,
+ idAndAttributeIndexMap,
+ scanOrder,
+ timePredicate,
+ pushDownPredicate,
+ pushDownLimit,
+ pushDownOffset,
+ pushLimitToEachDevice,
+ containsNonAlignedDevice,
+ projection,
+ aggregations,
+ groupingSets,
+ preGroupedSymbols,
+ step,
+ groupIdSymbol);
+ this.treeDBName = treeDBName;
+ this.measurementColumnNameMap = measurementColumnNameMap;
+ }
+
+ public String getTreeDBName() {
+ return treeDBName;
+ }
+
+ public Map<String, String> getMeasurementColumnNameMap() {
+ return measurementColumnNameMap;
+ }
+
+ @Override
+ public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+ return visitor.visitAggregationTreeDeviceViewScan(this, context);
+ }
+
+ @Override
+ public AggregationTreeDeviceViewScanNode clone() {
+ return new AggregationTreeDeviceViewScanNode(
+ id,
+ qualifiedObjectName,
+ outputSymbols,
+ assignments,
+ deviceEntries,
+ idAndAttributeIndexMap,
+ scanOrder,
+ timePredicate,
+ pushDownPredicate,
+ pushDownLimit,
+ pushDownOffset,
+ pushLimitToEachDevice,
+ containsNonAlignedDevice,
+ projection,
+ aggregations,
+ groupingSets,
+ preGroupedSymbols,
+ step,
+ groupIdSymbol,
+ treeDBName,
+ measurementColumnNameMap);
+ }
+
+ @Override
+ protected void serializeAttributes(ByteBuffer byteBuffer) {
Review Comment:
extract same serde codes into parent class's method
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java:
##########
@@ -524,6 +527,120 @@ public List<PlanNode>
visitDeviceTableScan(DeviceTableScanNode node, PlanContext
return resultTableScanNodeList;
}
+ @Override
+ public List<PlanNode> visitTreeDeviceViewScan(TreeDeviceViewScanNode node,
PlanContext context) {
+ // left of pair if TreeAlignedDeviceViewScanNode, right is
TreeNonAlignedDeviceViewScanNode
+ Map<TRegionReplicaSet, Pair<TreeDeviceViewScanNode,
TreeDeviceViewScanNode>> tableScanNodeMap =
+ new HashMap<>();
+
+ for (DeviceEntry deviceEntry : node.getDeviceEntries()) {
+ List<TRegionReplicaSet> regionReplicaSets =
+ analysis.getDataRegionReplicaSetWithTimeFilter(
+ node.getQualifiedObjectName().getDatabaseName(),
+ deviceEntry.getDeviceID(),
+ node.getTimeFilter());
Review Comment:
```suggestion
analysis.getDataRegionReplicaSetWithTimeFilter(
deviceEntry.getDeviceID(),
node.getTimeFilter());
```
For tree devices, you need to call this method
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/DeviceTableScanNode.java:
##########
@@ -74,6 +74,8 @@ public class DeviceTableScanNode extends TableScanNode {
// `pushDownLimit` row number
protected boolean pushLimitToEachDevice = false;
+ protected boolean containsNonAlignedDevice;
Review Comment:
```suggestion
protected transient boolean containsNonAlignedDevice;
```
don't need to be serialized or deserialized?
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java:
##########
@@ -524,6 +527,120 @@ public List<PlanNode>
visitDeviceTableScan(DeviceTableScanNode node, PlanContext
return resultTableScanNodeList;
}
+ @Override
+ public List<PlanNode> visitTreeDeviceViewScan(TreeDeviceViewScanNode node,
PlanContext context) {
+ // left of pair if TreeAlignedDeviceViewScanNode, right is
TreeNonAlignedDeviceViewScanNode
+ Map<TRegionReplicaSet, Pair<TreeDeviceViewScanNode,
TreeDeviceViewScanNode>> tableScanNodeMap =
Review Comment:
```suggestion
Map<TRegionReplicaSet, Pair<TreeAlignedDeviceViewScanNode,
TreeNonAlignedDeviceViewScanNode>> tableScanNodeMap =
```
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/TreeNonAlignedDeviceViewScanNode.java:
##########
@@ -0,0 +1,318 @@
+/*
+ * 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.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.relational.metadata.AlignedDeviceEntry;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnSchema;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.QualifiedObjectName;
+import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.db.queryengine.plan.statement.component.Ordering;
+
+import org.apache.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TreeNonAlignedDeviceViewScanNode extends TreeDeviceViewScanNode {
+
+ public TreeNonAlignedDeviceViewScanNode(
+ PlanNodeId id,
+ QualifiedObjectName qualifiedObjectName,
+ List<Symbol> outputSymbols,
+ Map<Symbol, ColumnSchema> assignments,
+ List<DeviceEntry> deviceEntries,
+ Map<Symbol, Integer> idAndAttributeIndexMap,
+ Ordering scanOrder,
+ Expression timePredicate,
+ Expression pushDownPredicate,
+ long pushDownLimit,
+ long pushDownOffset,
+ boolean pushLimitToEachDevice,
+ boolean containsNonAlignedDevice,
+ String treeDBName,
+ Map<String, String> measurementColumnNameMap) {
+ super(
+ id,
+ qualifiedObjectName,
+ outputSymbols,
+ assignments,
+ deviceEntries,
+ idAndAttributeIndexMap,
+ scanOrder,
+ timePredicate,
+ pushDownPredicate,
+ pushDownLimit,
+ pushDownOffset,
+ pushLimitToEachDevice,
+ containsNonAlignedDevice,
+ treeDBName,
+ measurementColumnNameMap);
+ }
+
+ @Override
+ public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+ return visitor.visitTreeNonAlignedDeviceViewScan(this, context);
+ }
+
+ @Override
+ public TreeNonAlignedDeviceViewScanNode clone() {
+ return new TreeNonAlignedDeviceViewScanNode(
+ getPlanNodeId(),
+ qualifiedObjectName,
+ outputSymbols,
+ assignments,
+ deviceEntries,
+ idAndAttributeIndexMap,
+ scanOrder,
+ timePredicate,
+ pushDownPredicate,
+ pushDownLimit,
+ pushDownOffset,
+ pushLimitToEachDevice,
+ containsNonAlignedDevice,
+ treeDBName,
+ measurementColumnNameMap);
+ }
+
+ @Override
+ protected void serializeAttributes(ByteBuffer byteBuffer) {
Review Comment:
extract all the same serde codes to super class and then call that in two
sub classes.
--
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]