Skip to content

Commit fbd7963

Browse files
authored
[To rel/0.13][IOTDB-2749]Fix isPathExist check on MTree (#5259)
1 parent a90f490 commit fbd7963

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,9 @@ public boolean isPathExist(PartialPath path) {
738738
return false;
739739
}
740740
cur = upperTemplate.getDirectNode(nodeNames[i]);
741+
} else {
742+
cur = cur.getChild(nodeNames[i]);
741743
}
742-
cur = cur.getChild(nodeNames[i]);
743744
if (cur.isMeasurement()) {
744745
return i == nodeNames.length - 1;
745746
}

server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,36 @@ public void testAddPathAndExist() throws IllegalPathException {
254254
fail(e.getMessage());
255255
}
256256
assertFalse(manager.isPathExist(new PartialPath("root.1")));
257+
258+
assertFalse(manager.isPathExist(new PartialPath("root.template")));
259+
assertFalse(manager.isPathExist(new PartialPath("root.template.d1")));
260+
261+
try {
262+
manager.createTimeseries(
263+
new PartialPath("root.template.d2"),
264+
TSDataType.INT32,
265+
TSEncoding.RLE,
266+
TSFileDescriptor.getInstance().getConfig().getCompressor(),
267+
Collections.emptyMap());
268+
} catch (MetadataException e) {
269+
e.printStackTrace();
270+
fail(e.getMessage());
271+
}
272+
273+
try {
274+
manager.createSchemaTemplate(getCreateTemplatePlan());
275+
manager.setSchemaTemplate(new SetTemplatePlan("template1", "root.template"));
276+
manager.setUsingSchemaTemplate(new ActivateTemplatePlan(new PartialPath("root.template.d1")));
277+
} catch (MetadataException e) {
278+
e.printStackTrace();
279+
fail(e.getMessage());
280+
}
281+
282+
assertTrue(manager.isPathExist(new PartialPath("root.template.d1")));
283+
assertTrue(manager.isPathExist(new PartialPath("root.template.d1.s11")));
284+
assertFalse(manager.isPathExist(new PartialPath("root.template.d2.s11")));
285+
assertTrue(manager.isPathExist(new PartialPath("root.template.d1.vector")));
286+
assertTrue(manager.isPathExist(new PartialPath("root.template.d1.vector.s0")));
257287
}
258288

259289
/**

0 commit comments

Comments
 (0)