jolshan commented on a change in pull request #9944:
URL: https://github.com/apache/kafka/pull/9944#discussion_r572355958



##########
File path: 
clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java
##########
@@ -265,9 +353,32 @@ public FetchRequestData build() {
             Map<TopicPartition, PartitionData> curSessionPartitions = 
copySessionPartitions
                     ? Collections.unmodifiableMap(new 
LinkedHashMap<>(sessionPartitions))
                     : Collections.unmodifiableMap(sessionPartitions);
+            Map<String, Uuid> toSendTopicIds =
+                    Collections.unmodifiableMap(new 
HashMap<>(sessionTopicIds));
+            Map<Uuid, String> toSendTopicNames =
+                    Collections.unmodifiableMap(new 
HashMap<>(sessionTopicNames));
+            boolean canUseTopicIds = sessionPartitionsPerTopic.size() == 
toSendTopicIds.size();
+
             next = null;
+            topicIds = null;
+            topicNames = null;
+            partitionsPerTopic = null;
             return new FetchRequestData(toSend, 
Collections.unmodifiableList(removed),
-                curSessionPartitions, nextMetadata);
+                curSessionPartitions, toSendTopicIds, toSendTopicNames, 
nextMetadata, canUseTopicIds);
+        }
+
+        private void addPartitionsAndIds(Map<String, Set<Integer>> 
partitionsPerTopic,
+                                         TopicPartition tp, Uuid id, 
Map<String, Uuid> topicIds,
+                                         Map<Uuid, String> topicNames) {
+            if (partitionsPerTopic.containsKey(tp.topic())) {
+                partitionsPerTopic.get(tp.topic()).add(tp.partition());
+            } else {
+                partitionsPerTopic.put(tp.topic(), new 
HashSet<>(tp.partition()));

Review comment:
       Yeah. Good catch. I'm going to experiment with this code a bit to see if 
it's faster to maintain this set or just get a set of topics from the map of 
topic partitions in` FetchRequestData`




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


Reply via email to