chia7712 commented on code in PR #15621: URL: https://github.com/apache/kafka/pull/15621#discussion_r1550270774
########## clients/src/main/java/org/apache/kafka/common/record/RecordBatch.java: ########## @@ -245,4 +246,23 @@ public interface RecordBatch extends Iterable<Record> { * @return Whether this is a batch containing control records */ boolean isControlBatch(); + + /** + * iterate all records to find the offset of max timestamp. + * noted: + * 1) that the earliest offset will return if there are multi records having same (max) timestamp + * 2) it always return -1 if the {@link RecordBatch#magic()} is equal to {@link RecordBatch#MAGIC_VALUE_V0} + * @return offset of max timestamp + */ + default Optional<Long> offsetOfMaxTimestamp() { + if (magic() == RecordBatch.MAGIC_VALUE_V0) return Optional.empty(); Review Comment: @junrao the short-circuit is added -- 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