ijuma commented on code in PR #19214:
URL: https://github.com/apache/kafka/pull/19214#discussion_r2005945059


##########
clients/src/main/java/org/apache/kafka/common/record/FileRecords.java:
##########
@@ -292,17 +292,43 @@ public int writeTo(TransferableChannel destChannel, int 
offset, int length) thro
     /**
      * Search forward for the file position of the message batch whose last 
offset that is greater
      * than or equal to the target offset. If no such batch is found, return 
null.
+     * <p>
+     * The following logic is intentionally designed to minimize memory usage
+     * by avoiding unnecessary calls to {@link 
FileChannelRecordBatch#lastOffset()} for every batch.
+     * Instead, we use {@link FileChannelRecordBatch#baseOffset()} comparisons 
when possible, and only 
+     * check {@link FileChannelRecordBatch#lastOffset()} when absolutely 
necessary.

Review Comment:
   The javadoc should explain the behavior of the method. This type of comment 
should be next to the actual code - it doesn't affect callers. It likely won't 
be seen by people changing the implementation either.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to