Merge branch 'master' of github.com:mesos/spark
This commit is contained in:
commit
1941d9602d
|
@ -615,6 +615,16 @@ class PairRDDFunctions[K: ClassManifest, V: ClassManifest](
|
|||
writer.cleanup()
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an RDD with the keys of each tuple.
|
||||
*/
|
||||
def keys: RDD[K] = self.map(_._1)
|
||||
|
||||
/**
|
||||
* Return an RDD with the values of each tuple.
|
||||
*/
|
||||
def values: RDD[V] = self.map(_._2)
|
||||
|
||||
private[spark] def getKeyClass() = implicitly[ClassManifest[K]].erasure
|
||||
|
||||
private[spark] def getValueClass() = implicitly[ClassManifest[V]].erasure
|
||||
|
|
|
@ -216,6 +216,13 @@ class ShuffleSuite extends FunSuite with ShouldMatchers with BeforeAndAfter {
|
|||
// Test that a shuffle on the file works, because this used to be a bug
|
||||
assert(file.map(line => (line, 1)).reduceByKey(_ + _).collect().toList === Nil)
|
||||
}
|
||||
|
||||
test("keys and values") {
|
||||
sc = new SparkContext("local", "test")
|
||||
val rdd = sc.parallelize(Array((1, "a"), (2, "b")))
|
||||
assert(rdd.keys.collect().toList === List(1, 2))
|
||||
assert(rdd.values.collect().toList === List("a", "b"))
|
||||
}
|
||||
}
|
||||
|
||||
object ShuffleSuite {
|
||||
|
|
Loading…
Reference in a new issue