chungen0126 commented on code in PR #10765:
URL: https://github.com/apache/ozone/pull/10765#discussion_r3596215556
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java:
##########
@@ -289,7 +313,106 @@ protected synchronized void addStream(ChunkInfo
chunkInfo) {
protected ChunkInputStream createChunkInputStream(ChunkInfo chunkInfo) {
return new ChunkInputStream(chunkInfo, blockID,
- xceiverClientFactory, pipelineRef::get, verifyChecksum, tokenRef::get);
+ xceiverClientFactory, pipelineRef::get, verifyChecksum, tokenRef::get,
lock);
+ }
+
+ @Override
+ public boolean readFully(long pos, ByteBuffer buffer) throws IOException {
+ Preconditions.checkArgument(buffer != null);
+ if (!initialized) {
+ initialize();
+ }
+
+ if (pos < 0 || pos > length) {
+ if (pos == 0) {
+ // It is possible for length and pos to be zero in which case
+ // seek should return instead of throwing exception
+ return true;
+ }
+ throw new EOFException(
+ "EOF encountered at pos: " + pos + " for block: " + blockID);
+ }
+
+ checkOpen();
+ int len = buffer.remaining();
+ int innerRetries = 0;
+ int chunkIdx = Arrays.binarySearch(chunkOffsets, pos);
+ if (chunkIdx < 0) {
Review Comment:
If the binary search doesn't find an exact match in the array, it returns a
negative number. For details, please see:
https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#binarySearch-int:A-int-
--
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]