File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
core/src/main/scala/org/apache/spark/rdd Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff 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 */
3044class OrderedRDDFunctions [K : Ordering : ClassTag ,
3145 V : ClassTag ,
You can’t perform that action at this time.
0 commit comments