You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/04/22 02:23:11 UTC

[iotdb] branch master updated: fix the bug when matching multi-wildcard in pattern tree (#5631)

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

xingtanzjr 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 650a7a8e94 fix the bug when matching multi-wildcard in pattern tree (#5631)
650a7a8e94 is described below

commit 650a7a8e943bd7ded54c639975d1eded66ea52c3
Author: Zhang.Jinrui <xi...@gmail.com>
AuthorDate: Fri Apr 22 10:23:05 2022 +0800

    fix the bug when matching multi-wildcard in pattern tree (#5631)
---
 .../iotdb/db/mpp/common/schematree/SchemaTreeVisitor.java  |  6 ++++--
 .../iotdb/db/mpp/common/schematree/SchemaTreeTest.java     | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeVisitor.java
index c19d854bde..b186881064 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeVisitor.java
@@ -199,9 +199,11 @@ public class SchemaTreeVisitor implements Iterator<MeasurementPath> {
     SchemaNode child = node.getChild(childName);
     if (child != null) {
       stack.push(Collections.singletonList(child).iterator());
-      context.push(node);
-      indexStack.push(patternIndex);
+    } else {
+      stack.push(Collections.emptyIterator());
     }
+    context.push(node);
+    indexStack.push(patternIndex);
   }
 
   private boolean checkOneLevelWildcardMatch(String regex, SchemaNode node) {
diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeTest.java
index 3e7f9cdd92..adbd42431e 100644
--- a/server/src/test/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTreeTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iotdb.db.mpp.common.schematree;
 
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.metadata.path.MeasurementPath;
 import org.apache.iotdb.db.metadata.path.PartialPath;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -42,6 +43,19 @@ public class SchemaTreeTest {
     testSchemaTree(root);
   }
 
+  @Test
+  public void testMultiWildcard() throws IllegalPathException {
+    SchemaNode root = generateSchemaTree();
+    SchemaTreeVisitor visitor =
+        new SchemaTreeVisitor(root, new PartialPath("root.**.s1"), 0, 0, false);
+    checkVisitorResult(
+        visitor,
+        3,
+        new String[] {"root.sg.d1.s1", "root.sg.d2.s1", "root.sg.d2.a.s1"},
+        null,
+        new boolean[] {false, false, true});
+  }
+
   private void testSchemaTree(SchemaNode root) throws Exception {
 
     SchemaTreeVisitor visitor =