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

zyk pushed a commit to branch rel/1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/1.1 by this push:
     new 0a9bbdf91aa [To rel/1.1] Avoid useless query in SchemaRegion when 
executing show child nodes (#10144)
0a9bbdf91aa is described below

commit 0a9bbdf91aa73d17d765938c1b916b515117829a
Author: Marcos_Zyk <[email protected]>
AuthorDate: Wed Jun 14 12:35:32 2023 +0800

    [To rel/1.1] Avoid useless query in SchemaRegion when executing show child 
nodes (#10144)
    
    
    
    * fix IT
---
 .../persistence/executor/ConfigPlanExecutor.java          | 15 ++++++++++++++-
 .../confignode/it/partition/IoTDBPartitionGetterIT.java   |  2 +-
 .../java/org/apache/iotdb/commons/path/PartialPath.java   |  9 +++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
index a9975b6072b..a502efd6afd 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
@@ -122,6 +122,7 @@ import org.slf4j.LoggerFactory;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -493,7 +494,19 @@ public class ConfigPlanExecutor {
       Pair<Set<TSchemaNode>, Set<PartialPath>> matchedChildInNextLevel =
           clusterSchemaInfo.getChildNodePathInNextLevel(partialPath);
       alreadyMatchedNode = matchedChildInNextLevel.left;
-      needMatchedNode = matchedChildInNextLevel.right;
+      if (!partialPath.hasMultiLevelMatchWildcard()) {
+        needMatchedNode = new HashSet<>();
+        for (PartialPath databasePath : matchedChildInNextLevel.right) {
+          if (databasePath.getNodeLength() == partialPath.getNodeLength() + 1) 
{
+            // this database node is already the target child node, no need to 
traverse its schema
+            // region
+            continue;
+          }
+          needMatchedNode.add(databasePath);
+        }
+      } else {
+        needMatchedNode = matchedChildInNextLevel.right;
+      }
     } else {
       // count nodes
       Pair<List<PartialPath>, Set<PartialPath>> matchedChildInNextLevel =
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java
index b8f662cb9c6..687f731095f 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java
@@ -503,7 +503,7 @@ public class IoTDBPartitionGetterIT {
           TSStatusCode.SUCCESS_STATUS.getStatusCode(), 
nodeManagementResp.getStatus().getCode());
       Assert.assertEquals(storageGroupNum, 
nodeManagementResp.getMatchedNodeSize());
       Assert.assertNotNull(nodeManagementResp.getSchemaRegionMap());
-      Assert.assertEquals(2, nodeManagementResp.getSchemaRegionMapSize());
+      Assert.assertEquals(0, nodeManagementResp.getSchemaRegionMapSize());
     }
   }
 }
diff --git 
a/node-commons/src/main/java/org/apache/iotdb/commons/path/PartialPath.java 
b/node-commons/src/main/java/org/apache/iotdb/commons/path/PartialPath.java
index cc81983f7ab..c33702e5be9 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/path/PartialPath.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/path/PartialPath.java
@@ -114,6 +114,15 @@ public class PartialPath extends Path implements 
Comparable<Path>, Cloneable {
     return false;
   }
 
+  public boolean hasMultiLevelMatchWildcard() {
+    for (String node : nodes) {
+      if (MULTI_LEVEL_PATH_WILDCARD.equals(node)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   /**
    * it will return a new partial path
    *

Reply via email to