private void addPartitionMovementRecord(TopicPartition partition, ConsumerPair pair) {
            partitionMovements.put(partition, pair);

            String topic = partition.topic();
            if (!partitionMovementsByTopic.containsKey(topic))
                partitionMovementsByTopic.put(topic, new HashMap<>());

            Map<ConsumerPair, Set<TopicPartition>> partitionMovementsForThisTopic = partitionMovementsByTopic.get(topic);
            if (!partitionMovementsForThisTopic.containsKey(pair))
                partitionMovementsForThisTopic.put(pair, new HashSet<>());

            partitionMovementsForThisTopic.get(pair).add(partition);
        }
This class maintains some data structures to simplify lookup of partition movements among consumers. At each point of
time during a partition rebalance it keeps track of partition movements corresponding to each topic, and also possible
movement (in form a <code>ConsumerPair</code> object) for each partition.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java