Skip to content

Commit 1b9b85c

Browse files
committed
Update scala doc.
1 parent 35798a8 commit 1b9b85c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

core/src/main/scala/org/apache/spark/rdd/OrderedRDDFunctions.scala

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,22 @@ import org.apache.spark.{Logging, RangePartitioner}
2424
/**
2525
* Extra functions available on RDDs of (key, value) pairs where the key is sortable through
2626
* an implicit conversion. Import `org.apache.spark.SparkContext._` at the top of your program to
27-
* use these functions. They will work with any key type that has a `scala.math.Ordered`
28-
* implementation.
27+
* use these functions. They will work with any key type `K` that has an implicit `Ordering[K]` in
28+
* scope. Ordering objects already exist for all of the standard primitive types. Users can also
29+
* define their own orderings for custom types, or to override the default ordering. The implicit
30+
* ordering that is in the closest scope will be used.
31+
*
32+
* {{{
33+
* import org.apache.spark.SparkContext._
34+
*
35+
* val rdd: RDD[(String, Int)] = ...
36+
* implicit val caseInsensitiveOrdering = new Ordering[String] {
37+
* override def compare(a: String, b: String) = a.toLowerCase.compare(b.toLowerCase)
38+
* }
39+
*
40+
* // Sort by key, using the above case insensitive ordering.
41+
* rdd.sortByKey
42+
* }}}
2943
*/
3044
class OrderedRDDFunctions[K : Ordering : ClassTag,
3145
V: ClassTag,

0 commit comments

Comments
 (0)