ijuma commented on a change in pull request #10960: URL: https://github.com/apache/kafka/pull/10960#discussion_r663382958
########## File path: core/src/main/scala/kafka/log/LogSegment.scala ########## @@ -99,21 +99,22 @@ class LogSegment private[log] (val log: FileRecords, // volatile for LogCleaner to see the update @volatile private var rollingBasedTimestamp: Option[Long] = None + /* The maximum timestamp and offset we see so far */ + @volatile private var _maxTimestampAndOffsetSoFar: (Option[Long], Option[Long]) = (None, None) + def maxTimestampAndOffsetSoFar_= (timestampAndOffset: (Long, Long)) : Unit = _maxTimestampAndOffsetSoFar = (Some(timestampAndOffset._1), Some(timestampAndOffset._2)) + def maxTimestampAndOffsetSoFar: (Long,Long) = { + if (_maxTimestampAndOffsetSoFar._1.isEmpty || _maxTimestampAndOffsetSoFar._2.isEmpty) + _maxTimestampAndOffsetSoFar = (Some(timeIndex.lastEntry.timestamp), Some(timeIndex.lastEntry.offset)) + (_maxTimestampAndOffsetSoFar._1.get, _maxTimestampAndOffsetSoFar._2.get) + } Review comment: There is a `TimestampOffset` too. Can we use that? -- 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