Skip to content

Commit

Permalink
fold added
Browse files Browse the repository at this point in the history
  • Loading branch information
oleewere committed Oct 22, 2014
1 parent b397751 commit 3359803
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ class RDDOperationsTest {
Assert.assertEquals(output, expectedOutput)
}

@Test
def testFold() {
val input = Seq(1, 2, 3, 4)
val expectedOutput = 10

val output = sc.makeRDD(input).fold(0)((n,m) => n + m)

Assert.assertEquals(output, expectedOutput)
}

@Test
def testGroupBy() {
val input = Seq((1, 1), (1, 2), (1, 3), (2, 4))
Expand Down Expand Up @@ -386,7 +396,7 @@ class RDDOperationsTest {
val input = Seq((1, 2), (1, 3), (2, 4))
val expectedOutput = Array((1,7), (2, 6))

val output = sc.makeRDD(input).foldByKey(2)(_ + _)
val output = sc.makeRDD(input).foldByKey(0)(_ + _)

Assert.assertEquals(output.collect(), expectedOutput)
}
Expand Down

0 comments on commit 3359803

Please sign in to comment.