private void remove(int brokerId, Uuid topicId, int removedPartition) {
        TimelineHashMap<Uuid, int[]> topicMap = elrMembers.get(brokerId);
        if (topicMap == null) {
            throw new RuntimeException("Broker " + brokerId + " has no elrMembers " +
                    "entry, so we can't remove " + topicId + ":" + removedPartition);
        }
        int[] partitions = topicMap.get(topicId);
        if (partitions == null) {
            throw new RuntimeException("Broker " + brokerId + " has no " +
                    "entry in elrMembers for topic " + topicId);
        }
        if (partitions.length == 1) {
            if (partitions[0] != removedPartition) {
                throw new RuntimeException("Broker " + brokerId + " has no " +
                        "entry in elrMembers for " + topicId + ":" + removedPartition);
            }
            topicMap.remove(topicId);
            if (topicMap.isEmpty()) {
                elrMembers.remove(brokerId);
            }
        } else {
            int[] newPartitions = new int[partitions.length - 1];
            int i = 0;
            for (int partition : partitions) {
                if (partition != removedPartition) {
                    newPartitions[i++] = partition;
                }
            }
            topicMap.put(topicId, newPartitions);
        }
    }
Update our records of a partition's ELR.

@param topicId       The topic ID of the partition.
@param partitionId   The partition ID of the partition.
@param prevElr       The previous ELR, or null if the partition is new.
@param nextElr       The new ELR, or null if the partition is being removed.
metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java