adixitconfluent commented on code in PR #19142: URL: https://github.com/apache/kafka/pull/19142#discussion_r1984521190
########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleAssignor.java: ########## @@ -135,56 +148,68 @@ private GroupAssignment newAssignmentHomogeneous( List<TopicIdPartition> targetPartitions, Map<TopicIdPartition, List<String>> currentAssignment ) { - Map<TopicIdPartition, List<String>> newAssignment = new HashMap<>(); - - // Step 1: Hash member IDs to topic partitions. - memberHashAssignment(targetPartitions, groupSpec.memberIds(), newAssignment); + int numGroupMembers = groupSpec.memberIds().size(); + int numTargetPartitions = targetPartitions.size(); + int desiredAssignmentCount = (numTargetPartitions + numGroupMembers - 1) / numGroupMembers; - // Step 2: Round-robin assignment for unassigned partitions which do not have members already assigned in the current assignment. - List<TopicIdPartition> unassignedPartitions = targetPartitions.stream() - .filter(targetPartition -> !newAssignment.containsKey(targetPartition)) - .filter(targetPartition -> !currentAssignment.containsKey(targetPartition)) - .toList(); + Map<TopicIdPartition, List<String>> newAssignment = new HashMap<>((int) (((numTargetPartitions + 1) / 0.75f) + 1)); Review Comment: What's the rationale behind using 0.75f and not some other arbitrary number? ########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleAssignor.java: ########## @@ -135,56 +148,68 @@ private GroupAssignment newAssignmentHomogeneous( List<TopicIdPartition> targetPartitions, Map<TopicIdPartition, List<String>> currentAssignment ) { - Map<TopicIdPartition, List<String>> newAssignment = new HashMap<>(); - - // Step 1: Hash member IDs to topic partitions. - memberHashAssignment(targetPartitions, groupSpec.memberIds(), newAssignment); + int numGroupMembers = groupSpec.memberIds().size(); + int numTargetPartitions = targetPartitions.size(); + int desiredAssignmentCount = (numTargetPartitions + numGroupMembers - 1) / numGroupMembers; Review Comment: I wanted to understand how we came up with the number? -- 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