clolov commented on code in PR #15213:
URL: https://github.com/apache/kafka/pull/15213#discussion_r1481540437


##########
core/src/main/scala/kafka/log/UnifiedLog.scala:
##########
@@ -1300,18 +1301,29 @@ class UnifiedLog(@volatile var logStartOffset: Long,
       } else if (targetTimestamp == 
ListOffsetsRequest.EARLIEST_LOCAL_TIMESTAMP) {
         val curLocalLogStartOffset = localLogStartOffset()
 
-        val earliestLocalLogEpochEntry = leaderEpochCache.asJava.flatMap(cache 
=> {
-          val epoch = cache.epochForOffset(curLocalLogStartOffset)
-          if (epoch.isPresent) cache.epochEntry(epoch.getAsInt) else 
Optional.empty[EpochEntry]()
-        })
-
-        val epochOpt = if (earliestLocalLogEpochEntry.isPresent && 
earliestLocalLogEpochEntry.get().startOffset <= curLocalLogStartOffset)
-          Optional.of[Integer](earliestLocalLogEpochEntry.get().epoch)
-        else Optional.empty[Integer]()
+        var epochResult: Optional[Integer] = 
Optional.of(RecordBatch.NO_PARTITION_LEADER_EPOCH)

Review Comment:
   You are correct, this is a miss on my side as part of making this piece of 
code more readable - fixing it in the subsequent commit.
   
   The logic should be
   * For EARLIEST_LOCAL_TIMESTAMP - return empty unless there is a leader epoch
   * For LATEST_TIERED_TIMESTAMP - if highest offset is -1 then return -1, if 
there is a highest offset then return empty unless there is a leader epoch



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

Reply via email to