This is an automated email from the ASF dual-hosted git repository.
zyk 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 47c30ee0cdc Avoid useless query in SchemaRegion when executing show
child nodes (#10140)
47c30ee0cdc is described below
commit 47c30ee0cdcd8e81579add73617f26ddac647c30
Author: Marcos_Zyk <[email protected]>
AuthorDate: Wed Jun 14 08:55:25 2023 +0800
Avoid useless query in SchemaRegion when executing show child nodes (#10140)
---
.../persistence/executor/ConfigPlanExecutor.java | 15 ++++++++++++++-
.../confignode/it/partition/IoTDBPartitionGetterIT.java | 2 +-
.../java/org/apache/iotdb/commons/path/PartialPath.java | 10 ++++++++++
.../org/apache/iotdb/commons/path/PathPatternUtil.java | 4 ++++
4 files changed, 29 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 2cd14b69fc8..e33c0ec0145 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
@@ -129,6 +129,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;
@@ -537,7 +538,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 65d1bb6295d..4df3da3ca80 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
@@ -487,7 +487,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 45868472a69..af0d037df33 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,16 @@ public class PartialPath extends Path implements
Comparable<Path>, Cloneable {
return false;
}
+ public boolean hasMultiLevelMatchWildcard() {
+ for (String node : nodes) {
+ // *, ** , d*, *d*
+ if (PathPatternUtil.hasMultiLevelMatchWildcard(node)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
// e.g. root.db.d.s, root.db.d.*, root.db.d.s*, not include patterns like
root.db.d.**
public boolean hasExplicitDevice() {
if (nodes[nodes.length - 1].equals(MULTI_LEVEL_PATH_WILDCARD)) {
diff --git
a/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
b/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
index 3c867a44aec..6d5b265a910 100644
---
a/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
+++
b/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
@@ -36,6 +36,10 @@ public class PathPatternUtil {
return node.startsWith(ONE_LEVEL_PATH_WILDCARD) ||
node.endsWith(ONE_LEVEL_PATH_WILDCARD);
}
+ public static boolean hasMultiLevelMatchWildcard(String node) {
+ return node.startsWith(ONE_LEVEL_PATH_WILDCARD);
+ }
+
/**
* Determine if a node pattern matches a node name.
*