chungen0126 commented on code in PR #10764:
URL: https://github.com/apache/ozone/pull/10764#discussion_r3840118538
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -2353,12 +2353,13 @@ private long readBlockImpl(ContainerCommandRequestProto
request, RandomAccessFil
} else {
bytesPerChecksum =
chunkInfos.get(0).getChecksumData().getBytesPerChecksum();
}
- // We have to align the read to checksum boundaries, so whatever offset is
requested, we have to move back to the
- // previous checksum boundary.
- // eg if bytesPerChecksum is 512, and the requested offset is 600, we have
to move back to 512.
- // If the checksum type is NONE, we don't have to do this, but using no
checksums should be rare in practice and
- // it simplifies the code to always do this.
- final long offsetAlignment = readBlock.getOffset() % bytesPerChecksum;
+ long offsetAlignment;
+ if (checksumType != ContainerProtos.ChecksumType.NONE) {
+ final long chunkRelativeOffset =
getChunkRelativeOffset(readBlock.getOffset(), chunkInfos);
+ offsetAlignment = chunkRelativeOffset % bytesPerChecksum;
+ } else {
+ offsetAlignment = readBlock.getOffset() % bytesPerChecksum;
+ }
Review Comment:
I'm wondering why we still need to adjust the offset when checksum
verification is skipped.
Since aligning the offset is mainly for getting complete chunks to calculate
the checksum, shouldn't we be able to read directly from the middle if there's
no verification?
--
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]