amaliujia commented on code in PR #1488:
URL: https://github.com/apache/ratis/pull/1488#discussion_r3526119436


##########
ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java:
##########
@@ -88,6 +89,34 @@ ByteString read(CheckedFunction<Path, Path, IOException> 
resolver, long offset,
     }
   }
 
+  void streamRead(CheckedFunction<Path, Path, IOException> resolver, long 
offset, long length,
+      WritableByteChannel stream) throws IOException {
+    if (offset + length > getWriteSize()) {
+      throw new IOException("Failed to read Wrote: offset (=" + offset
+          + " + length (=" + length + ") > size = " + getWriteSize()
+          + ", path=" + getRelativePath());
+    }
+
+    try (SeekableByteChannel in = Files.newByteChannel(
+        resolver.apply(getRelativePath()), StandardOpenOption.READ)) {
+      in.position(offset);
+      long remaining = length;
+      while (remaining > 0) {
+        final int chunkSize = FileStoreCommon.getChunkSize(remaining);
+        final ByteBuffer buffer = ByteBuffer.allocateDirect(chunkSize);

Review Comment:
   https://github.com/apache/ratis/pull/1488#discussion_r3468796242 suggested a 
different way which eliminated the need for this buffer 



##########
ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreCommon.java:
##########
@@ -47,6 +51,15 @@ static ByteString toByteString(Path p) {
     return ProtoUtils.toByteString(p.toString());
   }
 
+  static ByteBuffer getReplyBuffer(DataStreamReply reply) {

Review Comment:
   Rebased and use the new interface now.



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