Skip to content

Commit 35bcf32

Browse files
committed
Merge pull request apache#930 from holdenk/master
Add mapPartitionsWithIndex (cherry picked from commit c514cd1) Signed-off-by: Reynold Xin <[email protected]>
1 parent 976fe60 commit 35bcf32

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

core/src/main/scala/org/apache/spark/api/java/JavaRDDLike.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable {
6767
def map[R](f: JFunction[T, R]): JavaRDD[R] =
6868
new JavaRDD(rdd.map(f)(f.returnType()))(f.returnType())
6969

70+
/**
71+
* Return a new RDD by applying a function to each partition of this RDD, while tracking the index
72+
* of the original partition.
73+
*/
74+
def mapPartitionsWithIndex[R: ClassManifest](
75+
f: JFunction2[Int, java.util.Iterator[T], java.util.Iterator[R]],
76+
preservesPartitioning: Boolean = false): JavaRDD[R] =
77+
new JavaRDD(rdd.mapPartitionsWithIndex(((a,b) => f(a,asJavaIterator(b))),
78+
preservesPartitioning))
79+
7080
/**
7181
* Return a new RDD by applying a function to all elements of this RDD.
7282
*/

project/SparkBuild.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ object SparkBuild extends Build {
8181
organization := "org.apache.spark",
8282
version := "0.8.1-incubating-SNAPSHOT",
8383
scalaVersion := "2.9.3",
84-
scalacOptions := Seq("-unchecked", "-optimize", "-deprecation",
84+
scalacOptions := Seq("-Xmax-classfile-name", "120", "-unchecked", "-optimize", "-deprecation",
8585
"-target:" + SCALAC_JVM_VERSION),
8686
javacOptions := Seq("-target", JAVAC_JVM_VERSION, "-source", JAVAC_JVM_VERSION),
8787
unmanagedJars in Compile <<= baseDirectory map { base => (base / "lib" ** "*.jar").classpath },

0 commit comments

Comments
 (0)