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

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


The following commit(s) were added to refs/heads/aggrVector by this push:
     new 8d51377  lots of bugs
8d51377 is described below

commit 8d51377d79f02e3c15aefe48dad81d10809b3349
Author: Alima777 <[email protected]>
AuthorDate: Mon Sep 6 16:28:53 2021 +0800

    lots of bugs
---
 .../apache/iotdb/cluster/metadata/CMManager.java   |  36 +++----
 .../iotdb/cluster/query/LocalQueryExecutor.java    |   2 +-
 .../iotdb/AlignedTimeseriesSessionExample.java     |  16 +--
 .../iotdb/db/engine/merge/recover/LogAnalyzer.java |   2 +-
 .../org/apache/iotdb/db/metadata/MManager.java     |  11 +--
 .../java/org/apache/iotdb/db/metadata/MTree.java   | 110 ++++++++++-----------
 .../iotdb/db/metadata/VectorPartialPath.java       |   6 ++
 .../org/apache/iotdb/db/metadata/mnode/MNode.java  |   8 ++
 .../apache/iotdb/db/qp/executor/PlanExecutor.java  |   2 +-
 .../iotdb/db/qp/logical/crud/QueryOperator.java    |  15 ++-
 .../iotdb/db/qp/physical/crud/LastQueryPlan.java   |   2 -
 .../db/qp/physical/crud/RawDataQueryPlan.java      |  28 ++----
 .../qp/strategy/optimizer/ConcatPathOptimizer.java |   3 +-
 .../apache/iotdb/db/qp/utils/WildcardsRemover.java |   2 +-
 .../db/query/dataset/AlignByDeviceDataSet.java     |  21 ++--
 .../iotdb/db/query/executor/QueryRouter.java       |   7 --
 .../org/apache/iotdb/db/service/TSServiceImpl.java |   2 +-
 .../iotdb/db/metadata/MManagerAdvancedTest.java    |  12 +--
 .../iotdb/db/metadata/MManagerBasicTest.java       |   2 +-
 .../org/apache/iotdb/db/metadata/MTreeTest.java    |  21 ++--
 20 files changed, 142 insertions(+), 166 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 dcfc0ae..d873338 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
@@ -998,7 +998,7 @@ public class CMManager extends MManager {
         } catch (CheckConsistencyException e) {
           logger.warn("Failed to check consistency.", e);
         }
