Skip to content

Commit

Permalink
Make mapPartitionsWithIndex work with JavaRDD's
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Sep 14, 2013
1 parent 74f710f commit bfcddf4
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -71,9 +71,10 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable {
* Return a new RDD by applying a function to each partition of this RDD, while tracking the index
* of the original partition.
*/
def mapPartitionsWithIndex(f: JFunction2[Int, T, R],
def mapPartitionsWithIndex[R: ClassManifest](f: JFunction2[Int, java.util.Iterator[T], java.util.Iterator[R]],
preservesPartitioning: Boolean = false): JavaRDD[R] =
new JavaRDD(MapPartitionsWithIndexRDD(this, sc.clean(f), preservesPartitioning))
new JavaRDD(rdd.mapPartitionsWithIndex(((a,b) => f(a,asJavaIterator(b))),
preservesPartitioning))

/**
* Return a new RDD by applying a function to all elements of this RDD.
Expand Down

0 comments on commit bfcddf4

Please sign in to comment.