Skip to content
Snippets Groups Projects
Commit e85af507 authored by Binh Nguyen's avatar Binh Nguyen
Browse files

Leave default value of numPartitions to Scala code.

parent c82d4f07
No related branches found
No related tags found
No related merge requests found
......@@ -584,7 +584,9 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])(implicit val kManifest: ClassManif
* order of the keys).
*/
def sortByKey(comp: Comparator[K], ascending: Boolean): JavaPairRDD[K, V] = {
sortByKey(comp, ascending, rdd.partitions.size)
// numPartitions should never be negative in practice so we can use -1 here to indicate that
// we want to use implementation's default value.
sortByKey(comp, ascending, -1)
}
/**
......@@ -598,7 +600,11 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])(implicit val kManifest: ClassManif
override def compare(b: K) = comp.compare(a, b)
}
implicit def toOrdered(x: K): Ordered[K] = new KeyOrdering(x)
fromRDD(new OrderedRDDFunctions[K, V, (K, V)](rdd).sortByKey(ascending, numPartitions))
if (numPartitions < 0) {
fromRDD(new OrderedRDDFunctions[K, V, (K, V)](rdd).sortByKey(ascending))
} else {
fromRDD(new OrderedRDDFunctions[K, V, (K, V)](rdd).sortByKey(ascending, numPartitions))
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment