qiaojialin commented on a change in pull request #758: new 
SeriesDataRandomReader
URL: https://github.com/apache/incubator-iotdb/pull/758#discussion_r373469710
 
 

 ##########
 File path: 
server/src/main/java/org/apache/iotdb/db/query/reader/seriesRelated/SeriesDataRandomReader.java
 ##########
 @@ -419,4 +490,148 @@ public void close() throws IOException {
       openedChunkLoader.close();
     }
   }
+
+  public IPointReader getIPointReader() {
+    return new Ite();
+  }
+
+  public IBatchReader getIBatchReader() {
+    return new BatchIte();
+  }
+
+  private class BatchIte implements IBatchReader {
+
+    private BatchData batchData;
+    private boolean hasCachedBatchData = false;
+
+    /**
+     * This method overrides the AbstractDataReader.hasNextOverlappedPage for 
pause reads, to
+     * achieve a continuous read
+     */
+    @Override
+    public boolean hasNextBatch() throws IOException {
+
+      if (hasCachedBatchData) {
+        return true;
+      }
+
+      while (hasNextChunk()) {
+        while (hasNextPage()) {
+          if (!isPageOverlapped()) {
+            batchData = nextPage();
+            hasCachedBatchData = true;
+            return true;
+          }
+          while (hasNextOverlappedPage()) {
+            batchData = nextOverlappedPage();
+            hasCachedBatchData = true;
+            return true;
+          }
+        }
+      }
+      return false;
+    }
+
+    @Override
+    public BatchData nextBatch() throws IOException {
+      if (hasCachedBatchData || hasNextBatch()) {
+        hasCachedBatchData = false;
+        return batchData;
+      }
+      throw new IOException("no next batch");
+    }
+
+    @Override
+    public void close() throws IOException {
+    }
+  }
+
+  private class Ite implements IPointReader {
 
 Review comment:
   SeriesPointReader

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