qiaojialin commented on a change in pull request #435: [IOTDB-174] Fix querying 
timeseries interface cannot make a query by the specified path prefix
URL: https://github.com/apache/incubator-iotdb/pull/435#discussion_r338917311
 
 

 ##########
 File path: server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
 ##########
 @@ -781,20 +777,56 @@ private void findStorageGroup(MNode node, String path, 
HashSet<String> res) {
    *
    * @return a list contains all distinct devices
    */
-  Set<String> getAllDevices() {
-    return new HashSet<>(getNodesList(3));
+  Set<String> getAllDevices() throws SQLException {
+    List<String> res = new ArrayList<>();
+    MNode node;
+    if ((node = getRoot()) != null) {
+      findDevices(node, "root", res);
+    }
+    return new LinkedHashSet<>(res);
+  }
+
+  private void findDevices(MNode node, String path, List<String> res) {
+    if (node == null) {
+      return;
+    }
+    if (node.isLeaf()) {
+      res.add(path);
+      return;
+    }
+    if (node.hasChildren()) {
+      for (MNode child : node.getChildren().values()) {
+        if (child.isLeaf()) {
+          findDevices(child, path, res);
+        } else {
+          findDevices(child, path + "." + child.toString(), res);
+        }
+      }
+    }
   }
 
   /**
    * Get all nodes at the given level in current Metadata Tree.
    *
    * @return a list contains all nodes at the given level
    */
-  List<String> getNodesList(int nodeLevel) {
+  List<String> getNodesList(String schemaPattern, int nodeLevel) throws 
SQLException {
 
 Review comment:
   ok

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to