You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2021/06/06 08:18:21 UTC

[iotdb] 01/03: Fix bugs

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

xiangweiwei pushed a commit to branch removeTokenType
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 25259cf67881ae4347b0b10d760c21f462b3e85d
Author: Alima777 <wx...@gmail.com>
AuthorDate: Sun Jun 6 15:44:10 2021 +0800

    Fix bugs
---
 .../qp/logical/crud/AggregationQueryOperator.java  | 26 ++++++++-----------
 .../db/qp/logical/crud/FillQueryOperator.java      | 28 ++++++++-------------
 .../qp/logical/crud/GroupByFillQueryOperator.java  | 29 +++++++++++-----------
 .../db/qp/logical/crud/GroupByQueryOperator.java   | 26 ++++++++-----------
 .../iotdb/db/qp/logical/crud/QueryOperator.java    | 22 +++++++++-------
 .../iotdb/db/qp/logical/crud/UDFQueryOperator.java | 10 +++-----
 6 files changed, 63 insertions(+), 78 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/AggregationQueryOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/AggregationQueryOperator.java
index e18e873..f21c5a8 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/AggregationQueryOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/AggregationQueryOperator.java
@@ -79,8 +79,8 @@ public class AggregationQueryOperator extends QueryOperator {
   public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
       throws QueryProcessException {
     return isAlignByDevice()
-        ? this.generateAggregationAlignByDevicePlan(generator)
-        : this.generateRawDataQueryPlan(generator, new AggregationPlan());
+        ? this.generateAlignByDevicePlan(generator)
+        : super.generateRawDataQueryPlan(generator, initAggregationPlan(new AggregationPlan()));
   }
 
   private boolean verifyAllAggregationDataTypesEqual() throws MetadataException {
@@ -103,12 +103,18 @@ public class AggregationQueryOperator extends QueryOperator {
     }
   }
 
-  protected QueryPlan generateRawDataQueryPlan(PhysicalGenerator generator, QueryPlan queryPlan)
+  @Override
+  protected AlignByDevicePlan generateAlignByDevicePlan(PhysicalGenerator generator)
       throws QueryProcessException {
+    AlignByDevicePlan alignByDevicePlan = super.generateAlignByDevicePlan(generator);
+    alignByDevicePlan.setAggregationPlan(initAggregationPlan(new AggregationPlan()));
+
+    return alignByDevicePlan;
+  }
+
+  protected AggregationPlan initAggregationPlan(QueryPlan queryPlan) throws QueryProcessException {
     AggregationPlan aggregationPlan = (AggregationPlan) queryPlan;
     aggregationPlan.setAggregations(selectComponent.getAggregationFunctions());
-    super.generateRawDataQueryPlan(generator, aggregationPlan);
-
     if (isGroupByLevel()) {
       aggregationPlan.setLevel(specialClauseComponent.getLevel());
       try {
@@ -119,16 +125,6 @@ public class AggregationQueryOperator extends QueryOperator {
         throw new LogicalOperatorException(e);
       }
     }
-
     return aggregationPlan;
   }
-
-  protected AlignByDevicePlan generateAggregationAlignByDevicePlan(PhysicalGenerator generator)
-      throws QueryProcessException {
-    AlignByDevicePlan alignByDevicePlan = super.generateAlignByDevicePlan(generator);
-    alignByDevicePlan.setAggregationPlan(
-        (AggregationPlan) generateRawDataQueryPlan(generator, new AggregationPlan()));
-
-    return alignByDevicePlan;
-  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/FillQueryOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/FillQueryOperator.java
index 56e0bb1..579016c 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/FillQueryOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/FillQueryOperator.java
@@ -25,7 +25,6 @@ import org.apache.iotdb.db.qp.constant.FilterConstant.FilterType;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.crud.AlignByDevicePlan;
 import org.apache.iotdb.db.qp.physical.crud.FillQueryPlan;
-import org.apache.iotdb.db.qp.physical.crud.QueryPlan;
 import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
 
 public class FillQueryOperator extends QueryOperator {
@@ -55,29 +54,24 @@ public class FillQueryOperator extends QueryOperator {
       throws QueryProcessException {
     return isAlignByDevice()
         ? this.generateAlignByDevicePlan(generator)
-        : this.generateRawDataQueryPlan(generator, new FillQueryPlan());
-  }
-
-  @Override
-  protected QueryPlan generateRawDataQueryPlan(PhysicalGenerator generator, QueryPlan queryPlan)
-      throws QueryProcessException {
-    FillQueryPlan fillQueryPlan = (FillQueryPlan) queryPlan;
-    FilterOperator timeFilter = whereComponent.getFilterOperator();
-    long time = Long.parseLong(((BasicFunctionOperator) timeFilter).getValue());
-    fillQueryPlan.setQueryTime(time);
-    fillQueryPlan.setFillType(((FillClauseComponent) specialClauseComponent).getFillTypes());
-    queryPlan = super.generateRawDataQueryPlan(generator, fillQueryPlan);
-
-    return queryPlan;
+        : super.generateRawDataQueryPlan(generator, initFillQueryPlan());
   }
 
   @Override
   protected AlignByDevicePlan generateAlignByDevicePlan(PhysicalGenerator generator)
       throws QueryProcessException {
     AlignByDevicePlan alignByDevicePlan = super.generateAlignByDevicePlan(generator);
-    alignByDevicePlan.setFillQueryPlan(
-        (FillQueryPlan) generateRawDataQueryPlan(generator, new FillQueryPlan()));
+    alignByDevicePlan.setFillQueryPlan(initFillQueryPlan());
 
     return alignByDevicePlan;
   }
+
+  private FillQueryPlan initFillQueryPlan() {
+    FillQueryPlan fillQueryPlan = new FillQueryPlan();
+    FilterOperator timeFilter = whereComponent.getFilterOperator();
+    long time = Long.parseLong(((BasicFunctionOperator) timeFilter).getValue());
+    fillQueryPlan.setQueryTime(time);
+    fillQueryPlan.setFillType(((FillClauseComponent) specialClauseComponent).getFillTypes());
+    return fillQueryPlan;
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByFillQueryOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByFillQueryOperator.java
index 1cd1f53..ac621cf 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByFillQueryOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByFillQueryOperator.java
@@ -45,29 +45,28 @@ public class GroupByFillQueryOperator extends GroupByQueryOperator {
   public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
       throws QueryProcessException {
     return isAlignByDevice()
-        ? this.generateAggregationAlignByDevicePlan(generator)
-        : this.generateRawDataQueryPlan(generator, new GroupByTimeFillPlan());
+        ? this.generateAlignByDevicePlan(generator)
+        : super.generateRawDataQueryPlan(
+            generator, initGroupByTimeFillPlan(new GroupByTimeFillPlan()));
   }
 
   @Override
-  protected QueryPlan generateRawDataQueryPlan(PhysicalGenerator generator, QueryPlan queryPlan)
+  protected AlignByDevicePlan generateAlignByDevicePlan(PhysicalGenerator generator)
       throws QueryProcessException {
-    queryPlan = super.generateRawDataQueryPlan(generator, queryPlan);
-    GroupByTimeFillPlan groupByTimeFillPlan = (GroupByTimeFillPlan) queryPlan;
-    GroupByFillClauseComponent groupByFillClauseComponent =
-        (GroupByFillClauseComponent) specialClauseComponent;
-    groupByTimeFillPlan.setFillType(groupByFillClauseComponent.getFillTypes());
+    AlignByDevicePlan alignByDevicePlan = super.generateAlignByDevicePlan(generator);
+    alignByDevicePlan.setGroupByTimePlan(initGroupByTimeFillPlan(new GroupByTimeFillPlan()));
 
-    return queryPlan;
+    return alignByDevicePlan;
   }
 
-  @Override
-  protected AlignByDevicePlan generateAggregationAlignByDevicePlan(PhysicalGenerator generator)
+  protected GroupByTimeFillPlan initGroupByTimeFillPlan(QueryPlan queryPlan)
       throws QueryProcessException {
-    AlignByDevicePlan alignByDevicePlan = super.generateAlignByDevicePlan(generator);
-    alignByDevicePlan.setGroupByTimePlan(
-        (GroupByTimeFillPlan) generateRawDataQueryPlan(generator, new GroupByTimeFillPlan()));
+    GroupByTimeFillPlan groupByTimeFillPlan =
+        (GroupByTimeFillPlan) super.initGroupByTimePlan(queryPlan);
+    GroupByFillClauseComponent groupByFillClauseComponent =
+        (GroupByFillClauseComponent) specialClauseComponent;
+    groupByTimeFillPlan.setFillType(groupByFillClauseComponent.getFillTypes());
 
-    return alignByDevicePlan;
+    return groupByTimeFillPlan;
   }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByQueryOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByQueryOperator.java
index 8428f46..3ed87ec 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByQueryOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/GroupByQueryOperator.java
@@ -32,16 +32,21 @@ public class GroupByQueryOperator extends AggregationQueryOperator {
   public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
       throws QueryProcessException {
     return isAlignByDevice()
-        ? this.generateAggregationAlignByDevicePlan(generator)
-        : this.generateRawDataQueryPlan(generator, new GroupByTimePlan());
+        ? this.generateAlignByDevicePlan(generator)
+        : super.generateRawDataQueryPlan(generator, initGroupByTimePlan(new GroupByTimePlan()));
   }
 
   @Override
-  protected QueryPlan generateRawDataQueryPlan(PhysicalGenerator generator, QueryPlan queryPlan)
+  protected AlignByDevicePlan generateAlignByDevicePlan(PhysicalGenerator generator)
       throws QueryProcessException {
-    queryPlan = super.generateRawDataQueryPlan(generator, queryPlan);
+    AlignByDevicePlan alignByDevicePlan = super.generateAlignByDevicePlan(generator);
+    alignByDevicePlan.setGroupByTimePlan(initGroupByTimePlan(new GroupByTimePlan()));
+
+    return alignByDevicePlan;
+  }
 
-    GroupByTimePlan groupByTimePlan = (GroupByTimePlan) queryPlan;
+  protected GroupByTimePlan initGroupByTimePlan(QueryPlan queryPlan) throws QueryProcessException {
+    GroupByTimePlan groupByTimePlan = (GroupByTimePlan) initAggregationPlan(queryPlan);
     GroupByClauseComponent groupByClauseComponent = (GroupByClauseComponent) specialClauseComponent;
 
     groupByTimePlan.setInterval(groupByClauseComponent.getUnit());
@@ -49,6 +54,7 @@ public class GroupByQueryOperator extends AggregationQueryOperator {
     groupByTimePlan.setSlidingStep(groupByClauseComponent.getSlidingStep());
     groupByTimePlan.setSlidingStepByMonth(groupByClauseComponent.isSlidingStepByMonth());
     groupByTimePlan.setLeftCRightO(groupByClauseComponent.isLeftCRightO());
+
     if (!groupByClauseComponent.isLeftCRightO()) {
       groupByTimePlan.setStartTime(groupByClauseComponent.getStartTime() + 1);
       groupByTimePlan.setEndTime(groupByClauseComponent.getEndTime() + 1);
@@ -59,14 +65,4 @@ public class GroupByQueryOperator extends AggregationQueryOperator {
 
     return groupByTimePlan;
   }
-
-  @Override
-  protected AlignByDevicePlan generateAggregationAlignByDevicePlan(PhysicalGenerator generator)
-      throws QueryProcessException {
-    AlignByDevicePlan alignByDevicePlan = super.generateAlignByDevicePlan(generator);
-    alignByDevicePlan.setGroupByTimePlan(
-        (GroupByTimePlan) generateRawDataQueryPlan(generator, new GroupByTimePlan()));
-
-    return alignByDevicePlan;
-  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
index ec5fef9..f358efd 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
@@ -173,7 +173,6 @@ public class QueryOperator extends Operator {
 
   protected QueryPlan generateRawDataQueryPlan(PhysicalGenerator generator, QueryPlan queryPlan)
       throws QueryProcessException {
-
     RawDataQueryPlan rawDataQueryPlan = (RawDataQueryPlan) queryPlan;
     rawDataQueryPlan.setPaths(selectComponent.getPaths());
     rawDataQueryPlan.setResultColumns(selectComponent.getResultColumns());
@@ -203,14 +202,7 @@ public class QueryOperator extends Operator {
       throw new QueryProcessException(e);
     }
 
-    if (specialClauseComponent != null) {
-      rawDataQueryPlan.setWithoutAllNull(specialClauseComponent.isWithoutAllNull());
-      rawDataQueryPlan.setWithoutAnyNull(specialClauseComponent.isWithoutAnyNull());
-      rawDataQueryPlan.setRowLimit(specialClauseComponent.getRowLimit());
-      rawDataQueryPlan.setRowOffset(specialClauseComponent.getRowOffset());
-      rawDataQueryPlan.setAscending(specialClauseComponent.isAscending());
-      rawDataQueryPlan.setAlignByTime(specialClauseComponent.isAlignByTime());
-    }
+    convertSpecialClauseValues(rawDataQueryPlan);
 
     if (queryPlan instanceof QueryIndexPlan) {
       ((QueryIndexPlan) queryPlan).setIndexType(indexType);
@@ -360,6 +352,7 @@ public class QueryOperator extends Operator {
       measurements.addAll(measurementSetOfGivenSuffix);
     }
 
+    convertSpecialClauseValues(alignByDevicePlan);
     // slimit trim on the measurementColumnList
     if (specialClauseComponent.hasSlimit()) {
       int seriesSlimit = specialClauseComponent.getSeriesLimit();
@@ -385,6 +378,17 @@ public class QueryOperator extends Operator {
     return alignByDevicePlan;
   }
 
+  private void convertSpecialClauseValues(QueryPlan queryPlan) {
+    if (specialClauseComponent != null) {
+      queryPlan.setWithoutAllNull(specialClauseComponent.isWithoutAllNull());
+      queryPlan.setWithoutAnyNull(specialClauseComponent.isWithoutAnyNull());
+      queryPlan.setRowLimit(specialClauseComponent.getRowLimit());
+      queryPlan.setRowOffset(specialClauseComponent.getRowOffset());
+      queryPlan.setAscending(specialClauseComponent.isAscending());
+      queryPlan.setAlignByTime(specialClauseComponent.isAlignByTime());
+    }
+  }
+
   private List<PartialPath> removeStarsInDeviceWithUnique(List<PartialPath> paths)
       throws LogicalOptimizeException {
     List<PartialPath> retDevices;
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/UDFQueryOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/UDFQueryOperator.java
index fb937ee..4b6fdfe 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/UDFQueryOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/UDFQueryOperator.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.db.qp.logical.crud;
 
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.crud.QueryPlan;
 import org.apache.iotdb.db.qp.physical.crud.UDTFPlan;
 import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
 
@@ -38,14 +37,11 @@ public class UDFQueryOperator extends QueryOperator {
   @Override
   public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
       throws QueryProcessException {
-    return this.generateRawDataQueryPlan(generator, new UDTFPlan(selectComponent.getZoneId()));
+    return super.generateRawDataQueryPlan(generator, initUDTFPlan());
   }
 
-  @Override
-  protected QueryPlan generateRawDataQueryPlan(PhysicalGenerator generator, QueryPlan queryPlan)
-      throws QueryProcessException {
-    queryPlan = super.generateRawDataQueryPlan(generator, queryPlan);
-    UDTFPlan udtfPlan = (UDTFPlan) queryPlan;
+  private UDTFPlan initUDTFPlan() {
+    UDTFPlan udtfPlan = new UDTFPlan(selectComponent.getZoneId());
     udtfPlan.constructUdfExecutors(selectComponent.getResultColumns());
     return udtfPlan;
   }