HashPartitioner is a Partitioner for hash-based partitioning.
HashPartitioner is used as the default Partitioner.
HashPartitioner takes a number of partitions to be created.
HashPartitioner uses the number of partitions to find the partition ID for a given key (of a key-value record).
getPartition(key: Any): Int
getPartition returns 0 as the partition ID for
null keys, getPartition uses the key’s Object.hashCode modulo the configured number of partitions. For a negative result, getPartition adds the number of partitions (used for the modulo operator) to make it positive.
getPartition is part of the Partitioner abstraction.
equals(other: Any): Boolean
Two HashPartitioners are considered equal when the number of partitions are the same.
hashCode is the number of partitions.