chia7712 commented on code in PR #19214: URL: https://github.com/apache/kafka/pull/19214#discussion_r2005987706
########## 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: https://github.com/apache/kafka/pull/19257 -- 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