Alima777 commented on a change in pull request #2389:
URL: https://github.com/apache/iotdb/pull/2389#discussion_r550379435
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -688,6 +689,10 @@ public TSDataType getSeriesType(PartialPath path) throws
MetadataException {
return mtree.getDevices(prefixPath);
}
+ public Set<PartialPath> showDevices(ShowDevicesPlan plan) throws
MetadataException {
Review comment:
Rename this to `getDevices` or change the other to `showDevices` to
implement overloading.
##########
File path: server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
##########
@@ -672,6 +673,17 @@ private TSExecuteStatementResp
internalExecuteQueryStatement(String statement,
((ShowTimeSeriesPlan) plan).setHasLimit(true);
}
}
+
+ if (plan instanceof ShowDevicesPlan) {
+ //If the user does not pass the limit, then set limit = fetchSize and
haslimit=false,else set haslimit = true
+ if (((ShowDevicesPlan) plan).getLimit() == 0) {
+ ((ShowDevicesPlan) plan).setLimit(fetchSize);
+ ((ShowDevicesPlan) plan).setHasLimit(false);
+ } else {
+ ((ShowDevicesPlan) plan).setHasLimit(true);
+ }
+ }
+
Review comment:
Do this in `PhysicalGenerator` or the constructor of `ShowDevicePlan`,
not here.
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
##########
@@ -1121,7 +1122,32 @@ private void findChildNodePathInNextLevel(
throw new IllegalPathException(prefixPath.getFullPath());
}
Set<PartialPath> devices = new TreeSet<>();
- findDevices(root, nodes, 1, devices);
+ findDevices(root, nodes, 1, devices, false);
+ return devices;
+ }
+
+ Set<PartialPath> getDevices(ShowDevicesPlan plan) throws MetadataException {
+ String[] nodes = plan.getPath().getNodes();
+ if (nodes.length == 0 || !nodes[0].equals(root.getName())) {
+ throw new IllegalPathException(plan.getPath().getFullPath());
+ }
+ Set<PartialPath> devices;
+ limit.set(plan.getLimit());
+ offset.set(plan.getOffset());
+ curOffset.set(-1);
+ count.set(0);
+ if (offset.get() != 0 || limit.get() != 0) {
+ devices = new TreeSet<>();
+ findDevices(root, nodes, 1, devices, true);
+ } else {
+ devices = new TreeSet<>();
Review comment:
Line 1134: Set<PartialPath> devices = new TreeSet<>();
----------------------------------------------------------------
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]