yazgoo commented on code in PR #16486:
URL: https://github.com/apache/kafka/pull/16486#discussion_r1673685382


##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:
##########
@@ -793,6 +796,46 @@ protected void assignConnectors(List<WorkerLoad> 
workerAssignment, Collection<St
         }
     }
 
+    static class BalancedIterator<E> implements Iterator<E> {
+
+        private final Map<String, Iterator<E>> grouped;
+        private final List<String> keys;
+
+        private int k;
+
+        public BalancedIterator(Collection<E> collection, Function<E, String> 
allocationGrouper) {
+            this.k = 0;
+            this.grouped = collection.stream().collect(Collectors.groupingBy(
+                    allocationGrouper,
+                    Collectors.collectingAndThen(
+                            Collectors.toList(),
+                            List::iterator
+                    )
+            ));
+            this.keys = collection.stream()
+                .map(allocationGrouper)
+                .distinct()
+                .collect(Collectors.toList());

Review Comment:
   Thanks for the clarification !
   The BalancedIterator is only used to group:
   
   - `Collection<ConnectorTaskId>` by `connector
   - `Collection<String>` (string beings `Connector`) by `identity`
   
   So the structure is not aware of workers.



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