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 08:03:59 UTC

[iotdb] branch aggregationVector updated: split transform vector method

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


The following commit(s) were added to refs/heads/aggregationVector by this push:
     new b3b5c36  split transform vector method
b3b5c36 is described below

commit b3b5c364814cae35536d2068994d2f0758013dcd
Author: Alima777 <wx...@gmail.com>
AuthorDate: Tue Sep 14 16:03:28 2021 +0800

    split transform vector method
---
 .../cluster/query/ClusterPhysicalGenerator.java    |  7 ++--
 .../iotdb/AlignedTimeseriesSessionExample.java     | 14 ++++----
 .../org/apache/iotdb/db/metadata/MManager.java     | 17 +++-------
 .../iotdb/db/qp/physical/crud/QueryPlan.java       |  2 +-
 .../db/qp/physical/crud/RawDataQueryPlan.java      | 38 +++++++++++++---------
 .../iotdb/db/qp/strategy/PhysicalGenerator.java    |  7 ++--
 6 files changed, 38 insertions(+), 47 deletions(-)

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 0dcda7e..80a6a94 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
@@ -34,7 +34,6 @@ import org.apache.iotdb.db.qp.physical.sys.LoadConfigurationPlan.LoadConfigurati
 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.utils.Pair;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,7 +45,6 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
 public class ClusterPhysicalGenerator extends PhysicalGenerator {
@@ -67,9 +65,8 @@ public class ClusterPhysicalGenerator extends PhysicalGenerator {
   }
 
   @Override
-  public Pair<List<PartialPath>, Map<String, Integer>> getSeriesSchema(List<PartialPath> paths)
-      throws MetadataException {
-    return getCMManager().getSeriesSchemas(paths);
+  public List<PartialPath> groupVectorPaths(List<PartialPath> paths) throws MetadataException {
+    return getCMManager().groupVectorPaths(paths);
   }
 
   @Override
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 11520f6..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();
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 e2205ce..49fd942 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
@@ -1083,20 +1083,11 @@ public class MManager {
    * @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
-   *     VectorMeasurementSchema (s1,s2) would be returned once; Size of integer list must equal to
-   *     the input list size. It indicates the index of elements of original list in the result list
+   *     VectorMeasurementSchema (s1,s2) would be returned once.
    */
-  public Pair<List<PartialPath>, Map<String, Integer>> getSeriesSchemas(List<PartialPath> fullPaths)
-      throws MetadataException {
+  public List<PartialPath> groupVectorPaths(List<PartialPath> fullPaths) throws MetadataException {
     Map<IMNode, PartialPath> nodeToPartialPath = new LinkedHashMap<>();
-    Map<String, Integer> pathIndex = new LinkedHashMap<>();
-    for (int i = 0; i < fullPaths.size(); i++) {
-      PartialPath path = fullPaths.get(i);
-      pathIndex.put(path.getExactFullPath(), i);
-      if (path.isMeasurementAliasExists()) {
-        pathIndex.put(path.getFullPathWithAlias(), i);
-      }
-
+    for (PartialPath path : fullPaths) {
       IMeasurementMNode node = getMeasurementMNode(path);
       if (!nodeToPartialPath.containsKey(node)) {
         nodeToPartialPath.put(node, path.copy());
@@ -1110,7 +1101,7 @@ public class MManager {
         }
       }
     }
-    return new Pair<>(new ArrayList<>(nodeToPartialPath.values()), pathIndex);
+    return new ArrayList<>(nodeToPartialPath.values());
   }
 
   /**
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 aff2b51..aa63414 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
@@ -45,7 +45,7 @@ public abstract class QueryPlan extends PhysicalPlan {
 
   private Map<String, Integer> pathToIndex = new HashMap<>();
 
-  private Map<String, Integer> vectorPathToIndex = new HashMap<>();
+  private Map<String, Integer> vectorPathToIndex;
 
   private boolean enableRedirect = false;
 
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 b81ddec..12d975a 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
@@ -97,7 +97,8 @@ public class RawDataQueryPlan extends QueryPlan {
     if (isRawQuery()) {
       // if it is a RawQueryWithoutValueFilter, we also need to group all the subSensors of one
       // vector into one VectorPartialPath
-      transformVectorPaths(physicalGenerator, columnForDisplaySet);
+      fillVectorPathToIndex(columnForDisplaySet);
+      groupVectorPaths(physicalGenerator);
     }
   }
 
@@ -168,31 +169,36 @@ public class RawDataQueryPlan extends QueryPlan {
     return deviceToMeasurements;
   }
 
+  public void fillVectorPathToIndex(Set<String> columnForDisplaySet) {
+    Map<String, Integer> columnForDisplayToQueryDataSetIndex = new HashMap<>();
+    for (int i = 0; i < deduplicatedPaths.size(); i++) {
+      PartialPath path = deduplicatedPaths.get(i);
+      columnForDisplayToQueryDataSetIndex.put(path.getExactFullPath(), i);
+      if (path.isMeasurementAliasExists()) {
+        columnForDisplayToQueryDataSetIndex.put(path.getFullPathWithAlias(), i);
+      }
+    }
+    Map<String, Integer> vectorPathToIndex = new HashMap<>();
+    for (String columnForDisplay : columnForDisplaySet) {
+      vectorPathToIndex.put(
+          columnForDisplay, columnForDisplayToQueryDataSetIndex.get(columnForDisplay));
+    }
+    this.setVectorPathToIndex(vectorPathToIndex);
+  }
+
   /**
    * Group all the subSensors of one vector into one VectorPartialPath save the grouped
    * VectorPartialPath in deduplicatedVectorPaths and deduplicatedVectorDataTypes instead of putting
    * them directly into deduplicatedPaths and deduplicatedDataTypes, because we don't know whether
    * the raw query has value filter here.
    */
-  public void transformVectorPaths(
-      PhysicalGenerator physicalGenerator, Set<String> columnForDisplaySet)
-      throws MetadataException {
-    Pair<List<PartialPath>, Map<String, Integer>> pair =
-        physicalGenerator.getSeriesSchema(getDeduplicatedPaths());
-
-    List<PartialPath> vectorizedDeduplicatedPaths = pair.left;
+  public void groupVectorPaths(PhysicalGenerator physicalGenerator) throws MetadataException {
+    List<PartialPath> vectorizedDeduplicatedPaths =
+        physicalGenerator.groupVectorPaths(getDeduplicatedPaths());
     List<TSDataType> vectorizedDeduplicatedDataTypes =
         new ArrayList<>(physicalGenerator.getSeriesTypes(vectorizedDeduplicatedPaths));
     setDeduplicatedVectorPaths(vectorizedDeduplicatedPaths);
     setDeduplicatedVectorDataTypes(vectorizedDeduplicatedDataTypes);
-
-    Map<String, Integer> columnForDisplayToQueryDataSetIndex = pair.right;
-    Map<String, Integer> vectorPathToIndex = new HashMap<>();
-    for (String columnForDisplay : columnForDisplaySet) {
-      vectorPathToIndex.put(
-          columnForDisplay, columnForDisplayToQueryDataSetIndex.get(columnForDisplay));
-    }
-    setVectorPathToIndex(vectorPathToIndex);
   }
 
   public List<PartialPath> getDeduplicatedVectorPaths() {
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 abbb074..335de0f 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
@@ -29,10 +29,8 @@ import org.apache.iotdb.db.qp.physical.sys.LoadConfigurationPlan.LoadConfigurati
 import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.db.utils.SchemaUtils;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.utils.Pair;
 
 import java.util.List;
-import java.util.Map;
 
 /** Used to convert logical operator to physical plan */
 public class PhysicalGenerator {
@@ -60,8 +58,7 @@ public class PhysicalGenerator {
     return SchemaUtils.getSeriesTypesByPaths(paths);
   }
 
-  public Pair<List<PartialPath>, Map<String, Integer>> getSeriesSchema(List<PartialPath> paths)
-      throws MetadataException {
-    return IoTDB.metaManager.getSeriesSchemas(paths);
+  public List<PartialPath> groupVectorPaths(List<PartialPath> paths) throws MetadataException {
+    return IoTDB.metaManager.groupVectorPaths(paths);
   }
 }