jolshan commented on a change in pull request #9944: URL: https://github.com/apache/kafka/pull/9944#discussion_r572381787
########## File path: clients/src/main/java/org/apache/kafka/common/requests/FetchRequest.java ########## @@ -143,34 +275,71 @@ public String toString() { return result; } + private List<TopicPartition> toForgottenTopicList(List<FetchRequestData.ForgottenTopic> forgottenTopics, Map<Uuid, String> topicNames) { + List<TopicPartition> result = new ArrayList<>(); + forgottenTopics.forEach(forgottenTopic -> + forgottenTopic.partitions().forEach(partitionId -> { + String name = topicNames.get(forgottenTopic.topicId()); + if (name != null) + result.add(new TopicPartition(forgottenTopic.topic(), partitionId)); + }) + ); + return result; + } + + // Only used when Fetch is version 13 or greater. + private ToForgetAndIds toForgottenTopicListAndIds(List<FetchRequestData.ForgottenTopic> forgottenTopics, Map<Uuid, String> topicNames) { + List<TopicPartition> result = new ArrayList<>(); + Map<Uuid, Set<Integer>> unresolvedIds = new HashMap<>(); + forgottenTopics.forEach(forgottenTopic -> { + Set<Integer> partitions = new HashSet<>(); + forgottenTopic.partitions().forEach(partitionId -> { + String name = topicNames.get(forgottenTopic.topicId()); + if (name != null) + result.add(new TopicPartition(forgottenTopic.topic(), partitionId)); + else + partitions.add(partitionId); + }); + if (unresolvedIds.containsKey(forgottenTopic.topicId())) { + unresolvedIds.get(forgottenTopic.topicId()).addAll(partitions); + } else { + unresolvedIds.put(forgottenTopic.topicId(), partitions); Review comment: Ah. This is confusing due to how I named things. Basically, I'm collecting a set of partitions `partitions` for a given topic where the ID was not resolved. Then I'm adding them to unresolvedIds. This is a mapping from the topic ID to all the partitions that should be forgotten. I can rename and add comments to clarify what is happening here. ---------------------------------------------------------------- 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