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 2019/12/31 04:49:43 UTC
[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request
#687: [IOTDB-305] Add value filter function while executing group by device
Alima777 commented on a change in pull request #687: [IOTDB-305] Add value filter function while executing group by device
URL: https://github.com/apache/incubator-iotdb/pull/687#discussion_r362148245
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
##########
@@ -760,30 +760,51 @@ private void findStorageGroup(MNode node, String path, List<String> res) {
/**
* Get all devices in current Metadata Tree.
*
- * @return a list contains all distinct devices
+ * @return a list contains all distinct device names
*/
- Set<String> getAllDevices() {
- HashSet<String> devices = new HashSet<>();
- MNode node;
- if ((node = getRoot()) != null) {
- findDevices(node, SQLConstant.ROOT, devices);
- }
- return new LinkedHashSet<>(devices);
+ List<String> getAllDevices() throws PathException {
+ return getDevices(SQLConstant.ROOT);
}
- private void findDevices(MNode node, String path, HashSet<String> res) {
- if (node == null) {
- return;
+ /**
+ * Get all devices in current Metadata Tree with prefixPath.
+ *
+ * @return a list contains all distinct devices names
+ */
+ List<String> getDevices(String prefixPath) throws PathException {
+ String[] nodes = MetaUtils.getNodeNames(prefixPath, PATH_SEPARATOR);
+ if (nodes.length == 0 || !nodes[0].equals(getRoot().getName())) {
+ throw new MTreePathException("PrefixPath", prefixPath);
}
- if (node.isLeaf()) {
- res.add(path);
- return;
+ List<String> devices = new ArrayList<>();
+ findDevices(getRoot(), nodes, 1, "", devices);
+ return devices;
+ }
+
+ private void findDevices(MNode node, String[] nodes, int idx, String parent, List<String> res) {
Review comment:
fixed
----------------------------------------------------------------
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
With regards,
Apache Git Services