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


##########
ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreClient.java:
##########
@@ -197,6 +202,49 @@ public DataStreamOutput getStreamOutput(String path, long 
dataSize, RoutingTable
     return 
client.getDataStreamApi().stream(request.toByteString().asReadOnlyByteBuffer(), 
routingTable);
   }
 
+  public DataStreamInput getStreamInput(String path, long offset, long length) 
{
+    final ReadRequestProto read = ReadRequestProto.newBuilder()
+        .setPath(ProtoUtils.toByteString(path))
+        .setOffset(offset)
+        .setLength(length)
+        .build();
+    return 
client.getDataStreamApi().streamReadOnly(read.toByteString().asReadOnlyByteBuffer());
+  }
+
+  /**
+   * Read file data using streaming read and write it to the given channel.
+   *
+   * @return total number of bytes read.
+   */
+  public long streamRead(String path, long offset, long length, 
WritableByteChannel channel)
+      throws IOException {
+    long total = 0;
+    try (DataStreamInput in = getStreamInput(path, offset, length)) {
+      while (true) {
+        final ReferenceCountedObject<DataStreamReply> ref = 
in.readAsync().join();

Review Comment:
   Sure let's improve it later.



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