You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/09/06 07:49:33 UTC

[GitHub] [incubator-iotdb] yhwang-hbl opened a new pull request #1694: [IOTDB-813] Show storage group under given path prefix

yhwang-hbl opened a new pull request #1694:
URL: https://github.com/apache/incubator-iotdb/pull/1694


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-iotdb] yhwang-hbl commented on a change in pull request #1694: [IOTDB-813] Show storage group under given path prefix

Posted by GitBox <gi...@apache.org>.
yhwang-hbl commented on a change in pull request #1694:
URL: https://github.com/apache/incubator-iotdb/pull/1694#discussion_r484144430



##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
##########
@@ -502,6 +502,54 @@ private void findStorageGroup(
     return res;
   }
 
+  /**
+   * Get all storage group under give path
+   *
+   * @return a list contains all storage group names under give path
+   */
+  List<PartialPath> getStorageGroupPaths(PartialPath prefixPath) throws MetadataException {
+    String[] nodes = prefixPath.getNodes();
+    if (nodes.length == 0 || !nodes[0].equals(root.getName())) {
+      throw new IllegalPathException(prefixPath.getFullPath());
+    }
+    List<PartialPath> storageGroupPaths = new ArrayList<>();
+    findStorageGroupPaths(root, nodes, 1, "", storageGroupPaths);
+    return storageGroupPaths;
+  }
+
+  /**
+   * Traverse the MTree to match all storage group with prefix path.
+   *
+   * @param node              the current traversing node
+   * @param nodes             split the prefix path with '.'
+   * @param idx               the current index of array nodes
+   * @param parent            current parent path
+   * @param storageGroupPaths store all matched storage group names
+   */
+  private void findStorageGroupPaths(MNode node, String[] nodes, int idx, String parent,
+      List<PartialPath> storageGroupPaths) {
+    if (node instanceof StorageGroupMNode) {
+      storageGroupPaths.add(node.getPartialPath());
+      return;
+    }
+    String nodeReg = MetaUtils.getNodeRegByIdx(idx, nodes);
+    if (!(PATH_WILDCARD).equals(nodeReg)) {
+      if (node.hasChild(nodeReg)) {
+        findStorageGroupPaths(
+            node.getChild(nodeReg),
+            nodes,
+            idx + 1,
+            parent + node.getName() + PATH_SEPARATOR,
+            storageGroupPaths);

Review comment:
       Copy that. I'll change it




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-iotdb] qiaojialin merged pull request #1694: [IOTDB-813] Show storage group under given path prefix

Posted by GitBox <gi...@apache.org>.
qiaojialin merged pull request #1694:
URL: https://github.com/apache/incubator-iotdb/pull/1694


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #1694: [IOTDB-813] Show storage group under given path prefix

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on a change in pull request #1694:
URL: https://github.com/apache/incubator-iotdb/pull/1694#discussion_r484056784



##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
##########
@@ -502,6 +502,54 @@ private void findStorageGroup(
     return res;
   }
 
+  /**
+   * Get all storage group under give path
+   *
+   * @return a list contains all storage group names under give path
+   */
+  List<PartialPath> getStorageGroupPaths(PartialPath prefixPath) throws MetadataException {
+    String[] nodes = prefixPath.getNodes();
+    if (nodes.length == 0 || !nodes[0].equals(root.getName())) {
+      throw new IllegalPathException(prefixPath.getFullPath());
+    }
+    List<PartialPath> storageGroupPaths = new ArrayList<>();
+    findStorageGroupPaths(root, nodes, 1, "", storageGroupPaths);
+    return storageGroupPaths;
+  }
+
+  /**
+   * Traverse the MTree to match all storage group with prefix path.
+   *
+   * @param node              the current traversing node
+   * @param nodes             split the prefix path with '.'
+   * @param idx               the current index of array nodes
+   * @param parent            current parent path
+   * @param storageGroupPaths store all matched storage group names
+   */
+  private void findStorageGroupPaths(MNode node, String[] nodes, int idx, String parent,
+      List<PartialPath> storageGroupPaths) {
+    if (node instanceof StorageGroupMNode) {
+      storageGroupPaths.add(node.getPartialPath());
+      return;
+    }
+    String nodeReg = MetaUtils.getNodeRegByIdx(idx, nodes);
+    if (!(PATH_WILDCARD).equals(nodeReg)) {
+      if (node.hasChild(nodeReg)) {
+        findStorageGroupPaths(
+            node.getChild(nodeReg),
+            nodes,
+            idx + 1,
+            parent + node.getName() + PATH_SEPARATOR,
+            storageGroupPaths);

Review comment:
       Hi, please put these into one or two lines.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org