private void updatePartitionDirectories(
        Uuid topicId,
        int partitionId,
        Uuid[] previousDirectoryIds,
        Uuid[] newDirectoryIds
    ) {
        Objects.requireNonNull(topicId, "topicId cannot be null");
        TopicIdPartition topicIdPartition = new TopicIdPartition(topicId, partitionId);
        if (previousDirectoryIds != null) {
            for (Uuid dir : previousDirectoryIds) {
                if (!DirectoryId.reserved(dir)) {
                    TimelineHashSet<TopicIdPartition> partitions = directoriesToPartitions.get(dir);
                    if (partitions != null) {
                        partitions.remove(topicIdPartition);
                        if (partitions.isEmpty()) {
                            directoriesToPartitions.remove(dir);
                        }
                    }
                }
            }
        }
        if (newDirectoryIds != null) {
            for (Uuid dir : newDirectoryIds) {
                if (!DirectoryId.reserved(dir)) {
                    Set<TopicIdPartition> partitions = directoriesToPartitions.computeIfAbsent(dir,
                        __ -> new TimelineHashSet<>(snapshotRegistry, 0));
                    partitions.add(topicIdPartition);
                }
            }
        }
    }
Updates the directory to partition mapping for a single partition.
Assignments to reserved directory IDs are ignored, since they cannot
be used for directories, there's no use in maintaining a set of
partitions assigned to them.
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java