public static Map<String, List<Integer>> groupPartitionsByTopic(Collection<TopicPartition> partitions) {
        return groupPartitionsByTopic(
            partitions,
            topic -> new ArrayList<>(),
            List::add
        );
    }
Group a list of partitions by the topic name.

@param partitions The partitions to collect
@return partitions per topic
clients/src/main/java/org/apache/kafka/common/utils/CollectionUtils.java