szetszwo commented on code in PR #10764:
URL: https://github.com/apache/ozone/pull/10764#discussion_r3896884636


##########
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:
   @chungen0126 , ChecksumType.NONE is a uncommon case.  Let's keep the code 
simple and don't do anything special for 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]

Reply via email to