-        List<PartialPath> allTimeseriesName = 
getMatchedPathsLocally(pathUnderSG, withAlias);
+        List<PartialPath> allTimeseriesName = 
getAllTimeseriesPaths(pathUnderSG);
         logger.debug(
             "{}: get matched paths of {} locally, result {}",
             metaGroupMember.getName(),
@@ -1023,15 +1023,6 @@ public class CMManager extends MManager {
     return result;
   }
 
-  private List<PartialPath> getMatchedPathsLocally(PartialPath partialPath, 
boolean withAlias)
-      throws MetadataException {
-    if (!withAlias) {
-      return getAllTimeseriesPath(partialPath);
-    } else {
-      return super.getAllTimeseriesPathWithAlias(partialPath, -1, -1).left;
-    }
-  }
-
   private List<PartialPath> getMatchedPaths(
       PartitionGroup partitionGroup, List<String> pathsToQuery, boolean 
withAlias)
       throws MetadataException {
@@ -1229,7 +1220,7 @@ public class CMManager extends MManager {
 
   /** Similar to method getAllTimeseriesPath(), but return Path with alias 
alias. */
   @Override
-  public Pair<List<PartialPath>, Integer> getAllTimeseriesPathWithAlias(
+  public Pair<List<PartialPath>, Integer> getAllTimeseriesPathsWithAlias(
       PartialPath prefixPath, int limit, int offset) throws MetadataException {
 
     // get all storage groups this path may belong to
@@ -1323,7 +1314,7 @@ public class CMManager extends MManager {
   public List<String> getAllPaths(List<String> paths) throws MetadataException 
{
     List<String> ret = new ArrayList<>();
     for (String path : paths) {
-      getAllTimeseriesPath(new PartialPath(path)).stream()
+      getAllTimeseriesPaths(new PartialPath(path)).stream()
           .map(PartialPath::getFullPath)
           .forEach(ret::add);
     }
@@ -1729,27 +1720,22 @@ public class CMManager extends MManager {
 
   public GetAllPathsResult getAllPaths(List<String> paths, boolean withAlias)
       throws MetadataException {
-    List<String> retPaths = new ArrayList<>();
+    List<PartialPath> retPaths = new ArrayList<>();
     List<String> alias = null;
-    if (withAlias) {
-      alias = new ArrayList<>();
+    for (String path : paths) {
+      retPaths.addAll(getAllTimeseriesPaths(new PartialPath(path)));
     }
 
     if (withAlias) {
-      for (String path : paths) {
-        List<PartialPath> allTimeseriesPathWithAlias =
-            super.getAllTimeseriesPathWithAlias(new PartialPath(path), -1, 
-1).left;
-        for (PartialPath timeseriesPathWithAlias : allTimeseriesPathWithAlias) 
{
-          retPaths.add(timeseriesPathWithAlias.getFullPath());
-          alias.add(timeseriesPathWithAlias.getMeasurementAlias());
-        }
+      alias = new ArrayList<>();
+      for (PartialPath path : retPaths) {
+        alias.add(path.getMeasurementAlias());
       }
-    } else {
-      retPaths = getAllPaths(paths);
     }
 
     GetAllPathsResult getAllPathsResult = new GetAllPathsResult();
-    getAllPathsResult.setPaths(retPaths);
+    getAllPathsResult.setPaths(
+        
retPaths.stream().map(PartialPath::getFullPath).collect(Collectors.toList()));
     getAllPathsResult.setAliasList(alias);
     return getAllPathsResult;
   }
diff --git 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/LocalQueryExecutor.java 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/LocalQueryExecutor.java
index 0175ef9..8a362ac 100644
--- 
a/cluster/src/main/java/org/apache/iotdb/cluster/query/LocalQueryExecutor.java
+++ 
b/cluster/src/main/java/org/apache/iotdb/cluster/query/LocalQueryExecutor.java
@@ -774,7 +774,7 @@ public class LocalQueryExecutor {
     List<String> result = new ArrayList<>();
     for (String seriesPath : timeseriesList) {
       try {
-        List<PartialPath> path = getCMManager().getAllTimeseriesPath(new 
PartialPath(seriesPath));
+        List<PartialPath> path = getCMManager().getAllTimeseriesPaths(new 
PartialPath(seriesPath));
         if (path.size() != 1) {
           throw new MetadataException(
               String.format("Timeseries number of the name [%s] is not 1.", 
seriesPath));
diff --git 
a/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java
 
b/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java
index bf43a61..691ddb4 100644
--- 
a/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java
+++ 
b/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java
@@ -52,13 +52,13 @@ public class AlignedTimeseriesSessionExample {
     // set session fetchSize
     session.setFetchSize(10000);
 
-    createTemplate();
-    createAlignedTimeseries();
-    insertAlignedRecord();
-
-    insertTabletWithAlignedTimeseriesMethod1();
-    insertTabletWithAlignedTimeseriesMethod2();
-    insertNullableTabletWithAlignedTimeseries();
+    //    createTemplate();
+    //    createAlignedTimeseries();
+    //    insertAlignedRecord();
+    //
+    //    insertTabletWithAlignedTimeseriesMethod1();
+    //    insertTabletWithAlignedTimeseriesMethod2();
+    //    insertNullableTabletWithAlignedTimeseries();
 
     selectTest();
     selectWithValueFilterTest();
@@ -67,7 +67,7 @@ public class AlignedTimeseriesSessionExample {
 
     selectWithAggregationTest();
 
-    // selectWithAlignByDeviceTest();
+    selectWithAlignByDeviceTest();
 
     session.close();
   }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/LogAnalyzer.java
 
b/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/LogAnalyzer.java
index 9693d3c..287ac63 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/LogAnalyzer.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/LogAnalyzer.java
@@ -103,7 +103,7 @@ public class LogAnalyzer {
         analyzeUnseqFiles(bufferedReader);
 
         List<PartialPath> storageGroupPaths =
-            IoTDB.metaManager.getAllTimeseriesPath(new 
PartialPath(storageGroupName + ".*"));
+            IoTDB.metaManager.getAllTimeseriesPaths(new 
PartialPath(storageGroupName + ".*"));
         unmergedPaths = new ArrayList<>();
         unmergedPaths.addAll(storageGroupPaths);
 
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 fc533c5..bd700ad 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
@@ -592,7 +592,7 @@ public class MManager {
       mNodeCache.clear();
     }
     try {
-      List<PartialPath> allTimeseries = mtree.getAllTimeseriesPath(prefixPath);
+      List<PartialPath> allTimeseries = 
mtree.getAllTimeseriesPaths(prefixPath);
       if (allTimeseries.isEmpty()) {
         throw new PathNotExistException(prefixPath.getFullPath());
       }
@@ -874,14 +874,13 @@ public class MManager {
    * @param prefixPath can be a prefix or a full path. if the wildcard is not 
at the tail, then each
    *     wildcard can only match one level, otherwise it can match to the tail.
    */
-  public List<PartialPath> getAllTimeseriesPath(PartialPath prefixPath) throws 
MetadataException {
-    return mtree.getAllTimeseriesPath(prefixPath);
+  public List<PartialPath> getAllTimeseriesPaths(PartialPath prefixPath) 
throws MetadataException {
+    return mtree.getAllTimeseriesPaths(prefixPath);
   }
 
-  /** Similar to method getAllTimeseriesPath(), but return Path with alias. */
-  public Pair<List<PartialPath>, Integer> getAllTimeseriesPathWithAlias(
+  public Pair<List<PartialPath>, Integer> getAllTimeseriesPathsWithAlias(
       PartialPath prefixPath, int limit, int offset) throws MetadataException {
-    return mtree.getAllTimeseriesPathWithAlias(prefixPath, limit, offset);
+    return mtree.getAllTimeseriesPaths(prefixPath, limit, offset);
   }
 
   /** To calculate the count of timeseries for given prefix path. */
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
index 27c43e1..bfa1b74 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
@@ -968,48 +968,6 @@ public class MTree implements Serializable {
   }
 
   /**
-   * Get all timeseries under the given path
-   *
-   * @param prefixPath a prefix path or a full path, may contain '*'.
-   */
-  List<PartialPath> getAllTimeseriesPath(PartialPath prefixPath) throws 
MetadataException {
-    List<PartialPath> resultPathList = new ArrayList<>();
-    findPath(root, prefixPath.getNodes(), 1, resultPathList, null);
-    return resultPathList;
-  }
-
-  /**
-   * Get all timeseries paths under the given path
-   *
-   * @param prefixPath a prefix path or a full path, may contain '*'.
-   * @return Pair.left contains all the satisfied paths Pair.right means the 
current offset or zero
-   *     if we don't set offset.
-   */
-  Pair<List<PartialPath>, Integer> getAllTimeseriesPathWithAlias(
-      PartialPath prefixPath, int limit, int offset) throws MetadataException {
-    PartialPath prePath = new PartialPath(prefixPath.getNodes());
-    ShowTimeSeriesPlan plan = new ShowTimeSeriesPlan(prefixPath);
-    plan.setLimit(limit);
-    plan.setOffset(offset);
-    List<String[]> res = getAllMeasurementSchema(plan, false);
-    List<PartialPath> paths = new ArrayList<>();
-    for (String[] s : res) {
-      PartialPath path = new PartialPath(s[0]);
-      if (prePath.getMeasurement().equals(s[1])) {
-        path.setMeasurementAlias(s[1]);
-      }
-      paths.add(path);
-    }
-    if (curOffset.get() == null) {
-      offset = 0;
-    } else {
-      offset = curOffset.get() + 1;
-    }
-    curOffset.remove();
-    return new Pair<>(paths, offset);
-  }
-
-  /**
    * Get the count of timeseries under the given prefix path. if prefixPath 
contains '*', then not
    * throw PathNotExistException()
    *
@@ -1191,6 +1149,39 @@ public class MTree implements Serializable {
   }
 
   /**
+   * Get all timeseries under the given path
+   *
+   * @param prefixPath a prefix path or a full path, may contain '*'.
+   */
+  List<PartialPath> getAllTimeseriesPaths(PartialPath prefixPath) throws 
MetadataException {
+    List<PartialPath> resultPathList = new ArrayList<>();
+    findAllPaths(root, prefixPath.getNodes(), 1, resultPathList, null);
+    return resultPathList;
+  }
+
+  /**
+   * Get all timeseries paths under the given path
+   *
+   * @param prefixPath a prefix path or a full path, may contain '*'.
+   * @return Pair.left contains all the satisfied paths Pair.right means the 
current offset or zero
+   *     if we don't set offset.
+   */
+  Pair<List<PartialPath>, Integer> getAllTimeseriesPaths(
+      PartialPath prefixPath, int limit, int offset) throws MetadataException {
+    List<PartialPath> paths = getAllTimeseriesPaths(prefixPath);
+    if (limit != 0 || offset != 0) {
+      int delta = offset - paths.size();
+      offset = Math.max(delta, 0);
+      if (delta > 0) {
+        return new Pair<>(new ArrayList<>(), offset);
+      } else if (paths.size() > limit + offset) {
+        paths = paths.subList(offset, offset + limit);
+      }
+    }
+    return new Pair<>(paths, offset);
+  }
+
+  /**
    * Get all time series schema under the given path order by insert frequency
    *
    * <p>result: [name, alias, storage group, dataType, encoding, compression, 
offset]
@@ -1203,7 +1194,7 @@ public class MTree implements Serializable {
     }
     List<String[]> allMatchedNodes = new ArrayList<>();
 
-    findPath(root, nodes, 1, allMatchedNodes, false, true, queryContext, null);
+    findTimeSeriesSchema(root, nodes, 1, allMatchedNodes, false, true, 
queryContext, null);
 
     Stream<String[]> sortedStream =
         allMatchedNodes.stream()
@@ -1240,7 +1231,8 @@ public class MTree implements Serializable {
     offset.set(plan.getOffset());
     curOffset.set(-1);
     count.set(0);
-    findPath(root, nodes, 1, res, offset.get() != 0 || limit.get() != 0, 
false, null, null);
+    findTimeSeriesSchema(
+        root, nodes, 1, res, offset.get() != 0 || limit.get() != 0, false, 
null, null);
     // avoid memory leaks
     limit.remove();
     offset.remove();
@@ -1257,15 +1249,15 @@ public class MTree implements Serializable {
    * <p>Iterate through MTree to fetch metadata info of all leaf nodes under 
the given seriesPath
    *
    * @param needLast if false, lastTimeStamp in timeseriesSchemaList will be 
null
-   * @param timeseriesSchemaList List<String[]> result: [name, alias, storage 
group, dataType,
+   * @param measurementNodeList List<String[]> result: [name, alias, storage 
group, dataType,
    *     encoding, compression, offset, lastTimeStamp]
    */
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity 
warning
-  private void findPath(
+  private void findTimeSeriesSchema(
       IMNode curNode,
       String[] nodes,
       int childIndex,
-      List<String[]> timeseriesSchemaList,
+      List<String[]> measurementNodeList,
       boolean hasLimit,
       boolean needLast,
       QueryContext queryContext,
@@ -1286,10 +1278,10 @@ public class MTree implements Serializable {
         IMeasurementSchema measurementSchema = measurementMNode.getSchema();
 
         if (measurementSchema instanceof MeasurementSchema) {
-          timeseriesSchemaList.add(getTimeseriesInfo(measurementMNode, 
needLast, queryContext));
+          measurementNodeList.add(getTimeseriesInfo(measurementMNode, 
needLast, queryContext));
         } else if (measurementSchema instanceof VectorMeasurementSchema) {
           String nextNode = MetaUtils.getNodeRegByIdx(childIndex, nodes);
-          timeseriesSchemaList.addAll(
+          measurementNodeList.addAll(
               getVectorTimeseriesInfo(measurementMNode, needLast, 
queryContext, nextNode));
         }
         if (hasLimit) {
@@ -1308,11 +1300,11 @@ public class MTree implements Serializable {
     if (!nodeReg.contains(PATH_WILDCARD)) {
       IMNode next = curNode.getChild(nodeReg);
       if (next != null) {
-        findPath(
+        findTimeSeriesSchema(
             next,
             nodes,
             childIndex + 1,
-            timeseriesSchemaList,
+            measurementNodeList,
             hasLimit,
             needLast,
             queryContext,
@@ -1323,11 +1315,11 @@ public class MTree implements Serializable {
         if (!Pattern.matches(nodeReg.replace("*", ".*"), child.getName())) {
           continue;
         }
-        findPath(
+        findTimeSeriesSchema(
             child,
             nodes,
             childIndex + 1,
-            timeseriesSchemaList,
+            measurementNodeList,
             hasLimit,
             needLast,
             queryContext,
@@ -1346,7 +1338,7 @@ public class MTree implements Serializable {
           if (set.add(schema)) {
             if (schema instanceof MeasurementSchema) {
               if (Pattern.matches(nodeReg.replace("*", ".*"), 
schema.getMeasurementId())) {
-                timeseriesSchemaList.add(
+                measurementNodeList.add(
                     getTimeseriesInfo(
                         new MeasurementMNode(curNode, 
schema.getMeasurementId(), schema, null),
                         needLast,
@@ -1357,7 +1349,7 @@ public class MTree implements Serializable {
               if (Pattern.matches(
                   nodeReg.replace("*", ".*"), 
vectorMeasurementSchema.getMeasurementId())) {
                 String firstNode = 
vectorMeasurementSchema.getSubMeasurementsList().get(0);
-                timeseriesSchemaList.addAll(
+                measurementNodeList.addAll(
                     getVectorTimeseriesInfoForTemplate(
                         new MeasurementMNode(curNode, firstNode, schema, null),
                         needLast,
@@ -1379,7 +1371,7 @@ public class MTree implements Serializable {
    * <p>Iterate through MTree to fetch metadata info of all leaf nodes under 
the given seriesPath
    */
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity 
warning
-  private void findPath(
+  private void findAllPaths(
       IMNode curNode,
       String[] nodes,
       int childIndex,
@@ -1412,14 +1404,14 @@ public class MTree implements Serializable {
     if (!nodeReg.contains(PATH_WILDCARD)) {
       IMNode next = curNode.getChild(nodeReg);
       if (next != null) {
-        findPath(next, nodes, childIndex + 1, pathList, upperTemplate);
+        findAllPaths(next, nodes, childIndex + 1, pathList, upperTemplate);
       }
     } else {
       for (IMNode child : curNode.getChildren().values()) {
         if (!Pattern.matches(nodeReg.replace("*", ".*"), child.getName())) {
           continue;
         }
-        findPath(child, nodes, childIndex + 1, pathList, upperTemplate);
+        findAllPaths(child, nodes, childIndex + 1, pathList, upperTemplate);
       }
     }
 
@@ -1536,7 +1528,7 @@ public class MTree implements Serializable {
       if (!Pattern.matches(nextNode.replace("*", ".*"), subMeasurement)) {
         continue;
       }
-      paths.add(new PartialPath(node.getPartialPath().getFullPath(), 
subMeasurement));
+      paths.add(new VectorPartialPath(node.getPartialPath().getFullPath(), 
subMeasurement));
     }
     return paths;
   }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/VectorPartialPath.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/VectorPartialPath.java
index a16caf4..538857a 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/VectorPartialPath.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/VectorPartialPath.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.db.metadata;
 
 import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 
@@ -39,6 +40,11 @@ public class VectorPartialPath extends PartialPath {
     this.subSensorsPathList = subSensorsPathList;
   }
 
+  public VectorPartialPath(String path, String subSensor) throws 
IllegalPathException {
+    super(path);
+    this.subSensorsPathList = Collections.singletonList(new PartialPath(path, 
subSensor));
+  }
+
   public List<PartialPath> getSubSensorsPathList() {
     return subSensorsPathList;
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java
index 9a778a1..7a98ca4 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java
@@ -83,6 +83,14 @@ public abstract class MNode implements IMNode {
     return new PartialPath(detachedPath.toArray(new String[0]));
   }
 
+  public PartialPath getPartialPathWithAlias() {
+    PartialPath result = getPartialPath();
+    if (this instanceof MeasurementMNode) {
+      result.setMeasurementAlias(((MeasurementMNode) this).getAlias());
+    }
+    return result;
+  }
+
   /** get full path */
   @Override
   public String getFullPath() {
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java 
b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index e7cb235..c3fb2fd 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -722,7 +722,7 @@ public class PlanExecutor implements IPlanExecutor {
   }
 
   protected List<PartialPath> getPathsName(PartialPath path) throws 
MetadataException {
-    return IoTDB.metaManager.getAllTimeseriesPath(path);
+    return IoTDB.metaManager.getAllTimeseriesPaths(path);
   }
 
   protected List<PartialPath> getNodesList(PartialPath schemaPattern, int 
level)
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 d3dff46..b53d191 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
@@ -25,6 +25,7 @@ import 
org.apache.iotdb.db.exception.query.LogicalOptimizeException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.index.common.IndexType;
 import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.db.metadata.VectorPartialPath;
 import org.apache.iotdb.db.qp.constant.SQLConstant;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
@@ -260,14 +261,14 @@ public class QueryOperator extends Operator {
           }
 
           if (actualPaths.isEmpty()) {
-            String nonExistMeasurement = 
getMeasurementName(fullPath.getMeasurement(), aggregation);
+            String nonExistMeasurement = getMeasurementName(fullPath, 
aggregation);
             if (measurementSetOfGivenSuffix.add(nonExistMeasurement)) {
               measurementInfoMap.putIfAbsent(
                   nonExistMeasurement, new 
MeasurementInfo(MeasurementType.NonExist));
             }
           } else {
             for (PartialPath path : actualPaths) {
-              String measurementName = 
getMeasurementName(path.getMeasurement(), aggregation);
+              String measurementName = getMeasurementName(path, aggregation);
               TSDataType measurementDataType = 
IoTDB.metaManager.getSeriesType(path);
               TSDataType columnDataType = getAggregationType(aggregation);
               columnDataType = columnDataType == null ? measurementDataType : 
columnDataType;
@@ -372,7 +373,13 @@ public class QueryOperator extends Operator {
         : (((FunctionExpression) expression).getPaths().get(0));
   }
 
-  private String getMeasurementName(String initialMeasurement, String 
aggregation) {
+  private String getMeasurementName(PartialPath path, String aggregation) {
+    String initialMeasurement = path.getMeasurement();
+    if (path instanceof VectorPartialPath) {
+      String subMeasurement =
+          ((VectorPartialPath) 
path).getSubSensorsPathList().get(0).getMeasurement();
+      initialMeasurement += "." + subMeasurement;
+    }
     if (aggregation != null) {
       initialMeasurement = aggregation + "(" + initialMeasurement + ")";
     }
@@ -473,6 +480,6 @@ public class QueryOperator extends Operator {
   }
 
   protected List<PartialPath> getMatchedTimeseries(PartialPath path) throws 
MetadataException {
-    return IoTDB.metaManager.getAllTimeseriesPath(path);
+    return IoTDB.metaManager.getAllTimeseriesPaths(path);
   }
 }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/LastQueryPlan.java 
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/LastQueryPlan.java
index 4064364..21c3424 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/LastQueryPlan.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/LastQueryPlan.java
@@ -24,7 +24,6 @@ import 
org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
 import org.apache.iotdb.db.query.expression.ResultColumn;
-import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.tsfile.read.expression.IExpression;
 import org.apache.iotdb.tsfile.read.expression.impl.GlobalTimeExpression;
 import org.apache.iotdb.tsfile.read.filter.TimeFilter.TimeGt;
@@ -56,7 +55,6 @@ public class LastQueryPlan extends RawDataQueryPlan {
         columnForReaderSet.add(column);
       }
     }
-    transformPaths(IoTDB.metaManager);
     setResultColumns(deduplicatedResultColumns);
   }
 
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 796acc3..6abd297 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
@@ -20,12 +20,10 @@ package org.apache.iotdb.db.qp.physical.crud;
 
 import org.apache.iotdb.db.exception.metadata.MetadataException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.metadata.MManager;
 import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.metadata.VectorPartialPath;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
-import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.common.Path;
 import org.apache.iotdb.tsfile.read.expression.IExpression;
@@ -95,17 +93,12 @@ public class RawDataQueryPlan extends QueryPlan {
       }
     }
 
-    // TODO Maybe we should get VectorPartialPath above from MTree
-    // Currently, the above processing will only produce PartialPath instead 
of VectorPartialPath
-    // even if the queried time series is vector
-    // So, we need to transform the PartialPath to VectorPartialPath if is is 
a vector.
-    if (!isRawQuery()) {
-      transformPaths(IoTDB.metaManager);
-    } else {
-      // if it is a RawQueryWithoutValueFilter, we also need to group all the 
subSensors of one
-      // vector into one VectorPartialPath
-      transformVectorPaths(physicalGenerator, columnForDisplaySet);
-    }
+    //    if (isRawQuery()) {
+    //      // if it is a RawQueryWithoutValueFilter, we also need to group 
all the subSensors of
+    // one
+    //      // vector into one VectorPartialPath
+    //      transformVectorPaths(physicalGenerator, columnForDisplaySet);
+    //    }
   }
 
   public IExpression getExpression() {
@@ -177,15 +170,6 @@ public class RawDataQueryPlan extends QueryPlan {
     return deviceToMeasurements;
   }
 
-  public void transformPaths(MManager mManager) throws MetadataException {
-    for (int i = 0; i < deduplicatedPaths.size(); i++) {
-      PartialPath path = mManager.transformPath(deduplicatedPaths.get(i));
-      if (path instanceof VectorPartialPath) {
-        deduplicatedPaths.set(i, path);
-      }
-    }
-  }
-
   /**
    * Group all the subSensors of one vector into one VectorPartialPath save 
the grouped
    * VectorPartialPath in deduplicatedVectorPaths and 
deduplicatedVectorDataTypes instead of putting
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java
 
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java
index 3025014..74ac8d3 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java
@@ -207,8 +207,7 @@ public class ConcatPathOptimizer implements 
ILogicalOptimizer {
     HashSet<PartialPath> actualPaths = new HashSet<>();
     try {
       for (PartialPath originalPath : originalPaths) {
-        List<PartialPath> all =
-            IoTDB.metaManager.getAllTimeseriesPathWithAlias(originalPath, 0, 
0).left;
+        List<PartialPath> all = 
IoTDB.metaManager.getAllTimeseriesPaths(originalPath);
         if (all.isEmpty()) {
           throw new LogicalOptimizeException(
               String.format("Unknown time series %s in `where clause`", 
originalPath));
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/utils/WildcardsRemover.java 
b/server/src/main/java/org/apache/iotdb/db/qp/utils/WildcardsRemover.java
index c89303c..bd3bfe9 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/utils/WildcardsRemover.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/utils/WildcardsRemover.java
@@ -60,7 +60,7 @@ public class WildcardsRemover {
   public List<PartialPath> removeWildcardFrom(PartialPath path) throws 
LogicalOptimizeException {
     try {
       Pair<List<PartialPath>, Integer> pair =
-          IoTDB.metaManager.getAllTimeseriesPathWithAlias(path, currentLimit, 
currentOffset);
+          IoTDB.metaManager.getAllTimeseriesPathsWithAlias(path, currentLimit, 
currentOffset);
 
       consumed += pair.right;
       if (currentOffset != 0) {
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 923f459..4d3cfd3 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
@@ -24,6 +24,7 @@ import 
org.apache.iotdb.db.exception.metadata.MetadataException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.metadata.mnode.IMNode;
+import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
 import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.db.qp.physical.crud.AggregationPlan;
 import org.apache.iotdb.db.qp.physical.crud.AlignByDevicePlan;
@@ -43,6 +44,8 @@ import org.apache.iotdb.tsfile.read.common.RowRecord;
 import org.apache.iotdb.tsfile.read.expression.IExpression;
 import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
 import org.apache.iotdb.tsfile.utils.Binary;
+import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
+import org.apache.iotdb.tsfile.write.schema.VectorMeasurementSchema;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -177,7 +180,6 @@ public class AlignByDeviceDataSet extends QueryDataSet {
             groupByTimePlan.setDeduplicatedDataTypes(tsDataTypes);
             groupByTimePlan.setDeduplicatedAggregations(executeAggregations);
             groupByTimePlan.setExpression(expression);
-            groupByTimePlan.transformPaths(IoTDB.metaManager);
             currentDataSet = queryRouter.groupBy(groupByTimePlan, context);
             break;
           case AGGREGATE:
@@ -185,20 +187,17 @@ public class AlignByDeviceDataSet extends QueryDataSet {
             aggregationPlan.setDeduplicatedAggregations(executeAggregations);
             aggregationPlan.setDeduplicatedDataTypes(tsDataTypes);
             aggregationPlan.setExpression(expression);
-            aggregationPlan.transformPaths(IoTDB.metaManager);
             currentDataSet = queryRouter.aggregate(aggregationPlan, context);
             break;
           case FILL:
             fillQueryPlan.setDeduplicatedDataTypes(tsDataTypes);
             fillQueryPlan.setDeduplicatedPathsAndUpdate(executePaths);
-            fillQueryPlan.transformPaths(IoTDB.metaManager);
             currentDataSet = queryRouter.fill(fillQueryPlan, context);
             break;
           case QUERY:
             rawDataQueryPlan.setDeduplicatedPathsAndUpdate(executePaths);
             rawDataQueryPlan.setDeduplicatedDataTypes(tsDataTypes);
             rawDataQueryPlan.setExpression(expression);
-            rawDataQueryPlan.transformPaths(IoTDB.metaManager);
             currentDataSet = queryRouter.rawDataQuery(rawDataQueryPlan, 
context);
             break;
           default:
@@ -206,8 +205,7 @@ public class AlignByDeviceDataSet extends QueryDataSet {
         }
       } catch (QueryProcessException
           | QueryFilterOptimizationException
-          | StorageEngineException
-          | MetadataException e) {
+          | StorageEngineException e) {
         throw new IOException(e);
       }
 
@@ -230,9 +228,16 @@ public class AlignByDeviceDataSet extends QueryDataSet {
   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(mnode.getName() + "." + subMeasurement);
+          }
+        } else {
+          res.add(mnode.getName());
+        }
       }
 
       Template template = deviceNode.getUpperTemplate();
diff --git 
a/server/src/main/java/org/apache/iotdb/db/query/executor/QueryRouter.java 
b/server/src/main/java/org/apache/iotdb/db/query/executor/QueryRouter.java
index 8d7c210..8ddcc0e 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/executor/QueryRouter.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/executor/QueryRouter.java
@@ -20,7 +20,6 @@
 package org.apache.iotdb.db.query.executor;
 
 import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.qp.physical.crud.AggregationPlan;
@@ -38,7 +37,6 @@ import 
org.apache.iotdb.db.query.dataset.groupby.GroupByTimeDataSet;
 import org.apache.iotdb.db.query.dataset.groupby.GroupByWithValueFilterDataSet;
 import 
org.apache.iotdb.db.query.dataset.groupby.GroupByWithoutValueFilterDataSet;
 import org.apache.iotdb.db.query.executor.fill.IFill;
-import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.db.utils.TimeValuePairUtils;
 import 
org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -95,11 +93,6 @@ public class QueryRouter implements IQueryRouter {
 
     if (optimizedExpression != null
         && optimizedExpression.getType() != ExpressionType.GLOBAL_TIME) {
-      try {
-        queryPlan.transformPaths(IoTDB.metaManager);
-      } catch (MetadataException e) {
-        throw new QueryProcessException(e);
-      }
       return rawDataQueryExecutor.executeWithValueFilter(context);
     } else if (optimizedExpression != null
         && optimizedExpression.getType() == ExpressionType.GLOBAL_TIME) {
diff --git 
a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java 
b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 6f6e25c..e86ba94 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -382,7 +382,7 @@ public class TSServiceImpl implements TSIService.Iface {
   }
 
   protected List<PartialPath> getPaths(PartialPath path) throws 
MetadataException {
-    return IoTDB.metaManager.getAllTimeseriesPath(path);
+    return IoTDB.metaManager.getAllTimeseriesPaths(path);
   }
 
   private boolean executeInsertRowsPlan(InsertRowsPlan insertRowsPlan, 
List<TSStatus> result) {
diff --git 
a/server/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java 
b/server/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java
index 21e3c01..dbe965d 100644
--- 
a/server/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java
+++ 
b/server/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java
@@ -150,17 +150,17 @@ public class MManagerAdvancedTest {
           new PartialPath("root.vehicle.d0"),
           mmanager.getStorageGroupPath(new PartialPath("root.vehicle.d0.s1")));
       List<PartialPath> pathList =
-          mmanager.getAllTimeseriesPath(new PartialPath("root.vehicle.d1.*"));
+          mmanager.getAllTimeseriesPaths(new PartialPath("root.vehicle.d1.*"));
       assertEquals(6, pathList.size());
-      pathList = mmanager.getAllTimeseriesPath(new 
PartialPath("root.vehicle.d0"));
+      pathList = mmanager.getAllTimeseriesPaths(new 
PartialPath("root.vehicle.d0"));
       assertEquals(6, pathList.size());
-      pathList = mmanager.getAllTimeseriesPath(new 
PartialPath("root.vehicle.d*"));
+      pathList = mmanager.getAllTimeseriesPaths(new 
PartialPath("root.vehicle.d*"));
       assertEquals(12, pathList.size());
-      pathList = mmanager.getAllTimeseriesPath(new PartialPath("root.ve*.*"));
+      pathList = mmanager.getAllTimeseriesPaths(new PartialPath("root.ve*.*"));
       assertEquals(12, pathList.size());
-      pathList = mmanager.getAllTimeseriesPath(new 
PartialPath("root.vehicle*.d*.s1"));
+      pathList = mmanager.getAllTimeseriesPaths(new 
PartialPath("root.vehicle*.d*.s1"));
       assertEquals(2, pathList.size());
-      pathList = mmanager.getAllTimeseriesPath(new 
PartialPath("root.vehicle.d2"));
+      pathList = mmanager.getAllTimeseriesPaths(new 
PartialPath("root.vehicle.d2"));
       assertEquals(0, pathList.size());
     } catch (MetadataException e) {
       e.printStackTrace();
diff --git 
a/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java 
b/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
index a121683..70afdda 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
@@ -545,7 +545,7 @@ public class MManagerBasicTest {
     MManager manager = IoTDB.metaManager;
 
     try {
-      assertTrue(manager.getAllTimeseriesPath(new 
PartialPath("root")).isEmpty());
+      assertTrue(manager.getAllTimeseriesPaths(new 
PartialPath("root")).isEmpty());
       assertTrue(manager.getStorageGroupByPath(new 
PartialPath("root.vehicle")).isEmpty());
       assertTrue(manager.getStorageGroupByPath(new 
PartialPath("root.vehicle.device")).isEmpty());
       assertTrue(
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/MTreeTest.java 
b/server/src/test/java/org/apache/iotdb/db/metadata/MTreeTest.java
index 2070c69..15fff9d 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/MTreeTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/MTreeTest.java
@@ -203,12 +203,12 @@ public class MTreeTest {
     }
 
     try {
-      List<PartialPath> result = root.getAllTimeseriesPath(new 
PartialPath("root.a.*.s0"));
+      List<PartialPath> result = root.getAllTimeseriesPaths(new 
PartialPath("root.a.*.s0"));
       assertEquals(2, result.size());
       assertEquals("root.a.d0.s0", result.get(0).getFullPath());
       assertEquals("root.a.d1.s0", result.get(1).getFullPath());
 
-      result = root.getAllTimeseriesPath(new PartialPath("root.a.*.*.s0"));
+      result = root.getAllTimeseriesPaths(new PartialPath("root.a.*.*.s0"));
       assertEquals("root.a.b.d0.s0", result.get(0).getFullPath());
     } catch (MetadataException e) {
       e.printStackTrace();
@@ -270,26 +270,25 @@ public class MTreeTest {
     }
 
     try {
-      List<PartialPath> result = root.getAllTimeseriesPath(new 
PartialPath("root.a.*.s0"));
+      List<PartialPath> result = root.getAllTimeseriesPaths(new 
PartialPath("root.a.*.s0"));
       assertEquals(2, result.size());
       assertEquals("root.a.d0.s0", result.get(0).getFullPath());
       assertEquals("root.a.d1.s0", result.get(1).getFullPath());
 
-      result = root.getAllTimeseriesPath(new 
PartialPath("root.a.*.temperature"));
+      result = root.getAllTimeseriesPaths(new 
PartialPath("root.a.*.temperature"));
       assertEquals(2, result.size());
       assertEquals("root.a.d0.s0", result.get(0).getFullPath());
       assertEquals("root.a.d1.s0", result.get(1).getFullPath());
 
       List<PartialPath> result2 =
-          root.getAllTimeseriesPathWithAlias(new PartialPath("root.a.*.s0"), 
0, 0).left;
+          root.getAllTimeseriesPaths(new PartialPath("root.a.*.s0"), 0, 
0).left;
       assertEquals(2, result2.size());
       assertEquals("root.a.d0.s0", result2.get(0).getFullPath());
-      assertFalse(result2.get(0).isMeasurementAliasExists());
+      assertTrue(result2.get(0).isMeasurementAliasExists());
       assertEquals("root.a.d1.s0", result2.get(1).getFullPath());
-      assertFalse(result2.get(1).isMeasurementAliasExists());
+      assertTrue(result2.get(1).isMeasurementAliasExists());
 
-      result2 =
-          root.getAllTimeseriesPathWithAlias(new 
PartialPath("root.a.*.temperature"), 0, 0).left;
+      result2 = root.getAllTimeseriesPaths(new 
PartialPath("root.a.*.temperature"), 0, 0).left;
       assertEquals(2, result2.size());
       assertEquals("root.a.d0.temperature", 
result2.get(0).getFullPathWithAlias());
       assertEquals("root.a.d1.temperature", 
result2.get(1).getFullPathWithAlias());
@@ -720,8 +719,8 @@ public class MTreeTest {
 
     assertEquals(2, root.getDevices(new PartialPath("root")).size());
     assertEquals(2, root.getAllTimeseriesCount(new PartialPath("root")));
-    assertEquals(2, root.getAllTimeseriesPath(new PartialPath("root")).size());
-    assertEquals(2, root.getAllTimeseriesPathWithAlias(new 
PartialPath("root"), 0, 0).left.size());
+    assertEquals(2, root.getAllTimeseriesPaths(new 
PartialPath("root")).size());
+    assertEquals(2, root.getAllTimeseriesPaths(new PartialPath("root"), 0, 
0).left.size());
   }
 
   @Test

Reply via email to