MINOR: Move FileRecord JavaDoc to comment (#19257)

See: https://github.com/apache/kafka/pull/19214#discussion_r2005945059

Move explaination from Javadoc to comment.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Ken Huang 2025-03-21 13:47:56 +08:00 committed by GitHub
parent 0548f1bc82
commit e21c46a504
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 6 deletions

View File

@ -292,11 +292,6 @@ public class FileRecords extends AbstractRecords implements Closeable {
/** /**
* Search forward for the file position of the message batch whose last offset that is greater * 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. * 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.
* *
* @param targetOffset The offset to search for. * @param targetOffset The offset to search for.
* @param startingPosition The starting position in the file to begin searching from. * @param startingPosition The starting position in the file to begin searching from.
@ -304,7 +299,9 @@ public class FileRecords extends AbstractRecords implements Closeable {
*/ */
public LogOffsetPosition searchForOffsetFromPosition(long targetOffset, int startingPosition) { public LogOffsetPosition searchForOffsetFromPosition(long targetOffset, int startingPosition) {
FileChannelRecordBatch prevBatch = null; FileChannelRecordBatch prevBatch = null;
// The following logic is intentionally designed to minimize memory usage by avoiding
// unnecessary calls to lastOffset() for every batch.
// Instead, we use baseOffset() comparisons when possible, and only check lastOffset() when absolutely necessary.
for (FileChannelRecordBatch batch : batchesFrom(startingPosition)) { for (FileChannelRecordBatch batch : batchesFrom(startingPosition)) {
// If baseOffset exactly equals targetOffset, return immediately // If baseOffset exactly equals targetOffset, return immediately
if (batch.baseOffset() == targetOffset) { if (batch.baseOffset() == targetOffset) {