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

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


The following commit(s) were added to refs/heads/new_vector by this push:
     new 6b10062  [To new_vector] Eliminate getExactFullPath and refactor 
groupAlignedPaths (#4283)
6b10062 is described below

commit 6b10062aab36fd6881be27a9e343993cff5bdbe7
Author: Marcos_Zyk <[email protected]>
AuthorDate: Mon Nov 1 11:41:26 2021 +0800

    [To new_vector] Eliminate getExactFullPath and refactor groupAlignedPaths 
(#4283)
---
 .../cluster/query/ClusterDataQueryExecutor.java    |  2 +-
 .../cluster/query/ClusterPhysicalGenerator.java    |  3 +-
 .../cluster/query/reader/ClusterReaderFactory.java |  4 +-
 .../query/reader/mult/RemoteMultSeriesReader.java  |  2 +-
 .../org/apache/iotdb/db/metadata/MManager.java     | 35 +-----------------
 .../iotdb/db/metadata/mnode/MeasurementMNode.java  |  1 +
 .../org/apache/iotdb/db/metadata/mtree/MTree.java  |  7 +---
 .../apache/iotdb/db/metadata/path/AlignedPath.java | 43 +++++++++-------------
 .../iotdb/db/metadata/path/MeasurementPath.java    | 11 ++++++
 .../apache/iotdb/db/metadata/path/PartialPath.java | 17 ---------
 .../apache/iotdb/db/metadata/utils/MetaUtils.java  | 34 +++++++++++++++++
 .../iotdb/db/qp/physical/crud/AggregationPlan.java |  4 +-
 .../iotdb/db/qp/physical/crud/QueryPlan.java       |  2 +-
 .../iotdb/db/qp/strategy/PhysicalGenerator.java    |  4 +-
 .../iotdb/db/qp/utils/GroupByLevelController.java  |  2 +-
 .../query/expression/unary/TimeSeriesOperand.java  |  2 +-
 .../apache/iotdb/db/metadata/MetaUtilsTest.java    | 31 ++++++++++++++++
 17 files changed, 111 insertions(+), 93 deletions(-)

diff --git 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java
 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java
index 29470f3..c9eddd8 100644
--- 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java
+++ 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterDataQueryExecutor.java
@@ -129,7 +129,7 @@ public class ClusterDataQueryExecutor extends 
RawDataQueryExecutor {
     for (int i = 0; i < queryPlan.getDeduplicatedPaths().size(); i++) {
       PartialPath partialPath = queryPlan.getDeduplicatedPaths().get(i);
       TSDataType dataType = queryPlan.getDeduplicatedDataTypes().get(i);
-      String fullPath = partialPath.getExactFullPath();
+      String fullPath = partialPath.getFullPath();
       AssignPathManagedMergeReader assignPathManagedMergeReader =
           new AssignPathManagedMergeReader(fullPath, dataType);
       for (AbstractMultPointReader multPointReader : multPointReaders) {
diff --git 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPhysicalGenerator.java
 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPhysicalGenerator.java
index 6e631cd..49abc08 100644
--- 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPhysicalGenerator.java
+++ 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPhysicalGenerator.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.metadata.MetadataException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.metadata.path.PartialPath;
+import org.apache.iotdb.db.metadata.utils.MetaUtils;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.logical.crud.QueryOperator;
 import 
org.apache.iotdb.db.qp.logical.sys.LoadConfigurationOperator.LoadConfigurationOperatorType;
@@ -66,7 +67,7 @@ public class ClusterPhysicalGenerator extends 
PhysicalGenerator {
 
   @Override
   public List<PartialPath> groupVectorPaths(List<PartialPath> paths) throws 
MetadataException {
-    return getCMManager().groupAlignedPaths(paths);
+    return MetaUtils.groupAlignedPaths(paths);
   }
 
   @Override
diff --git 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
index fcdff7c..881d16f 100644
--- 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
+++ 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
@@ -340,7 +340,7 @@ public class ClusterReaderFactory {
                 dataGroupMember,
                 ascending,
                 null);
-        partialPathPointReaderMap.put(partialPath.getExactFullPath(), 
seriesPointReader);
+        partialPathPointReaderMap.put(partialPath.getFullPath(), 
seriesPointReader);
       }
 
       if (logger.isDebugEnabled()) {
@@ -1125,7 +1125,7 @@ public class ClusterReaderFactory {
               ascending,
               null,
               false);
-      partialPathBatchReaderMap.put(partialPath.getExactFullPath(), 
batchReader);
+      partialPathBatchReaderMap.put(partialPath.getFullPath(), batchReader);
     }
     return new MultBatchReader(partialPathBatchReaderMap);
   }
diff --git 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReader.java
 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReader.java
index e80fc1e..cec009d 100644
--- 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReader.java
+++ 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReader.java
@@ -73,7 +73,7 @@ public class RemoteMultSeriesReader extends 
AbstractMultPointReader {
     this.cachedBatchs = Maps.newHashMap();
     this.pathToDataType = Maps.newHashMap();
     for (int i = 0; i < sourceInfo.getPartialPaths().size(); i++) {
-      String fullPath = sourceInfo.getPartialPaths().get(i).getExactFullPath();
+      String fullPath = sourceInfo.getPartialPaths().get(i).getFullPath();
       this.cachedBatchs.put(fullPath, new ConcurrentLinkedQueue<>());
       this.pathToDataType.put(fullPath, sourceInfo.getDataTypes().get(i));
     }
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 3b49634..7e90243 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
@@ -104,7 +104,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -644,7 +643,7 @@ public class MManager {
 
       Set<String> failedNames = new HashSet<>();
       for (PartialPath p : allTimeseries) {
-        deleteSingleTimeseriesInternal(p.getExactPath(), failedNames);
+        deleteSingleTimeseriesInternal(p, failedNames);
       }
       return failedNames.isEmpty() ? null : String.join(",", failedNames);
     } catch (IOException e) {
@@ -1065,36 +1064,6 @@ public class MManager {
   // region Interfaces for timeseries, measurement and schema info Query
 
   /**
-   * PartialPath of aligned time series will be organized to one AlignedPath. 
BEFORE this method,
-   * all the aligned time series is NOT united. For example, given 
root.sg.d1.vector1[s1] and
-   * root.sg.d1.vector1[s2], they will be organized to root.sg.d1.vector1 
[s1,s2]
-   *
-   * @param fullPaths full path list without uniting the sub measurement under 
the same aligned time
-   *     series.
-   * @return Size of partial path list could NOT equal to the input list size. 
For example, the
-   *     vector1 (s1,s2) would be returned once.
-   */
-  public List<PartialPath> groupAlignedPaths(List<PartialPath> fullPaths) 
throws MetadataException {
-    Map<String, PartialPath> nodeToPartialPath = new LinkedHashMap<>();
-    for (PartialPath path : fullPaths) {
-      String fullPath = path.getFullPath();
-      if (!nodeToPartialPath.containsKey(fullPath)) {
-        nodeToPartialPath.put(fullPath, path.copy());
-      } else {
-        // if nodeToPartialPath contains node
-        PartialPath existPath = nodeToPartialPath.get(fullPath);
-        if (!existPath.equals(path)) {
-          // could be AlignedPath
-          AlignedPath alignedPath = (AlignedPath) path;
-          ((AlignedPath) existPath)
-              .addMeasurement(alignedPath.getMeasurementList(), 
alignedPath.getSchemaList());
-        }
-      }
-    }
-    return new ArrayList<>(nodeToPartialPath.values());
-  }
-
-  /**
    * Return all measurement paths for given path if the path is abstract. Or 
return the path itself.
    * Regular expression in this method is formed by the amalgamation of 
seriesPath and the character
    * '*'.
@@ -1194,7 +1163,7 @@ public class MManager {
         }
         res.add(
             new ShowTimeSeriesResult(
-                ansString.left.getExactFullPath(),
+                ansString.left.getFullPath(),
                 ansString.right[0],
                 ansString.right[1],
                 TSDataType.valueOf(ansString.right[2]),
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
index cf0ab23..5289765 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
@@ -84,6 +84,7 @@ public class MeasurementMNode extends MNode implements 
IMeasurementMNode {
   public MeasurementPath getMeasurementPath() {
     MeasurementPath result = new MeasurementPath(super.getPartialPath());
     result.setMeasurementSchema(schema);
+    result.setUnderAlignedEntity(getParent().isAligned());
     return result;
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
index c89616d..c29502f 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
@@ -45,7 +45,6 @@ import 
org.apache.iotdb.db.metadata.mtree.traverser.counter.EntityCounter;
 import org.apache.iotdb.db.metadata.mtree.traverser.counter.MNodeLevelCounter;
 import org.apache.iotdb.db.metadata.mtree.traverser.counter.MeasurementCounter;
 import 
org.apache.iotdb.db.metadata.mtree.traverser.counter.StorageGroupCounter;
-import org.apache.iotdb.db.metadata.path.AlignedPath;
 import org.apache.iotdb.db.metadata.path.MeasurementPath;
 import org.apache.iotdb.db.metadata.path.PartialPath;
 import org.apache.iotdb.db.metadata.template.Template;
@@ -916,11 +915,7 @@ public class MTree implements Serializable {
               // only when user query with alias, the alias in path will be set
               path.setMeasurementAlias(node.getAlias());
             }
-            if (node.getParent().isAligned()) {
-              result.add(new AlignedPath(path));
-            } else {
-              result.add(path);
-            }
+            result.add(path);
           }
         };
     collector.traverse();
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/path/AlignedPath.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/path/AlignedPath.java
index 88e1348..d325291 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/path/AlignedPath.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/path/AlignedPath.java
@@ -26,7 +26,6 @@ import org.apache.iotdb.db.query.context.QueryContext;
 import org.apache.iotdb.db.query.filter.TsFileFilter;
 import org.apache.iotdb.db.query.reader.series.AlignedSeriesReader;
 import org.apache.iotdb.db.utils.TestOnly;
-import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
 import org.apache.iotdb.tsfile.read.filter.basic.Filter;
@@ -96,19 +95,31 @@ public class AlignedPath extends PartialPath {
     this.measurementList = measurementList;
   }
 
-  public void addMeasurement(String subSensor) {
-    this.measurementList.add(subSensor);
+  public void addMeasurement(String measurement) {
+    this.measurementList.add(measurement);
   }
 
-  public void addMeasurement(List<String> subSensors) {
-    this.measurementList.addAll(subSensors);
+  public void addMeasurement(List<String> measurements) {
+    this.measurementList.addAll(measurements);
   }
 
-  public void addMeasurement(List<String> measurementList, 
List<IMeasurementSchema> schemaList) {
-    this.measurementList.addAll(measurementList);
+  public void addMeasurement(MeasurementPath measurementPath) {
+    if (measurementList == null) {
+      measurementList = new ArrayList<>();
+    }
+    measurementList.add(measurementPath.getMeasurement());
+
     if (schemaList == null) {
       schemaList = new ArrayList<>();
     }
+    schemaList.add(measurementPath.getMeasurementSchema());
+  }
+
+  public void addMeasurement(List<String> measurementList, 
List<IMeasurementSchema> schemaList) {
+    this.measurementList.addAll(measurementList);
+    if (this.schemaList == null) {
+      this.schemaList = new ArrayList<>();
+    }
     this.schemaList.addAll(schemaList);
   }
 
@@ -163,24 +174,6 @@ public class AlignedPath extends PartialPath {
   }
 
   @Override
-  public PartialPath getExactPath() {
-    PartialPath path = super.getExactPath();
-    if (measurementList.size() == 1) {
-      return path.concatNode(measurementList.get(0));
-    }
-    return path;
-  }
-
-  @Override
-  public String getExactFullPath() {
-    fullPath = getFullPath();
-    if (measurementList.size() == 1) {
-      return fullPath + TsFileConstant.PATH_SEPARATOR + measurementList.get(0);
-    }
-    return fullPath;
-  }
-
-  @Override
   public AlignedSeriesReader createSeriesReader(
       Set<String> allSensors,
       TSDataType dataType,
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/path/MeasurementPath.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/path/MeasurementPath.java
index a8ea436..1861d65 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/metadata/path/MeasurementPath.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/metadata/path/MeasurementPath.java
@@ -35,6 +35,9 @@ import java.util.Set;
 public class MeasurementPath extends PartialPath {
 
   private IMeasurementSchema measurementSchema;
+
+  private boolean isUnderAlignedEntity = false;
+
   // alias of measurement, null pointer cannot be serialized in thrift so 
empty string is instead
   private String measurementAlias = "";
 
@@ -71,6 +74,14 @@ public class MeasurementPath extends PartialPath {
     return getDevice() + IoTDBConstant.PATH_SEPARATOR + measurementAlias;
   }
 
+  public boolean isUnderAlignedEntity() {
+    return isUnderAlignedEntity;
+  }
+
+  public void setUnderAlignedEntity(boolean underAlignedEntity) {
+    isUnderAlignedEntity = underAlignedEntity;
+  }
+
   public PartialPath copy() {
     MeasurementPath result = new MeasurementPath();
     result.nodes = nodes;
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/path/PartialPath.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/path/PartialPath.java
index d7ff076..fde7705 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/path/PartialPath.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/path/PartialPath.java
@@ -363,23 +363,6 @@ public class PartialPath extends Path implements 
Comparable<Path> {
     return ret;
   }
 
-  // todo eliminate such "exact" related logic in future work
-  /**
-   * If the partialPath is AlignedPath and it has only one measurement, return 
the measurement's
-   * PartialPath. Otherwise, return this partialPath
-   */
-  public PartialPath getExactPath() {
-    return this;
-  }
-
-  /**
-   * If the partialPath is AlignedPath and it has only one measurement, return 
the measurement's
-   * full path. Otherwise, return the partialPath's fullPath
-   */
-  public String getExactFullPath() {
-    return getFullPath();
-  }
-
   public SeriesReader createSeriesReader(
       Set<String> allSensors,
       TSDataType dataType,
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/utils/MetaUtils.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/utils/MetaUtils.java
index 035f4a1..d3f5916 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/utils/MetaUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/utils/MetaUtils.java
@@ -22,11 +22,15 @@ import org.apache.iotdb.db.conf.IoTDBConstant;
 import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.exception.metadata.MetadataException;
 import org.apache.iotdb.db.metadata.mnode.IMNode;
+import org.apache.iotdb.db.metadata.path.AlignedPath;
+import org.apache.iotdb.db.metadata.path.MeasurementPath;
 import org.apache.iotdb.db.metadata.path.PartialPath;
 import org.apache.iotdb.db.utils.TestOnly;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -104,6 +108,36 @@ public class MetaUtils {
     return new PartialPath(storageGroupNodes);
   }
 
+  /**
+   * PartialPath of aligned time series will be organized to one AlignedPath. 
BEFORE this method,
+   * all the aligned time series is NOT united. For example, given 
root.sg.d1.vector1[s1] and
+   * root.sg.d1.vector1[s2], they will be organized to root.sg.d1.vector1 
[s1,s2]
+   *
+   * @param fullPaths full path list without uniting the sub measurement under 
the same aligned time
+   *     series.
+   * @return Size of partial path list could NOT equal to the input list size. 
For example, the
+   *     vector1 (s1,s2) would be returned once.
+   */
+  public static List<PartialPath> groupAlignedPaths(List<PartialPath> 
fullPaths) {
+    List<PartialPath> result = new LinkedList<>();
+    Map<String, AlignedPath> alignedEntityToPath = new HashMap<>();
+    for (PartialPath path : fullPaths) {
+      MeasurementPath measurementPath = (MeasurementPath) path;
+      if (!measurementPath.isUnderAlignedEntity()) {
+        result.add(measurementPath);
+      } else {
+        String entity = measurementPath.getDevice();
+        if (!alignedEntityToPath.containsKey(entity)) {
+          alignedEntityToPath.put(entity, new AlignedPath(measurementPath));
+        } else {
+          alignedEntityToPath.get(entity).addMeasurement(measurementPath);
+        }
+      }
+    }
+    result.addAll(alignedEntityToPath.values());
+    return result;
+  }
+
   @TestOnly
   public static List<String> getMultiFullPaths(IMNode node) {
     if (node == null) {
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AggregationPlan.java
 
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AggregationPlan.java
index 41c8cd7..3943a74 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AggregationPlan.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AggregationPlan.java
@@ -93,7 +93,7 @@ public class AggregationPlan extends RawDataQueryPlan {
       String rawPath =
           String.format(
               "%s(%s)",
-              deduplicatedAggregations.get(i), 
getDeduplicatedPaths().get(i).getExactFullPath());
+              deduplicatedAggregations.get(i), 
getDeduplicatedPaths().get(i).getFullPath());
       String transformedPath = groupByLevelController.getGroupedPath(rawPath);
       AggregateResult result = groupPathsResultMap.get(transformedPath);
       if (result == null) {
@@ -124,7 +124,7 @@ public class AggregationPlan extends RawDataQueryPlan {
       String functionName = aggregations.get(pathIndex);
       String aggregatePath =
           groupByLevelController.getGroupedPath(
-              String.format("%s(%s)", functionName, path.getExactFullPath()));
+              String.format("%s(%s)", functionName, path.getFullPath()));
       columnForDisplay = aggregatePath;
     }
     return columnForDisplay;
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/QueryPlan.java 
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/QueryPlan.java
index 9a79a3c..c00f479 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/QueryPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/QueryPlan.java
@@ -136,7 +136,7 @@ public abstract class QueryPlan extends PhysicalPlan {
 
   public String getColumnForReaderFromPath(PartialPath path, int pathIndex) {
     ResultColumn resultColumn = resultColumns.get(pathIndex);
-    return resultColumn.hasAlias() ? resultColumn.getAlias() : 
path.getExactFullPath();
+    return resultColumn.hasAlias() ? resultColumn.getAlias() : 
path.getFullPath();
   }
 
   public String getColumnForDisplay(String columnForReader, int pathIndex) {
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java 
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
index c1d7e11..8e9816b 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
@@ -21,12 +21,12 @@ package org.apache.iotdb.db.qp.strategy;
 import org.apache.iotdb.db.exception.metadata.MetadataException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.metadata.path.PartialPath;
+import org.apache.iotdb.db.metadata.utils.MetaUtils;
 import org.apache.iotdb.db.qp.logical.Operator;
 import 
org.apache.iotdb.db.qp.logical.sys.LoadConfigurationOperator.LoadConfigurationOperatorType;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.sys.LoadConfigurationPlan;
 import 
org.apache.iotdb.db.qp.physical.sys.LoadConfigurationPlan.LoadConfigurationPlanType;
-import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.db.utils.SchemaUtils;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 
@@ -59,6 +59,6 @@ public class PhysicalGenerator {
   }
 
   public List<PartialPath> groupVectorPaths(List<PartialPath> paths) throws 
MetadataException {
-    return IoTDB.metaManager.groupAlignedPaths(paths);
+    return MetaUtils.groupAlignedPaths(paths);
   }
 }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/utils/GroupByLevelController.java 
b/server/src/main/java/org/apache/iotdb/db/qp/utils/GroupByLevelController.java
index 6110f95..7afa82e 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/qp/utils/GroupByLevelController.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/qp/utils/GroupByLevelController.java
@@ -81,7 +81,7 @@ public class GroupByLevelController {
         String functionName = ((FunctionExpression) 
expression).getFunctionName();
         String groupedPath =
             generatePartialPathByLevel(isCountStar, paths.get(0).getNodes(), 
levels);
-        String rawPath = String.format("%s(%s)", functionName, 
paths.get(0).getExactFullPath());
+        String rawPath = String.format("%s(%s)", functionName, 
paths.get(0).getFullPath());
         String pathWithFunction = String.format("%s(%s)", functionName, 
groupedPath);
 
         if (seriesLimit == 0 && seriesOffset == 0) {
diff --git 
a/server/src/main/java/org/apache/iotdb/db/query/expression/unary/TimeSeriesOperand.java
 
b/server/src/main/java/org/apache/iotdb/db/query/expression/unary/TimeSeriesOperand.java
index 02134d2..eb08fd4 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/query/expression/unary/TimeSeriesOperand.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/query/expression/unary/TimeSeriesOperand.java
@@ -116,6 +116,6 @@ public class TimeSeriesOperand extends Expression {
 
   @Override
   public String toString() {
-    return path.isMeasurementAliasExists() ? path.getFullPathWithAlias() : 
path.getExactFullPath();
+    return path.isMeasurementAliasExists() ? path.getFullPathWithAlias() : 
path.getFullPath();
   }
 }
diff --git 
a/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java 
b/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java
index ea17917..14a597d 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java
@@ -19,16 +19,22 @@
 package org.apache.iotdb.db.metadata;
 
 import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
 import org.apache.iotdb.db.metadata.mnode.InternalMNode;
+import org.apache.iotdb.db.metadata.path.AlignedPath;
+import org.apache.iotdb.db.metadata.path.MeasurementPath;
+import org.apache.iotdb.db.metadata.path.PartialPath;
 import org.apache.iotdb.db.metadata.utils.MetaUtils;
 
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 public class MetaUtilsTest {
@@ -123,4 +129,29 @@ public class MetaUtilsTest {
           }
         });
   }
+
+  @Test
+  public void testGroupAlignedPath() throws MetadataException {
+    List<PartialPath> pathList = new ArrayList<>();
+
+    MeasurementPath path1 = new MeasurementPath(new 
PartialPath("root.sg.device.s1"));
+    pathList.add(path1);
+    MeasurementPath path2 = new MeasurementPath(new 
PartialPath("root.sg.device.s2"));
+    pathList.add(path2);
+
+    MeasurementPath path3 = new MeasurementPath(new 
PartialPath("root.sg.aligned_device.s1"));
+    path3.setUnderAlignedEntity(true);
+    pathList.add(path3);
+    MeasurementPath path4 = new MeasurementPath(new 
PartialPath("root.sg.aligned_device.s2"));
+    path4.setUnderAlignedEntity(true);
+    pathList.add(path4);
+
+    AlignedPath alignedPath = new AlignedPath(path3);
+    alignedPath.addMeasurement(path4);
+
+    List<PartialPath> result = MetaUtils.groupAlignedPaths(pathList);
+    assertTrue(result.contains(path1));
+    assertTrue(result.contains(path2));
+    assertTrue(result.contains(alignedPath));
+  }
 }

Reply via email to