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/11/27 10:36:06 UTC

[iotdb] branch master updated: Fix slot query bug; add optimization for getSchemaPartition (#8200)

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 e5b4dfe033 Fix slot query bug; add optimization for getSchemaPartition (#8200)
e5b4dfe033 is described below

commit e5b4dfe033b3c6426bfc3df5a066f34d454a8774
Author: Beyyes <cg...@foxmail.com>
AuthorDate: Sun Nov 27 18:36:00 2022 +0800

    Fix slot query bug; add optimization for getSchemaPartition (#8200)
---
 .../iotdb/confignode/manager/ConfigManager.java    | 38 ++++++++++++----------
 .../iotdb/db/mpp/plan/parser/ASTVisitor.java       |  2 +-
 2 files changed, 22 insertions(+), 18 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 dde5cf66ba..4cc6bcf9f4 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
@@ -485,26 +485,30 @@ public class ConfigManager implements IManager {
     Map<String, Set<TSeriesPartitionSlot>> partitionSlotsMap = new HashMap<>();
     List<PartialPath> relatedPaths = patternTree.getAllPathPatterns();
     List<String> allStorageGroups = getClusterSchemaManager().getStorageGroupNames();
+    List<PartialPath> allStorageGroupPaths = new ArrayList<>();
+    for (String storageGroup : allStorageGroups) {
+      try {
+        allStorageGroupPaths.add(new PartialPath(storageGroup));
+      } catch (IllegalPathException e) {
+        throw new RuntimeException(e);
+      }
+    }
     Map<String, Boolean> scanAllRegions = new HashMap<>();
     for (PartialPath path : relatedPaths) {
-      for (String storageGroup : allStorageGroups) {
-        try {
-          PartialPath storageGroupPath = new PartialPath(storageGroup);
-          if (path.overlapWith(storageGroupPath.concatNode(MULTI_LEVEL_PATH_WILDCARD))
-              && !scanAllRegions.containsKey(storageGroup)) {
-            List<TSeriesPartitionSlot> relatedSlot = calculateRelatedSlot(path, storageGroupPath);
-            if (relatedSlot.isEmpty()) {
-              scanAllRegions.put(storageGroup, true);
-              partitionSlotsMap.put(storageGroup, new HashSet<>());
-            } else {
-              partitionSlotsMap
-                  .computeIfAbsent(storageGroup, k -> new HashSet<>())
-                  .addAll(relatedSlot);
-            }
+      for (int i = 0; i < allStorageGroups.size(); i++) {
+        String storageGroup = allStorageGroups.get(i);
+        PartialPath storageGroupPath = allStorageGroupPaths.get(i);
+        if (path.overlapWith(storageGroupPath.concatNode(MULTI_LEVEL_PATH_WILDCARD))
+            && !scanAllRegions.containsKey(storageGroup)) {
+          List<TSeriesPartitionSlot> relatedSlot = calculateRelatedSlot(path, storageGroupPath);
+          if (relatedSlot.isEmpty()) {
+            scanAllRegions.put(storageGroup, true);
+            partitionSlotsMap.put(storageGroup, new HashSet<>());
+          } else {
+            partitionSlotsMap
+                .computeIfAbsent(storageGroup, k -> new HashSet<>())
+                .addAll(relatedSlot);
           }
-        } catch (IllegalPathException e) {
-          // this line won't be reached in general
-          throw new RuntimeException(e);
         }
       }
     }
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index cc453de4dd..f1f0b0e236 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -3029,7 +3029,7 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
             new TSeriesPartitionSlot(Integer.parseInt(ctx.seriesSlot.getText())));
     if (ctx.timeSlot != null) {
       getRegionIdStatement.setTimeSlotId(
-          new TTimePartitionSlot(Integer.parseInt(ctx.timeSlot.getText())));
+          new TTimePartitionSlot(Long.parseLong(ctx.timeSlot.getText())));
     }
     return getRegionIdStatement;
   }