Skip to content

Commit

Permalink
Merge pull request #887 from apache/jira_444
Browse files Browse the repository at this point in the history
[IOTDB-546] Fix show child paths statement doesn't show quotation marks
  • Loading branch information
Jialin Qiao committed Mar 6, 2020
2 parents f514abd + 40222c0 commit 13b2236
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
10 changes: 8 additions & 2 deletions server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ private void findChildNodePathInNextLevel(MNode node, String[] nodes, int idx, S
parent + node.getName() + PATH_SEPARATOR, res, length);
}
} else {
if (node instanceof InternalMNode) {
if (node instanceof InternalMNode && node.getChildren().size() > 0) {
for (MNode child : node.getChildren().values()) {
if (!Pattern.matches(nodeReg.replace("*", ".*"), child.getName())) {
continue;
Expand All @@ -575,7 +575,13 @@ private void findChildNodePathInNextLevel(MNode node, String[] nodes, int idx, S
}
}
} else if (idx == length) {
res.add(parent + node.getName());
String nodeName;
if (node.getName().contains(TsFileConstant.PATH_SEPARATOR)) {
nodeName = "\"" + node + "\"";
} else {
nodeName = node.getName();
}
res.add(parent + nodeName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void testAddPathAndExist() {

try {
manager.setStorageGroup("root.laptop.d1");
manager.setStorageGroup("root.1");
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
Expand All @@ -80,8 +81,7 @@ public void testAddPathAndExist() {

try {
manager.createTimeseries("root.laptop.d1.s0", TSDataType.valueOf("INT32"),
TSEncoding.valueOf("RLE"), compressionType, Collections
.emptyMap());
TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
Expand All @@ -93,20 +93,31 @@ public void testAddPathAndExist() {
try {
manager.createTimeseries("root.laptop.d1.s1", TSDataType.valueOf("INT32"),
TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
manager.createTimeseries("root.laptop.d1.1_2", TSDataType.INT32, TSEncoding.RLE,
TSFileDescriptor.getInstance().getConfig().getCompressor(), Collections.EMPTY_MAP);
manager.createTimeseries("root.laptop.d1.\"1.2.3\"", TSDataType.INT32, TSEncoding.RLE,
TSFileDescriptor.getInstance().getConfig().getCompressor(), Collections.EMPTY_MAP);
manager.createTimeseries("root.1.2.3", TSDataType.INT32, TSEncoding.RLE,
TSFileDescriptor.getInstance().getConfig().getCompressor(), Collections.EMPTY_MAP);
} catch (MetadataException e1) {
e1.printStackTrace();
fail(e1.getMessage());
}
assertTrue(manager.isPathExist("root.laptop.d1.s1"));
assertTrue(manager.isPathExist("root.laptop.d1.1_2"));
assertTrue(manager.isPathExist("root.laptop.d1.\"1.2.3\""));
assertTrue(manager.isPathExist("root.1.2.3"));
assertTrue(manager.isPathExist("root.1"));
assertTrue(manager.isPathExist("root.1.2"));

try {
manager.deleteTimeseries("root.laptop.d1.s1");
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
}
// just delete s0, and don't delete root.laptop.d1??
// delete storage group or not
assertFalse(manager.isPathExist("root.laptop.d1.s1"));

try {
manager.deleteTimeseries("root.laptop.d1.s0");
} catch (MetadataException e) {
Expand Down Expand Up @@ -158,6 +169,28 @@ public void testAddPathAndExist() {
"root.laptop.d2"),
e.getMessage());
}

try {
manager.deleteTimeseries("root.laptop.d1.1_2");
manager.deleteTimeseries("root.laptop.d1.\"1.2.3\"");
manager.deleteTimeseries("root.1.2.3");
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
}
assertFalse(manager.isPathExist("root.laptop.d1.1_2"));
assertFalse(manager.isPathExist("root.laptop.d1.\"1.2.3\""));
assertFalse(manager.isPathExist("root.1.2.3"));
assertFalse(manager.isPathExist("root.1.2"));
assertTrue(manager.isPathExist("root.1"));

try {
manager.deleteStorageGroups(Collections.singletonList("root.1"));
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
}
assertFalse(manager.isPathExist("root.1"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ public void testCheckStorageGroup() {
assertTrue(root.isStorageGroup("root.laptop.d1"));
assertTrue(root.isStorageGroup("root.laptop.d2"));
assertFalse(root.isStorageGroup("root.laptop.d3"));

root.setStorageGroup("root.1");
assertTrue(root.isStorageGroup("root.1"));
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
Expand Down

0 comments on commit 13b2236

Please sign in to comment.