You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/06/13 13:51:16 UTC

[iotdb] branch master updated: [IOTDB-3331] Fix create three level timeseries. (#6247)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2242a4033e [IOTDB-3331] Fix create three level timeseries. (#6247)
2242a4033e is described below

commit 2242a4033ee7d47256002f683fadb84495fee42f
Author: ZhangHongYin <46...@users.noreply.github.com>
AuthorDate: Mon Jun 13 21:51:11 2022 +0800

    [IOTDB-3331] Fix create three level timeseries. (#6247)
---
 .../main/java/org/apache/iotdb/confignode/manager/ConfigManager.java | 5 +++--
 .../main/java/org/apache/iotdb/commons/partition/DataPartition.java  | 3 ++-
 .../java/org/apache/iotdb/commons/partition/SchemaPartition.java     | 3 ++-
 .../src/main/java/org/apache/iotdb/commons/utils/PathUtils.java      | 4 ++++
 .../java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java   | 3 ++-
 .../apache/iotdb/db/mpp/plan/analyze/ClusterPartitionFetcher.java    | 5 +++--
 .../apache/iotdb/db/mpp/plan/analyze/StandalonePartitionFetcher.java | 3 ++-
 7 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
index fe30ba53e5..e81c72d76c 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
 import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.utils.AuthUtils;
+import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.confignode.conf.ConfigNodeConf;
 import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
 import org.apache.iotdb.confignode.consensus.request.auth.AuthorReq;
@@ -280,7 +281,7 @@ public class ConfigManager implements Manager {
       for (String devicePath : devicePaths) {
         boolean matchStorageGroup = false;
         for (String storageGroup : storageGroups) {
-          if (devicePath.startsWith(storageGroup + ".")) {
+          if (PathUtils.isStartWith(devicePath, storageGroup)) {
             matchStorageGroup = true;
             if (devicePath.contains("*")) {
               // Get all SchemaPartitions of this StorageGroup if the devicePath contains "*"
@@ -341,7 +342,7 @@ public class ConfigManager implements Manager {
         if (!devicePath.contains("*")) {
           // Only check devicePaths that without "*"
           for (String storageGroup : storageGroups) {
-            if (devicePath.startsWith(storageGroup + ".")) {
+            if (PathUtils.isStartWith(devicePath, storageGroup)) {
               partitionSlotsMap
                   .computeIfAbsent(storageGroup, key -> new ArrayList<>())
                   .add(getPartitionManager().getSeriesPartitionSlot(devicePath));
diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java b/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java
index e1004d7445..9523e22482 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.commons.partition;
 import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
 import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
 import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
+import org.apache.iotdb.commons.utils.PathUtils;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -114,7 +115,7 @@ public class DataPartition extends Partition {
 
   private String getStorageGroupByDevice(String deviceName) {
     for (String storageGroup : dataPartitionMap.keySet()) {
-      if (deviceName.startsWith(storageGroup + ".")) {
+      if (PathUtils.isStartWith(deviceName, storageGroup)) {
         return storageGroup;
       }
     }
diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaPartition.java b/node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaPartition.java
index 989586458f..f9ed307c69 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaPartition.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaPartition.java
@@ -20,6 +20,7 @@ package org.apache.iotdb.commons.partition;
 
 import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
 import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
+import org.apache.iotdb.commons.utils.PathUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -69,7 +70,7 @@ public class SchemaPartition extends Partition {
 
   private String getStorageGroupByDevice(String deviceName) {
     for (String storageGroup : schemaPartitionMap.keySet()) {
-      if (deviceName.startsWith(storageGroup + ".")) {
+      if (PathUtils.isStartWith(deviceName, storageGroup)) {
         return storageGroup;
       }
     }
diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java b/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java
index a886350498..474010392c 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java
@@ -126,6 +126,10 @@ public class PathUtils {
     }
   }
 
+  public static boolean isStartWith(String deviceName, String storageGroup) {
+    return deviceName.equals(storageGroup) || deviceName.startsWith(storageGroup + ".");
+  }
+
   private static boolean checkBackQuotes(String src) {
     int num = src.length() - src.replace("`", "").length();
     if (num % 2 == 1) {
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java b/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java
index 8c3e307b58..e30d650140 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java
@@ -20,6 +20,7 @@
 package org.apache.iotdb.db.mpp.common.schematree;
 
 import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.metadata.path.MeasurementPath;
@@ -267,7 +268,7 @@ public class SchemaTree {
    */
   public String getBelongedStorageGroup(String pathName) {
     for (String storageGroup : storageGroups) {
-      if (pathName.startsWith(storageGroup + ".")) {
+      if (PathUtils.isStartWith(pathName, storageGroup)) {
         return storageGroup;
       }
     }
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ClusterPartitionFetcher.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ClusterPartitionFetcher.java
index 1470daf66a..5da5985d80 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ClusterPartitionFetcher.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ClusterPartitionFetcher.java
@@ -30,6 +30,7 @@ import org.apache.iotdb.commons.partition.SchemaNodeManagementPartition;
 import org.apache.iotdb.commons.partition.SchemaPartition;
 import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor;
 import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionReq;
 import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionResp;
 import org.apache.iotdb.confignode.rpc.thrift.TSchemaNodeManagementReq;
@@ -460,7 +461,7 @@ public class ClusterPartitionFetcher implements IPartitionFetcher {
         for (String devicePath : devicePaths) {
           boolean hit = false;
           for (String storageGroup : storageGroupCache) {
-            if (devicePath.startsWith(storageGroup + ".")) {
+            if (PathUtils.isStartWith(devicePath, storageGroup)) {
               deviceToStorageGroupMap.put(devicePath, storageGroup);
               hit = true;
               break;
@@ -597,7 +598,7 @@ public class ClusterPartitionFetcher implements IPartitionFetcher {
         if (!device.contains("*")) {
           String storageGroup = null;
           for (String storageGroupName : storageGroupNames) {
-            if (device.startsWith(storageGroupName + ".")) {
+            if (PathUtils.isStartWith(device, storageGroup)) {
               storageGroup = storageGroupName;
               break;
             }
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/StandalonePartitionFetcher.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/StandalonePartitionFetcher.java
index 5f291684b1..d389e124f3 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/StandalonePartitionFetcher.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/StandalonePartitionFetcher.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.commons.partition.SchemaNodeManagementPartition;
 import org.apache.iotdb.commons.partition.SchemaPartition;
 import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor;
 import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.engine.StorageEngineV2;
@@ -169,7 +170,7 @@ public class StandalonePartitionFetcher implements IPartitionFetcher {
       List<PartialPath> allStorageGroups = localConfigNode.getAllStorageGroupPaths();
       for (String devicePath : devicePaths) {
         for (PartialPath storageGroup : allStorageGroups) {
-          if (devicePath.startsWith(storageGroup.getFullPath() + ".")) {
+          if (PathUtils.isStartWith(devicePath, storageGroup.getFullPath())) {
             deviceToStorageGroup.put(devicePath, storageGroup.getFullPath());
           }
         }