Skip to content

Commit

Permalink
fix the bug when matching multi-wildcard in pattern tree (#5631)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingtanzjr committed Apr 22, 2022
1 parent 9522cfb commit 650a7a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@ private void pushSingleChild(SchemaNode node, String childName, int patternIndex
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,6 +43,19 @@ public void testSchemaTreeVisitor() throws Exception {
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 =
Expand Down

0 comments on commit 650a7a8

Please sign in to comment.