diff options
Diffstat (limited to 'core/src/main/scala/org/apache/spark/rdd/RDD.scala')
-rw-r--r-- | core/src/main/scala/org/apache/spark/rdd/RDD.scala | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/main/scala/org/apache/spark/rdd/RDD.scala b/core/src/main/scala/org/apache/spark/rdd/RDD.scala index f8283fbbb9..ddb901246d 100644 --- a/core/src/main/scala/org/apache/spark/rdd/RDD.scala +++ b/core/src/main/scala/org/apache/spark/rdd/RDD.scala @@ -957,6 +957,18 @@ abstract class RDD[T: ClassTag]( def takeOrdered(num: Int)(implicit ord: Ordering[T]): Array[T] = top(num)(ord.reverse) /** + * Returns the max of this RDD as defined by the implicit Ordering[T]. + * @return the maximum element of the RDD + * */ + def max()(implicit ord: Ordering[T]):T = this.reduce(ord.max) + + /** + * Returns the min of this RDD as defined by the implicit Ordering[T]. + * @return the minimum element of the RDD + * */ + def min()(implicit ord: Ordering[T]):T = this.reduce(ord.min) + + /** * Save this RDD as a text file, using string representations of elements. */ def saveAsTextFile(path: String) { |