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

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


The following commit(s) were added to refs/heads/auth by this push:
     new 54b925f4f57 Fix scope does not work when counting nodes  (#11069)
54b925f4f57 is described below

commit 54b925f4f57ce697718f1114ec4373a8cb0e96e5
Author: Chen YZ <[email protected]>
AuthorDate: Wed Sep 6 20:40:27 2023 +0800

    Fix scope does not work when counting nodes  (#11069)
---
 .../confignode/persistence/executor/ConfigPlanExecutor.java  |  3 ++-
 .../confignode/persistence/schema/ClusterSchemaInfo.java     |  4 ++--
 .../iotdb/confignode/persistence/schema/ConfigMTree.java     |  5 +++--
 .../iotdb/confignode/persistence/schema/ConfigMTreeTest.java | 11 ++++++-----
 .../plan/statement/metadata/CountNodesStatement.java         | 12 ------------
 5 files changed, 13 insertions(+), 22 deletions(-)

diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
index 81dc6364350..e9f830bbbb0 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
@@ -579,7 +579,8 @@ public class ConfigPlanExecutor {
     } else {
       // count nodes
       Pair<List<PartialPath>, Set<PartialPath>> matchedChildInNextLevel =
-          clusterSchemaInfo.getNodesListInGivenLevel(partialPath, level);
+          clusterSchemaInfo.getNodesListInGivenLevel(
+              partialPath, level, getNodePathsPartitionPlan.getScope());
       alreadyMatchedNode =
           matchedChildInNextLevel.left.stream()
               .map(path -> new TSchemaNode(path.getFullPath(), 
MNodeType.UNIMPLEMENT.getNodeType()))
diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
index 82a8ac616ab..caff28f250a 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
@@ -657,12 +657,12 @@ public class ClusterSchemaInfo implements 
SnapshotProcessor {
   }
 
   public Pair<List<PartialPath>, Set<PartialPath>> getNodesListInGivenLevel(
-      PartialPath partialPath, int level) {
+      PartialPath partialPath, int level, PathPatternTree scope) {
     Pair<List<PartialPath>, Set<PartialPath>> matchedPathsInNextLevel =
         new Pair(new HashSet<>(), new HashSet<>());
     databaseReadWriteLock.readLock().lock();
     try {
-      matchedPathsInNextLevel = mTree.getNodesListInGivenLevel(partialPath, 
level, true);
+      matchedPathsInNextLevel = mTree.getNodesListInGivenLevel(partialPath, 
level, true, scope);
     } catch (MetadataException e) {
       LOGGER.error("Error get matched paths in given level.", e);
     } finally {
diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
index fdd482106b2..72dae94e440 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
@@ -383,11 +383,12 @@ public class ConfigMTree {
    * path pattern is used to match prefix path.
    */
   public Pair<List<PartialPath>, Set<PartialPath>> getNodesListInGivenLevel(
-      PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch) throws 
MetadataException {
+      PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch, 
PathPatternTree scope)
+      throws MetadataException {
     List<PartialPath> result = new LinkedList<>();
     try (MNodeAboveDBCollector<Void, IConfigMNode> collector =
         new MNodeAboveDBCollector<Void, IConfigMNode>(
-            root, pathPattern, store, isPrefixMatch, ALL_MATCH_SCOPE) {
+            root, pathPattern, store, isPrefixMatch, scope) {
           @Override
           protected Void collectMNode(IConfigMNode node) {
             result.add(getPartialPathFromRootToNode(node));
diff --git 
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTreeTest.java
 
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTreeTest.java
index 77cb392708a..c88e52af34d 100644
--- 
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTreeTest.java
+++ 
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTreeTest.java
@@ -210,19 +210,19 @@ public class ConfigMTreeTest {
     root.setStorageGroup(new PartialPath("root.sg2"));
 
     Pair<List<PartialPath>, Set<PartialPath>> result =
-        root.getNodesListInGivenLevel(new PartialPath("root.**"), 3, false);
+        root.getNodesListInGivenLevel(new PartialPath("root.**"), 3, false, 
ALL_MATCH_SCOPE);
     Assert.assertEquals(0, result.left.size());
     Assert.assertEquals(2, result.right.size());
 
-    result = root.getNodesListInGivenLevel(new PartialPath("root.**"), 1, 
false);
+    result = root.getNodesListInGivenLevel(new PartialPath("root.**"), 1, 
false, ALL_MATCH_SCOPE);
     Assert.assertEquals(2, result.left.size());
     Assert.assertEquals(2, result.right.size());
 
-    result = root.getNodesListInGivenLevel(new PartialPath("root.*.*"), 2, 
false);
+    result = root.getNodesListInGivenLevel(new PartialPath("root.*.*"), 2, 
false, ALL_MATCH_SCOPE);
     Assert.assertEquals(0, result.left.size());
     Assert.assertEquals(2, result.right.size());
 
-    result = root.getNodesListInGivenLevel(new PartialPath("root.*.*"), 1, 
false);
+    result = root.getNodesListInGivenLevel(new PartialPath("root.*.*"), 1, 
false, ALL_MATCH_SCOPE);
     Assert.assertEquals(0, result.left.size());
     Assert.assertEquals(2, result.right.size());
 
@@ -231,7 +231,8 @@ public class ConfigMTreeTest {
     root.setStorageGroup(new PartialPath("root.sg"));
     root.setStorageGroup(new PartialPath("root.ln"));
 
-    result = root.getNodesListInGivenLevel(new PartialPath("root.*.*.s1"), 2, 
true);
+    result =
+        root.getNodesListInGivenLevel(new PartialPath("root.*.*.s1"), 2, true, 
ALL_MATCH_SCOPE);
     Assert.assertEquals(0, result.left.size());
     Assert.assertEquals(5, result.right.size());
     Assert.assertTrue(result.right.contains(new PartialPath("root.sg1")));
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/CountNodesStatement.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/CountNodesStatement.java
index 0ea68aae09d..06c9c7ef75d 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/CountNodesStatement.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/CountNodesStatement.java
@@ -20,28 +20,16 @@
 package org.apache.iotdb.db.queryengine.plan.statement.metadata;
 
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.path.PathPatternTree;
-import org.apache.iotdb.commons.schema.SchemaConstant;
 import org.apache.iotdb.db.queryengine.plan.statement.StatementVisitor;
 
 public class CountNodesStatement extends CountStatement {
   private final int level;
 
-  private PathPatternTree authorityScope = SchemaConstant.ALL_MATCH_SCOPE;
-
   public CountNodesStatement(PartialPath partialPath, int level) {
     super(partialPath);
     this.level = level;
   }
 
-  public PathPatternTree getAuthorityScope() {
-    return authorityScope;
-  }
-
-  public void setAuthorityScope(PathPatternTree authorityScope) {
-    this.authorityScope = authorityScope;
-  }
-
   public int getLevel() {
     return level;
   }

Reply via email to