ijuma commented on a change in pull request #10960: URL: https://github.com/apache/kafka/pull/10960#discussion_r664036719
########## File path: core/src/main/scala/kafka/log/LogSegment.scala ########## @@ -386,15 +385,13 @@ class LogSegment private[log] (val log: FileRecords, private def loadLargestTimestamp(): Unit = { // Get the last time index entry. If the time index is empty, it will return (-1, baseOffset) val lastTimeIndexEntry = timeIndex.lastEntry - maxTimestampSoFar = lastTimeIndexEntry.timestamp - offsetOfMaxTimestampSoFar = lastTimeIndexEntry.offset + maxTimestampAndOffsetSoFar = TimestampOffset(lastTimeIndexEntry.timestamp, lastTimeIndexEntry.offset) Review comment: Why are we creating a new instance here? Isn't `lastIndexEntry` what we want already? ########## File path: core/src/main/scala/kafka/log/Log.scala ########## @@ -1345,8 +1345,9 @@ class Log(@volatile private var _dir: File, val latestTimestampSegment = segmentsCopy.maxBy(_.maxTimestampSoFar) val latestEpochOpt = leaderEpochCache.flatMap(_.latestEpoch).map(_.asInstanceOf[Integer]) val epochOptional = Optional.ofNullable(latestEpochOpt.orNull) - Some(new TimestampAndOffset(latestTimestampSegment.maxTimestampSoFar, - latestTimestampSegment.offsetOfMaxTimestampSoFar, + val latestTimestampAndOffset = latestTimestampSegment.maxTimestampAndOffsetSoFar + Some(new TimestampAndOffset(latestTimestampAndOffset.timestamp, + latestTimestampAndOffset.offset, Review comment: Is this another instance of unnecessary copying? Are there others? ########## File path: core/src/main/scala/kafka/log/Log.scala ########## @@ -1345,8 +1345,9 @@ class Log(@volatile private var _dir: File, val latestTimestampSegment = segmentsCopy.maxBy(_.maxTimestampSoFar) val latestEpochOpt = leaderEpochCache.flatMap(_.latestEpoch).map(_.asInstanceOf[Integer]) val epochOptional = Optional.ofNullable(latestEpochOpt.orNull) - Some(new TimestampAndOffset(latestTimestampSegment.maxTimestampSoFar, - latestTimestampSegment.offsetOfMaxTimestampSoFar, + val latestTimestampAndOffset = latestTimestampSegment.maxTimestampAndOffsetSoFar + Some(new TimestampAndOffset(latestTimestampAndOffset.timestamp, + latestTimestampAndOffset.offset, Review comment: Oh, this is a different type (`TimestampAndOffset`). -- 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