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/09/14 07:26:28 UTC

[iotdb] branch aggregationVector created (now 42d5bfd)

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

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


      at 42d5bfd  add comments for align by device

This branch includes the following new commits:

     new 42d5bfd  add comments for align by device

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[iotdb] 01/01: add comments for align by device

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 42d5bfd2a0cc80b67a96c77b1923457c564caf9b
Author: Alima777 <wx...@gmail.com>
AuthorDate: Tue Sep 14 15:25:42 2021 +0800

    add comments for align by device
---
 .../apache/iotdb/db/qp/logical/crud/QueryOperator.java    |  7 ++++++-
 .../iotdb/db/qp/physical/crud/RawDataQueryPlan.java       |  1 +
 .../iotdb/db/query/dataset/AlignByDeviceDataSet.java      | 15 +++++++++++++--
 3 files changed, 20 insertions(+), 3 deletions(-)

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 842850a..720aed7 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
@@ -41,6 +41,7 @@ import org.apache.iotdb.db.query.expression.ResultColumn;
 import org.apache.iotdb.db.query.expression.unary.FunctionExpression;
 import org.apache.iotdb.db.query.expression.unary.TimeSeriesOperand;
 import org.apache.iotdb.db.service.IoTDB;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.expression.IExpression;
 
@@ -373,11 +374,15 @@ public class QueryOperator extends Operator {
         : (((FunctionExpression) expression).getPaths().get(0));
   }
 
+  /**
+   * If path is a vectorPartialPath, we return its measurementId + subMeasurement as the final
+   * measurement. e.g. path: root.sg.d1.vector1[s1], return "vector1.s1".
+   */
   private String getMeasurementName(PartialPath path, String aggregation) {
     String initialMeasurement = path.getMeasurement();
     if (path instanceof VectorPartialPath) {
       String subMeasurement = ((VectorPartialPath) path).getSubSensor(0);
-      initialMeasurement += "." + subMeasurement;
+      initialMeasurement += TsFileConstant.PATH_SEPARATOR + subMeasurement;
     }
     if (aggregation != null) {
       initialMeasurement = aggregation + "(" + initialMeasurement + ")";
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/RawDataQueryPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/RawDataQueryPlan.java
index 5936633..b81ddec 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/RawDataQueryPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/RawDataQueryPlan.java
@@ -44,6 +44,7 @@ public class RawDataQueryPlan extends QueryPlan {
   private IExpression expression = null;
   private Map<String, Set<String>> deviceToMeasurements = new HashMap<>();
 
+  // TODO: remove this when all types of query supporting vector
   /** used to group all the sub sensors of one vector into VectorPartialPath */
   private List<PartialPath> deduplicatedVectorPaths = new ArrayList<>();
 
diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/AlignByDeviceDataSet.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/AlignByDeviceDataSet.java
index 86008d1..7ab4095 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/dataset/AlignByDeviceDataSet.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/AlignByDeviceDataSet.java
@@ -35,6 +35,7 @@ import org.apache.iotdb.db.query.context.QueryContext;
 import org.apache.iotdb.db.query.executor.IQueryRouter;
 import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.rpc.RedirectException;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.common.Field;
@@ -224,6 +225,11 @@ public class AlignByDeviceDataSet extends QueryDataSet {
     return false;
   }
 
+  /**
+   * Get all measurements under given device. For a vectorMeasurementSchema, we return its
+   * measurementId + all subMeasurement. e.g. schema: vector1[s1, s2], return ["vector1.s1",
+   * "vector1.s2"].
+   */
   protected Set<String> getMeasurementsUnderGivenDevice(PartialPath device) throws IOException {
     try {
       Set<String> res = new HashSet<>();
@@ -233,7 +239,7 @@ public class AlignByDeviceDataSet extends QueryDataSet {
       for (IMeasurementSchema schema : measurementSchemas) {
         if (schema instanceof VectorMeasurementSchema) {
           for (String subMeasurement : schema.getSubMeasurementsList()) {
-            res.add(schema.getMeasurementId() + "." + subMeasurement);
+            res.add(schema.getMeasurementId() + TsFileConstant.PATH_SEPARATOR + subMeasurement);
           }
         } else {
           res.add(schema.getMeasurementId());
@@ -246,6 +252,10 @@ public class AlignByDeviceDataSet extends QueryDataSet {
     }
   }
 
+  /**
+   * Attention. For a vectorPath(root.sg.d1.vector1.s1), device is root.sg.d1, measurement is
+   * "vector1.s1".
+   */
   private PartialPath transformPath(PartialPath device, String measurement) throws IOException {
     try {
       PartialPath fullPath = new PartialPath(device.getFullPath(), measurement);
@@ -253,7 +263,8 @@ public class AlignByDeviceDataSet extends QueryDataSet {
       if (schema instanceof MeasurementSchema) {
         return fullPath;
       } else {
-        return new VectorPartialPath(fullPath.getDevice(), fullPath.getMeasurement());
+        String vectorPath = fullPath.getDevice();
+        return new VectorPartialPath(vectorPath, fullPath.getMeasurement());
       }
     } catch (MetadataException e) {
       throw new IOException("Cannot get node from " + device, e);