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

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

commit 5fa0eb293df62734555d59fcc97122e4dfa3a5fd
Author: Jincheng Sun <[email protected]>
AuthorDate: Thu Apr 29 15:14:55 2021 +0800

    [IoTDB-1331] Add transformPath for CMManger
---
 .../java/org/apache/iotdb/cluster/metadata/CMManager.java | 15 +++++++++++++++
 .../main/java/org/apache/iotdb/db/metadata/MManager.java  | 15 ++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git 
a/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java 
b/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
index 3524db8..7849f0e 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
@@ -81,6 +81,7 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
 import org.apache.iotdb.tsfile.read.TimeValuePair;
 import org.apache.iotdb.tsfile.utils.Pair;
 import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
+import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 import org.apache.iotdb.tsfile.write.schema.TimeseriesSchema;
 import org.apache.iotdb.tsfile.write.schema.VectorMeasurementSchema;
 
@@ -265,6 +266,20 @@ public class CMManager extends MManager {
     return super.getSeriesSchema(fullPath, getMeasurementMNode(fullPath));
   }
 
+  /**
+   * Transform the PartialPath to VectorPartialPath if it is a sub sensor of 
one vector. otherwise,
+   * we don't change it.
+   */
+  @Override
+  public PartialPath transformPath(PartialPath partialPath) throws 
MetadataException {
+    MeasurementMNode node = getMeasurementMNode(partialPath);
+    if (node.getSchema() instanceof MeasurementSchema) {
+      return partialPath;
+    } else {
+      return toVectorPath(partialPath, node.getName());
+    }
+  }
+
   private MeasurementMNode getMeasurementMNode(PartialPath fullPath) throws 
MetadataException {
     MeasurementMNode node = null;
     // try remote cache first
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 5e35f82..e03b1ba 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -1190,7 +1190,7 @@ public class MManager {
   }
 
   /**
-   * transform the PartialPath to VectorPartialPath if it is a sub sensor of 
one vector otherwise,
+   * Transform the PartialPath to VectorPartialPath if it is a sub sensor of 
one vector. otherwise,
    * we don't change it.
    */
   public PartialPath transformPath(PartialPath partialPath) throws 
MetadataException {
@@ -1198,13 +1198,18 @@ public class MManager {
     if (node.getSchema() instanceof MeasurementSchema) {
       return partialPath;
     } else {
-      List<PartialPath> subSensorsPathList = new ArrayList<>();
-      subSensorsPathList.add(partialPath);
-      return new VectorPartialPath(
-          partialPath.getDevice() + "." + node.getName(), subSensorsPathList);
+      return toVectorPath(partialPath, node.getName());
     }
   }
 
+  /** Convert the PartialPath to VectorPartialPath. */
+  protected VectorPartialPath toVectorPath(PartialPath partialPath, String 
name)
+      throws MetadataException {
+    List<PartialPath> subSensorsPathList = new ArrayList<>();
+    subSensorsPathList.add(partialPath);
+    return new VectorPartialPath(partialPath.getDevice() + "." + name, 
subSensorsPathList);
+  }
+
   /**
    * Get schema of partialPaths, in which aligned timeseries should only 
organized to one schema.
    * This method should be called when logical plan converts to physical plan.

Reply via email to