bharatviswa504 commented on a change in pull request #804: HDDS-1496. Support
partial chunk reads and checksum verification
URL: https://github.com/apache/hadoop/pull/804#discussion_r287088418
##########
File path:
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java
##########
@@ -146,22 +160,34 @@ public synchronized int read(byte[] b, int off, int len)
throws IOException {
// this case.
throw new IOException(String.format(
"Inconsistent read for blockID=%s length=%d numBytesRead=%d",
- current.blockInputStream.getBlockID(), current.length,
- numBytesRead));
+ current.getBlockID(), current.getLength(), numBytesRead));
}
totalReadLen += numBytesRead;
off += numBytesRead;
len -= numBytesRead;
if (current.getRemaining() <= 0 &&
- ((currentStreamIndex + 1) < streamEntries.size())) {
- currentStreamIndex += 1;
+ ((blockIndex + 1) < blockStreams.size())) {
+ blockIndex += 1;
}
}
return totalReadLen;
}
+ /**
+ * Seeks the KeyInputStream to the specified position. This involves 2 steps:
+ * 1. Updating the blockIndex to the blockStream corresponding to the
+ * seeked position.
+ * 2. Seeking the corresponding blockStream to the adjusted position.
+ *
+ * For example, let’s say the block size is 200 bytes and block[0] stores
+ * data from indices 0 - 199, block[1] from indices 200 - 399 and so on.
+ * Let’s say we seek to position 240. In the first step, the blockIndex
+ * would be updated to 1 as indices 200 - 399 reside in blockStream[1]. In
+ * the second step, the blockStream[1] would be seeked to position 40 (=
+ * 240 - blockOffset[1] (= 200)).
+ */
@Override
- public void seek(long pos) throws IOException {
+ public synchronized void seek(long pos) throws IOException {
checkNotClosed();
Review comment:
NIT: Not changed by this patch, can we rename this to checkOpen() similar to
other inputStreams?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]