You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2019/12/12 01:46:29 UTC

[GitHub] [hadoop-ozone] bharatviswa504 commented on a change in pull request #345: HDDS-2703. OzoneFSInputStream to support ByteBufferReadable

bharatviswa504 commented on a change in pull request #345: HDDS-2703. OzoneFSInputStream to support ByteBufferReadable
URL: https://github.com/apache/hadoop-ozone/pull/345#discussion_r356923285
 
 

 ##########
 File path: hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java
 ##########
 @@ -76,4 +79,21 @@ public boolean seekToNewSource(long targetPos) throws IOException {
   public int available() throws IOException {
     return inputStream.available();
   }
+
+  /**
+   * @param buf the ByteBuffer to receive the results of the read operation.
+   * @return the number of bytes read, possibly zero.
+   * @throws IOException if there is some error performing the read
+   */
+  @Override
+  public int read(ByteBuffer buf) throws IOException {
+
+    int bufInitPos = buf.position();
+    while (buf.hasRemaining() && (inputStream.available() > 0)) {
 
 Review comment:
   Instead of reading byte by byte, can we use inputStream.read(byte b[], int off, int len)?
   
   Something in similar terms
   ```
       int readLen = Math.min(buf.remaining(), inputStream.available());
       byte[] readData = new byte[readLen];
   
       inputStream.read(readData, bufInitPos, readLen);
       buf.put(readData);
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org