hachikuji commented on a change in pull request #9275: URL: https://github.com/apache/kafka/pull/9275#discussion_r488309917
########## File path: core/src/main/scala/kafka/server/epoch/LeaderEpochFileCache.scala ########## @@ -91,8 +95,23 @@ class LeaderEpochFileCache(topicPartition: TopicPartition, } } + def removeEntries(predicate: EpochEntry => Boolean): Seq[EpochEntry] = { + val removedEpochs = mutable.ListBuffer.empty[EpochEntry] + val iterator = epochs.entrySet().iterator() + + while (iterator.hasNext) { Review comment: That's a good question. We probably could be smarter in `truncateAndAppend` if it was safe to assume epoch/start offset increases monotonically. Maybe we just need to add the logic to validate that invariant on startup. Let me take a look at 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org