You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/09/10 02:41:36 UTC

[GitHub] [iotdb] zyk990424 commented on a change in pull request #3916: [IOTDB-1666] Implement vector support align by device

zyk990424 commented on a change in pull request #3916:
URL: https://github.com/apache/iotdb/pull/3916#discussion_r705847641



##########
File path: server/src/main/java/org/apache/iotdb/db/query/dataset/AlignByDeviceDataSet.java
##########
@@ -230,14 +230,29 @@ public boolean hasNextWithoutConstraint() throws IOException {
   protected Set<String> getDeviceMeasurements(PartialPath device) throws IOException {
     try {
       IMNode deviceNode = IoTDB.metaManager.getNodeByPath(device);
-      Set<String> res = new HashSet<>(deviceNode.getChildren().keySet());
+      Set<String> res = new HashSet<>();
       for (IMNode mnode : deviceNode.getChildren().values()) {
-        res.addAll(mnode.getChildren().keySet());
+        IMeasurementSchema measurementSchema = ((MeasurementMNode) mnode).getSchema();
+        if (measurementSchema instanceof VectorMeasurementSchema) {
+          for (String subMeasurement : measurementSchema.getSubMeasurementsList()) {
+            res.add(measurementSchema.getMeasurementId() + "." + subMeasurement);
+          }
+        } else {
+          res.add(mnode.getName());
+        }

Review comment:
       I suggest encapsulate this measurement access in MManager. It's better not use MNode outside the metadata module.

##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
##########
@@ -1419,16 +1419,16 @@ private void addVectorMeasurementSchema(
       String[] tsRow = new String[7];
       tsRow[0] = null;
       tsRow[1] = getStorageGroupPath(devicePath).getFullPath();
-      tsRow[2] = schema.getValueTSDataTypeList().get(i).toString();
-      tsRow[3] = schema.getValueTSEncodingList().get(i).toString();
+      tsRow[2] = schema.getSubMeasurementsTSDataTypeList().get(i).toString();
+      tsRow[3] = schema.getSubMeasurementsTSEncodingList().get(i).toString();
       tsRow[4] = schema.getCompressor().toString();
       tsRow[5] = "-1";
       tsRow[6] =
           needLast
               ? String.valueOf(getLastTimeStamp((IMeasurementMNode) node, queryContext))
               : null;
       Pair<PartialPath, String[]> temp =
-          new Pair<>(new PartialPath(devicePath.getFullPath(), measurements.get(i)), tsRow);
+          new Pair<>(new VectorPartialPath(devicePath.getFullPath(), measurements.get(i)), tsRow);

Review comment:
       This is the key modification. I got it.

##########
File path: server/src/main/java/org/apache/iotdb/db/query/dataset/AlignByDeviceDataSet.java
##########
@@ -246,6 +261,20 @@ public boolean hasNextWithoutConstraint() throws IOException {
     }
   }
 
+  private PartialPath transformPath(PartialPath device, String measurement) throws IOException {
+    try {
+      PartialPath fullPath = new PartialPath(device.getFullPath(), measurement);
+      MeasurementMNode node = (MeasurementMNode) IoTDB.metaManager.getNodeByPath(fullPath);
+      if (node.getSchema() instanceof MeasurementSchema) {
+        return fullPath;
+      } else {
+        return new VectorPartialPath(fullPath.getDevice(), fullPath.getMeasurement());
+      }
+    } catch (MetadataException e) {
+      throw new IOException("Cannot get node from " + device, e);
+    }

Review comment:
       Same above




-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org