RangePartitioner is a Partitioner for…​FIXME

RangePartitioner[K : Ordering : ClassTag, V] is a parameterized type of K keys that can be sorted (ordered) and V values.

RangePartitioner is used for sortByKey operator.

Creating Instance

RangePartitioner takes the following to be created:

  • Number of partitions

  • RDD (RDD[_ <: Product2[K, V]])

  • ascending flag (default: true)

  • samplePointsPerPartitionHint (default: 20)

rangeBounds Array

RangePartitioner uses rangeBounds registry (of type Array[K]) when requested for getPartition and hashCode, number of partitions.

Number of Partitions

numPartitions: Int

numPartitions is simply one more than the length of the rangeBounds array.

numPartitions is part of the Partitioner abstraction.

Finding Partition ID for Key

getPartition(key: Any): Int


getPartition is part of the Partitioner abstraction.