Skip to content

Commit

Permalink
core/tests now pass
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Apr 8, 2014
1 parent 249abde commit 37888ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions core/src/test/java/org/apache/spark/JavaAPISuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.spark;

import java.io.*;
import java.lang.StringBuilder;
import java.util.*;

import scala.Tuple2;
Expand Down Expand Up @@ -86,6 +87,19 @@ public int iteratorSize(Iterator<?> a) {
return size;
}

public String iteratorStr(Iterator<?> a) {
StringBuilder str = new StringBuilder();
str.append("[");
while (a.hasNext()) {
str.append(a.next().toString());
if (a.hasNext()) {
str.append(", ");
}
}
str.append("]");
return str.toString();
}

@SuppressWarnings("unchecked")
@Test
public void sparkContextUnion() {
Expand Down Expand Up @@ -242,8 +256,8 @@ public void cogroup() {
new Tuple2<String, Integer>("Apples", 3)
));
JavaPairRDD<String, Tuple2<Iterator<String>, Iterator<Integer>>> cogrouped = categories.cogroup(prices);
Assert.assertEquals("[Fruit, Citrus]", cogrouped.lookup("Oranges").get(0)._1().toString());
Assert.assertEquals("[2]", cogrouped.lookup("Oranges").get(0)._2().toString());
Assert.assertEquals("[Fruit, Citrus]", iteratorStr(cogrouped.lookup("Oranges").get(0)._1()));
Assert.assertEquals("[2]", iteratorStr(cogrouped.lookup("Oranges").get(0)._2()));

cogrouped.collect();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
assert(result1.toSet == Set[(Int, Int)]((0, 5), (1, 5)))

// groupByKey
val result2 = rdd.groupByKey().collect()
val result2 = rdd.groupByKey().collect().map(x => (x._1, x._2.toList)).toSet
assert(result2.toSet == Set[(Int, Seq[Int])]
((0, ArrayBuffer[Int](1, 1, 1, 1, 1)), (1, ArrayBuffer[Int](1, 1, 1, 1, 1))))
((0, List[Int](1, 1, 1, 1, 1)), (1, List[Int](1, 1, 1, 1, 1))))
}

test("simple cogroup") {
Expand Down

0 comments on commit 37888ec

Please sign in to comment.