mingyen066 opened a new pull request, #23477:
URL: https://github.com/apache/kafka/pull/23477

   `FileRecords.searchForTimestamp`, `RemoteLogManager.lookupTimestamp` and 
`RecordBatch.offsetOfMaxTimestamp` iterate records only to read `timestamp()` 
and `offset()`, but they use `streamingIterator`, which for compressed v2 
batches decodes and copies every record's key, value and headers into fresh 
ByteBuffers. `skipKeyValueIterator` (added in KAFKA-8106 for the log validator) 
reads the same scalar fields and skips the body with `InputStream.skip()`, 
returning a `PartialDefaultRecord`, but it was only declared on 
`MutableRecordBatch`, so the file-backed `FileChannelRecordBatch` used by 
`searchForTimestamp` could not use it.
   
   Changes:
   
   - moves both `skipKeyValueIterator` overloads from `MutableRecordBatch` to 
`RecordBatch`, next to `streamingIterator`;
   - implements them on `FileChannelRecordBatch` by delegating to 
`loadFullBatch()`, the same way `streamingIterator` already does;
   - moves the legacy (v0/v1) fallback from `ByteBufferLegacyRecordBatch` up to 
`AbstractLegacyRecordBatch`, so `BasicLegacyRecordBatch` (the inner record of a 
compressed legacy wrapper) is covered too. The fallback now returns the 
closeable iterator directly instead of wrapping it in `CloseableIterator.wrap`, 
which silently turned `close()` into a no-op;
   - switches the three timestamp lookup paths to `skipKeyValueIterator`. The 
`maxRecordBodySize` guard from #23429 still applies, since `readPartiallyFrom` 
enforces it the same way `readFrom` does.
   
   Uncompressed batches are unaffected: `skipKeyValueIterator` returns the 
zero-copy `uncompressedIterator` for them, exactly as `streamingIterator` does.
   


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