Skip to content
Snippets Groups Projects
Commit 26c3581f authored by Wieland Hoffmann's avatar Wieland Hoffmann Committed by Sean Owen
Browse files

[DOC] Explicitly state that top maintains the order of elements

Top is implemented in terms of takeOrdered, which already maintains the
order, so top should, too.

Author: Wieland Hoffmann <themineo@gmail.com>

Closes #10013 from mineo/top-order.
parent 953e8e6d
No related branches found
No related tags found
No related merge requests found
...@@ -556,7 +556,7 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable { ...@@ -556,7 +556,7 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable {
/** /**
* Returns the top k (largest) elements from this RDD as defined by * Returns the top k (largest) elements from this RDD as defined by
* the specified Comparator[T]. * the specified Comparator[T] and maintains the order.
* @param num k, the number of top elements to return * @param num k, the number of top elements to return
* @param comp the comparator that defines the order * @param comp the comparator that defines the order
* @return an array of top elements * @return an array of top elements
...@@ -567,7 +567,7 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable { ...@@ -567,7 +567,7 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable {
/** /**
* Returns the top k (largest) elements from this RDD using the * Returns the top k (largest) elements from this RDD using the
* natural ordering for T. * natural ordering for T and maintains the order.
* @param num k, the number of top elements to return * @param num k, the number of top elements to return
* @return an array of top elements * @return an array of top elements
*/ */
......
...@@ -1327,7 +1327,8 @@ abstract class RDD[T: ClassTag]( ...@@ -1327,7 +1327,8 @@ abstract class RDD[T: ClassTag](
/** /**
* Returns the top k (largest) elements from this RDD as defined by the specified * Returns the top k (largest) elements from this RDD as defined by the specified
* implicit Ordering[T]. This does the opposite of [[takeOrdered]]. For example: * implicit Ordering[T] and maintains the ordering. This does the opposite of
* [[takeOrdered]]. For example:
* {{{ * {{{
* sc.parallelize(Seq(10, 4, 2, 12, 3)).top(1) * sc.parallelize(Seq(10, 4, 2, 12, 3)).top(1)
* // returns Array(12) * // returns Array(12)
......
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