1.  Can be changed

        require(partitions.toSet.diff(rdd.partitions.map(_.index).toSet).isEmpty, "partition index out of range")

2.  Custom Partitioner causing a lot of problems 

   		val partitioner = new Partitioner {
		  override def numPartitions: Int = 2
		  override def getPartition(key: Any): Int = key.hashCode() % 2
		 }

		val pairs = sc.parallelize(Array((1, 2), (3, 4), (5, 6), (-1, 7)))
		val shuffled = pairs.partitionBy(partitioner)
		shuffled.count