lbradstreet commented on a change in pull request #9008: URL: https://github.com/apache/kafka/pull/9008#discussion_r455835380
########## File path: clients/src/main/java/org/apache/kafka/common/requests/FetchRequest.java ########## @@ -273,6 +99,28 @@ public boolean equals(Object o) { } } + private Map<TopicPartition, PartitionData> toPartitionDataMap(List<FetchRequestData.FetchTopic> fetchableTopics) { + Map<TopicPartition, PartitionData> result = new LinkedHashMap<>(); + fetchableTopics.forEach(fetchTopic -> fetchTopic.partitions().forEach(fetchPartition -> { + Optional<Integer> leaderEpoch = Optional.of(fetchPartition.currentLeaderEpoch()) + .filter(epoch -> epoch != RecordBatch.NO_PARTITION_LEADER_EPOCH); + result.put(new TopicPartition(fetchTopic.topic(), fetchPartition.partition()), + new PartitionData(fetchPartition.fetchOffset(), fetchPartition.logStartOffset(), + fetchPartition.partitionMaxBytes(), leaderEpoch)); Review comment: Let's open a jira for getting rid of the toPartitionDataMap if we don't address it in this PR. It's a pretty large part of the cost here and there are only a few places we would have to deal with it. ---------------------------------------------------------------- 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