lianetm commented on code in PR #14690:
URL: https://github.com/apache/kafka/pull/14690#discussion_r1408355119


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManager.java:
##########
@@ -192,6 +221,26 @@ private NetworkClientDelegate.UnsentRequest 
makeHeartbeatRequest() {
         });
     }
 
+    private List<ConsumerGroupHeartbeatRequestData.TopicPartitions> 
buildTopicPartitionsList(Set<TopicIdPartition> topicIdPartitions) {
+        List<ConsumerGroupHeartbeatRequestData.TopicPartitions> result = new 
ArrayList<>();
+        Map<Uuid, List<Integer>> partitionsPerTopicId = new HashMap<>();
+        for (TopicIdPartition topicIdPartition : topicIdPartitions) {
+            Uuid topicId = topicIdPartition.topicId();
+            if (!partitionsPerTopicId.containsKey(topicId)) {
+                partitionsPerTopicId.put(topicId, new ArrayList<>());
+            }
+            
partitionsPerTopicId.get(topicId).add(topicIdPartition.partition());
+        }
+        for (Map.Entry<Uuid, List<Integer>> entry : 
partitionsPerTopicId.entrySet()) {
+            Uuid topicId = entry.getKey();
+            List<Integer> partitions = entry.getValue();
+            result.add(new ConsumerGroupHeartbeatRequestData.TopicPartitions()
+                    .setTopicId(topicId)
+                    .setPartitions(partitions));
+        }

Review Comment:
   Definitely, done in the [follow-up 
PR](https://github.com/apache/kafka/pull/14857)



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