This is an automated email from the ASF dual-hosted git repository.
ColinLeeo pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new 86a3f507494 Fixed the bug that nodes with non-trivial wildcards are
not correctly handled in mods setting (#12978) (#18666)
86a3f507494 is described below
commit 86a3f50749447f61976f41093fbe0f72ddbabf9e
Author: Caideyipi <[email protected]>
AuthorDate: Mon Sep 21 09:52:21 2026 +0800
Fixed the bug that nodes with non-trivial wildcards are not correctly
handled in mods setting (#12978) (#18666)
(cherry picked from commit 1ca1f9c0b9136e43b2c53e415df1a38fd9c1d154)
---
.../iotdb/db/metadata/path/PatternTreeMapTest.java | 6 +++++-
.../org/apache/iotdb/commons/path/PathPatternNode.java | 17 ++++++++++++++++-
.../org/apache/iotdb/commons/path/PathPatternUtil.java | 3 ++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/path/PatternTreeMapTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/path/PatternTreeMapTest.java
index a3450f72332..e9405f0374b 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/path/PatternTreeMapTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/path/PatternTreeMapTest.java
@@ -182,6 +182,9 @@ public class PatternTreeMapTest {
patternTreeMap.append(
new PartialPath("root.sg1.d1.*.d3.s4"),
new Deletion(new PartialPath("root.sg1.d1.*.d3.s4"), 3, 4, 6));
+ patternTreeMap.append(
+ new PartialPath("root.sg1.d1.t1.d*.s5"),
+ new Deletion(new PartialPath("root.sg1.d1.t1.d*.s5"), 4, 7, 10));
checkOverlappedByDevice(
patternTreeMap,
@@ -205,7 +208,8 @@ public class PatternTreeMapTest {
new Deletion(new PartialPath("root.**.s1"), 10, 100, 200),
new Deletion(new PartialPath("root.**"), 5, 10, 100),
new Deletion(new PartialPath("root.sg1.d1.*.d3.s5"), 2, 4, 6),
- new Deletion(new PartialPath("root.sg1.d1.*.d3.s4"), 3, 4, 6)));
+ new Deletion(new PartialPath("root.sg1.d1.*.d3.s4"), 3, 4, 6),
+ new Deletion(new PartialPath("root.sg1.d1.t1.d*.s5"), 4, 7, 10)));
}
private <T> void checkOverlapped(
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternNode.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternNode.java
index 89ae7444d19..3dd274b8c37 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternNode.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternNode.java
@@ -58,6 +58,10 @@ public class PathPatternNode<V, VSerializer extends
PathPatternNode.Serializer<V
private final VSerializer serializer;
+ // Children names with wildcard, for accelerating wildcard searching.
+ // Here we do not include "*" or "**" to ensure that the set is empty in
most cases.
+ private final Set<String> childrenNamesWithNonTrivialWildcard = new
HashSet<>();
+
public PathPatternNode(String name, VSerializer serializer) {
this.name = name;
this.children = new HashMap<>();
@@ -90,6 +94,10 @@ public class PathPatternNode<V, VSerializer extends
PathPatternNode.Serializer<V
if (children.containsKey(MULTI_LEVEL_PATH_WILDCARD)) {
res.add(children.get(MULTI_LEVEL_PATH_WILDCARD));
}
+ childrenNamesWithNonTrivialWildcard.stream()
+ .filter(path -> PathPatternUtil.isNodeMatch(path, nodeName))
+ .map(children::get)
+ .forEach(res::add);
return res;
}
@@ -98,7 +106,13 @@ public class PathPatternNode<V, VSerializer extends
PathPatternNode.Serializer<V
}
public void addChild(PathPatternNode<V, VSerializer> tmpNode) {
- children.put(tmpNode.getName(), tmpNode);
+ String nodeName = tmpNode.getName();
+ if (PathPatternUtil.hasWildcard(nodeName)
+ && !PathPatternUtil.isMultiLevelMatchWildcard(nodeName)
+ && !ONE_LEVEL_PATH_WILDCARD.equals(nodeName)) {
+ childrenNamesWithNonTrivialWildcard.add(nodeName);
+ }
+ children.put(nodeName, tmpNode);
}
public void deleteChild(PathPatternNode<V, VSerializer> tmpNode) {
@@ -265,6 +279,7 @@ public class PathPatternNode<V, VSerializer extends
PathPatternNode.Serializer<V
return SHALLOW_SIZE
+ RamUsageEstimator.sizeOf(name)
+ RamUsageEstimator.sizeOfHashSet(valueSet)
+ + RamUsageEstimator.sizeOfHashSet(childrenNamesWithNonTrivialWildcard)
+ RamUsageEstimator.sizeOfMapWithKnownShallowSize(
children,
RamUsageEstimator.SHALLOW_SIZE_OF_HASHMAP,
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
index a8ba920813b..6ee73645350 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternUtil.java
@@ -33,7 +33,8 @@ public class PathPatternUtil {
* patternNode that can match batch explicit node names. e.g. *, e.g. *, **,
d*, *d*.
*/
public static boolean hasWildcard(String node) {
- return node.startsWith(ONE_LEVEL_PATH_WILDCARD) ||
node.endsWith(ONE_LEVEL_PATH_WILDCARD);
+ return node != null
+ && (node.startsWith(ONE_LEVEL_PATH_WILDCARD) ||
node.endsWith(ONE_LEVEL_PATH_WILDCARD));
}
public static boolean isMultiLevelMatchWildcard(String node) {