HashPartitioner is a Partitioner for hash-based partitioning.
HashPartitioner places null keys in 0th partition.
HashPartitioner is used as the default Partitioner.
HashPartitioner takes the following to be created:
- Number of partitions
Number of Partitions¶
numPartitions returns the given number of partitions.
numPartitions is part of the Partitioner abstraction.
Partition for Key¶
getPartition( key: Any): Int
getPartition simply returns
getPartition uses the Object.hashCode of the key modulo the number of partitions. For negative results,
getPartition adds the number of partitions to make it non-negative.
getPartition is part of the Partitioner abstraction.