Copilot commented on code in PR #12046:
URL: https://github.com/apache/ozone/pull/12046#discussion_r4569695431
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/checksum/BaseFileChecksumHelper.java:
##########
@@ -377,14 +392,25 @@ FileChecksum makeCompositeCrcResult() throws IOException {
}
CrcComposer crcComposer =
CrcComposer.newCrcComposer(toHadoopChecksumType(), blockSizeHint);
+ // NB: blockChecksumBytes.length may be much longer than actual bytes
written into the DataOutput.
byte[] blockChecksumBytes = blockChecksumBuf.getData();
+ int checksumOffset = 0;
for (int i = 0; i < keyLocationInfos.size(); ++i) {
OmKeyLocationInfo block = keyLocationInfos.get(i);
+ if (block.getLength() == 0) {
+ // checksumBlocks() skipped the empty block, there is no CRC to read.
+ continue;
+ }
+ if (checksumOffset >= blockChecksumBuf.getLength()) {
+ // checksumBlocks() stopped before this block because of the requested
length.
+ break;
Review Comment:
For a key with 1000- and 700-byte blocks, requesting length 1000 still
returns the full-key CRC: `checksumBlocks()` permits `currentLength ==
getLength()`, so both block CRCs are written and this guard consumes both. Stop
collecting block checksums once the requested length is exhausted by changing
the collection-loop check to `currentLength >= getLength()`. Add an
exact-block-boundary regression case; the new 500-byte request does not cover
it.
--
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]