ChenSammi commented on code in PR #6372:
URL: https://github.com/apache/ozone/pull/6372#discussion_r1524300587
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java:
##########
@@ -137,4 +139,49 @@ public void unbuffer() {
((CanUnbuffer) inputStream).unbuffer();
}
}
+
+ /**
+ * @param buf the ByteBuffer to receive the results of the read operation.
+ * @param position offset
+ * @return the number of bytes read, possibly zero, or -1 if
+ * reach end-of-stream
+ * @throws IOException if there is some error performing the read
+ */
+ @Override
+ public int read(long position, ByteBuffer buf) throws IOException {
+ if (!buf.hasRemaining()) {
+ return 0;
+ }
+ long oldPos = this.getPos();
+ int bytesRead;
+ try {
+ ((Seekable) inputStream).seek(position);
+ bytesRead = ((ByteBufferReadable) inputStream).read(buf);
+ } catch (EOFException e) {
+ // Either position is negative or it has reached EOF
+ return -1;
+ } finally {
+ ((Seekable) inputStream).seek(oldPos);
+ }
+ return bytesRead;
+ }
+
+ /**
+ * @param buf the ByteBuffer to receive the results of the read operation.
+ * @param position offset
+ * @return void
+ * @throws IOException if there is some error performing the read
+ * @throws EOFException if end of file reched before reading fully
Review Comment:
reched -> reached
--
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]