This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch beyyes/multi_devices_fe
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/beyyes/multi_devices_fe by 
this push:
     new c66fabc2661 accelerate fe doDistributedPlan and schedule
c66fabc2661 is described below

commit c66fabc266123bd196303dbb111ed04b57daf601
Author: Beyyes <[email protected]>
AuthorDate: Mon Nov 20 21:47:35 2023 +0800

    accelerate fe doDistributedPlan and schedule
---
 .../db/queryengine/plan/analyze/TypeProvider.java  | 24 ++++++++++++++++++++++
 .../plan/planner/OperatorTreeGenerator.java        | 11 ++++++----
 .../plan/planner/SubPlanTypeExtractor.java         | 19 +++++++++++++----
 .../plan/planner/TemplatedLogicalPlan.java         |  1 +
 4 files changed, 47 insertions(+), 8 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/TypeProvider.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/TypeProvider.java
index feddf18226e..625f1e9d770 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/TypeProvider.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/TypeProvider.java
@@ -30,6 +30,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 
 public class TypeProvider {
 
@@ -41,6 +42,7 @@ public class TypeProvider {
   private List<String> measurementList;
   private List<IMeasurementSchema> schemaList;
   private List<TSDataType> dataTypes;
+  private Set<String> allSensors;
 
   public TypeProvider() {
     this.typeMap = new HashMap<>();
@@ -50,6 +52,20 @@ public class TypeProvider {
     this.typeMap = typeMap;
   }
 
+  public TypeProvider(
+      List<String> measurementList,
+      List<IMeasurementSchema> schemaList,
+      List<TSDataType> dataTypes,
+      Set<String> allSensors) {
+    if (measurementList != null) {
+      this.measurementList = measurementList;
+      this.schemaList = schemaList;
+      this.dataTypes = dataTypes;
+      this.allSensors = allSensors;
+    }
+    this.typeMap = new HashMap<>();
+  }
+
   public TSDataType getType(String symbol) {
     return typeMap.get(symbol);
   }
@@ -133,4 +149,12 @@ public class TypeProvider {
   public List<TSDataType> getDataTypes() {
     return this.dataTypes;
   }
+
+  public void setAllSensors(Set<String> allSensors) {
+    this.allSensors = allSensors;
+  }
+
+  public Set<String> getAllSensors() {
+    return this.allSensors;
+  }
 }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java
index 45b8ca02b3d..c94026742e1 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java
@@ -346,7 +346,10 @@ public class OperatorTreeGenerator extends 
PlanVisitor<Operator, LocalExecutionP
     seriesScanOptionsBuilder.withLimit(node.getLimit());
     seriesScanOptionsBuilder.withOffset(node.getOffset());
     AlignedPath seriesPath = node.getAlignedPath();
-    seriesScanOptionsBuilder.withAllSensors(new 
HashSet<>(seriesPath.getMeasurementList()));
+    seriesScanOptionsBuilder.withAllSensors(
+        context.getTypeProvider().getAllSensors() != null
+            ? context.getTypeProvider().getAllSensors()
+            : new HashSet<>(seriesPath.getMeasurementList()));
 
     OperatorContext operatorContext =
         context
@@ -2557,8 +2560,8 @@ public class OperatorTreeGenerator extends 
PlanVisitor<Operator, LocalExecutionP
 
   private List<TSDataType> getInputColumnTypesUseTemplate(
       PlanNode node, TypeProvider typeProvider) {
-    // in template situation, the children of FilterNode/TransformNode can be 
TimeJoinNode,
-    // ScanNode, any others?
+    // Only templated device + filter situation can invoke this method,
+    // the children of FilterNode/TransformNode can be TimeJoinNode, ScanNode, 
any others?
     List<TSDataType> dataTypes = new ArrayList<>();
     for (PlanNode child : node.getChildren()) {
       if (child instanceof SeriesScanNode) {
@@ -2569,7 +2572,6 @@ public class OperatorTreeGenerator extends 
PlanVisitor<Operator, LocalExecutionP
             .getAlignedPath()
             .getSchemaList()
             .forEach(c -> dataTypes.add(c.getType()));
-        // dataTypes.add(((AlignedSeriesScanNode) 
child).getAlignedPath().getSeriesType());
       } else {
         dataTypes.addAll(getInputColumnTypesUseTemplate(child, typeProvider));
       }
@@ -2584,6 +2586,7 @@ public class OperatorTreeGenerator extends 
PlanVisitor<Operator, LocalExecutionP
   }
 
   private List<TSDataType> getOutputColumnTypesOfTimeJoinNode(PlanNode node) {
+    // Only templated device situation can invoke this method,
     // the children of TimeJoinNode can only be ScanNode or TimeJoinNode
     List<TSDataType> dataTypes = new ArrayList<>();
     for (PlanNode child : node.getChildren()) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/SubPlanTypeExtractor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/SubPlanTypeExtractor.java
index 8ad60acc063..8d4df010115 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/SubPlanTypeExtractor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/SubPlanTypeExtractor.java
@@ -26,6 +26,7 @@ import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.SimplePlanVisitor;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.AggregationNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.GroupByLevelNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.GroupByTagNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.SingleDeviceViewNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.SlidingWindowAggregationNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.last.LastQueryCollectNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.last.LastQueryMergeNode;
@@ -45,10 +46,12 @@ public class SubPlanTypeExtractor {
   private SubPlanTypeExtractor() {}
 
   public static TypeProvider extractor(PlanNode root, TypeProvider allTypes) {
-    TypeProvider typeProvider = new TypeProvider();
-    typeProvider.setSchemaList(allTypes.getSchemaList());
-    typeProvider.setMeasurementList(allTypes.getMeasurementList());
-    typeProvider.setDataTypes(allTypes.getDataTypes());
+    TypeProvider typeProvider =
+        new TypeProvider(
+            allTypes.getMeasurementList(),
+            allTypes.getSchemaList(),
+            allTypes.getDataTypes(),
+            allTypes.getAllSensors());
     root.accept(new Visitor(typeProvider, allTypes), null);
     return typeProvider;
   }
@@ -159,6 +162,14 @@ public class SubPlanTypeExtractor {
       return visitPlan(node, context);
     }
 
+    @Override
+    public Void visitSingleDeviceView(SingleDeviceViewNode node, Void context) 
{
+      if (typeProvider.getMeasurementList() != null) {
+        return null;
+      }
+      return visitPlan(node, context);
+    }
+
     // end region PlanNode of last read
 
     private void updateTypeProviderByAggregationDescriptor(
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TemplatedLogicalPlan.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TemplatedLogicalPlan.java
index fc04b952463..ead71d394f9 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TemplatedLogicalPlan.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TemplatedLogicalPlan.java
@@ -187,6 +187,7 @@ public class TemplatedLogicalPlan {
               mergedSchemaList.stream()
                   .map(IMeasurementSchema::getType)
                   .collect(Collectors.toList()));
+      context.getTypeProvider().setAllSensors(new 
HashSet<>(mergedMeasurementList));
     }
 
     return planBuilder.getRoot();

Reply via email to