szetszwo commented on code in PR #11245:
URL: https://github.com/apache/ozone/pull/11245#discussion_r4065326381


##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java:
##########
@@ -211,4 +225,101 @@ public void readFully(long position, ByteBuffer buf) 
throws IOException {
       }
     }
   }
+
+  /**
+   * Byte-array positioned read. Tries the native stateless {@link 
ExtendedInputStream#readFully}
+   * path first (via a zero-copy {@link ByteBuffer#wrap}). Falls back to a 
synchronized
+   * seek-read-restore using byte-array {@link #read(byte[], int, int)} so 
that the fallback
+   * works for any {@link Seekable} stream, not just those that also implement
+   * {@link org.apache.hadoop.fs.ByteBufferReadable}.
+   * <p>
+   * {@link FSInputStream} synchronizes its inherited implementation on {@code 
this}, a different
+   * monitor from {@code positionedReadLock}; without this override the two 
APIs can interleave.
+   */
+  @Override
+  public int read(long position, byte[] buffer, int offset, int length) throws 
IOException {

Review Comment:
   > ... we only support ByteBufferReadable , ...
   
   In current code, are the inner input streams always ByteBufferReadable?  If 
yes, let's only support ByteBufferReadable.  (We may add a assertion in the 
constructor as  well.)



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to