Skip to content


RangePartitioner is a Partitioner.

[[ordering]] 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]] Creating Instance

RangePartitioner takes the following to be created:

  • [[partitions]] Number of partitions
  • [[rdd]][RDD] (RDD[_ <: Product2[K, V]])
  • [[ascending]] ascending flag (default: true)
  • [[samplePointsPerPartitionHint]] samplePointsPerPartitionHint (default: 20)

== [[rangeBounds]] rangeBounds Array

RangePartitioner uses rangeBounds registry (of type Array[K]) when requested for <> and <>, <>.

== [[numPartitions]] Number of Partitions


numPartitions: Int

numPartitions is simply one more than the length of the <> array.

numPartitions is part of the[Partitioner] abstraction.

== [[getPartition]] Finding Partition ID for Key

[source, scala]

getPartition(key: Any): Int


getPartition is part of the[Partitioner] abstraction.

Last update: 2020-10-14