761417898 commented on code in PR #568:
URL: https://github.com/apache/tsfile/pull/568#discussion_r2427821873


##########
java/tsfile/src/main/java/org/apache/tsfile/read/query/dataset/TreeResultSet.java:
##########
@@ -56,6 +72,92 @@ public void close() {
 
   @Override
   public Iterator<TSRecord> recordIterator() {
-    return null;
+    return new TreeResultSet.RecordIterator();
+  }
+
+  private class RecordIterator implements Iterator<TSRecord> {
+    private final LinkedList<TSRecord> recordBuffer = new LinkedList<>();
+    private boolean exhausted = false;
+
+    @Override
+    public boolean hasNext() {
+      if (!recordBuffer.isEmpty()) {
+        return true;
+      }
+      if (exhausted) {
+        return false;
+      }
+
+      try {
+        return fetchRecords();
+      } catch (IOException e) {
+        throw new NoSuchElementException(e.toString());
+      }
+    }
+
+    private boolean fetchRecords() throws IOException {
+      boolean hasNewRecords = false;
+      while (TreeResultSet.this.next()) {
+        for (String device : deviceList) {
+          TSRecord record = new TSRecord(device, getLong("Time"));
+          record.addPoint("id", device);
+
+          for (String measurement : measurementList) {
+            Integer pathIdx =
+                pathIndexMap.get(new Path(new StringArrayDeviceID(device), 
measurement, false));

Review Comment:
   fixed
   ```
     private Map<String, Map<String, Path>> cachedPaths;
   
     // .......
       this.cachedPaths = new HashMap<>();
       for (String device : deviceList) {
         Map<String, Path> measurementPathMap = new HashMap<>();
         for (String measurement : measurementList) {
           measurementPathMap.put(measurement,
                   new Path(new StringArrayDeviceID(device), measurement, 
false));
         }
         cachedPaths.put(device, measurementPathMap);
       }
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to