How do you optimize a Spark job that is suffering from data skew?
Implement a deterministic Python simulation of salting. Given record keys, known hot keys, partition count, and salt bucket count, return the number of records assigned to each partition. Non-hot keys use sum(ord(c) for c in key) % num_partitions; occurrences of hot keys rotate through salt buckets before mapping to partitions.
def partition_loads(records, hot_keys, num_partitions, salt_buckets): returns a list of num_partitions integers.
def partition_loads(records, hot_keys, num_partitions, salt_buckets):