hudi-agent commented on code in PR #20321:
URL: https://github.com/apache/hudi/pull/20321#discussion_r4286739116


##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileBlock.java:
##########
@@ -137,6 +142,35 @@ protected HFileBlock(HFileContext context,
         this.startOffsetInBuff + HFILEBLOCK_HEADER_SIZE + 
uncompressedSizeWithoutHeader;
   }
 
+  /**
+   * Rejects impossible header sizes before they are used to size checksums, 
allocate buffers or
+   * locate content.
+   */
+  private void validateHeader(byte[] byteBuff, int startOffsetInBuff) {
+    long onDiskSizeWithHeader = (long) HFILEBLOCK_HEADER_SIZE + 
onDiskSizeWithoutHeader;
+    boolean valid = onDiskSizeWithoutHeader >= 0 && 
uncompressedSizeWithoutHeader >= 0

Review Comment:
   🤖 nit: could you split this `valid` expression into a few named checks, such 
as `hasNonNegativeSizes`, `fitsInBuffer`, `hasValidDataSize` and 
`uncompressedFitsOnDisk`? The trailing `(!NONE || ...)` clause is aligned like 
the other conditions, so it's easy to misread as a standalone check.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



-- 
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]

Reply via email to