diff options
author | Holden Karau <holden@pigscanfly.ca> | 2013-10-20 01:17:13 -0700 |
---|---|---|
committer | Holden Karau <holden@pigscanfly.ca> | 2013-10-20 01:17:13 -0700 |
commit | e58c69d955ef8faacb794a0c1666b21c1606453e (patch) | |
tree | e45259f04d5fc2bea7bc118df86153ffeeaada60 | |
parent | 2a37235825cecd3f75286d11456c6e3cb13d4327 (diff) | |
download | spark-e58c69d955ef8faacb794a0c1666b21c1606453e.tar.gz spark-e58c69d955ef8faacb794a0c1666b21c1606453e.tar.bz2 spark-e58c69d955ef8faacb794a0c1666b21c1606453e.zip |
Add tests for the Java implementation.
-rw-r--r-- | core/src/test/scala/org/apache/spark/JavaAPISuite.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/src/test/scala/org/apache/spark/JavaAPISuite.java b/core/src/test/scala/org/apache/spark/JavaAPISuite.java index 591c1d498d..8a9c6e63e0 100644 --- a/core/src/test/scala/org/apache/spark/JavaAPISuite.java +++ b/core/src/test/scala/org/apache/spark/JavaAPISuite.java @@ -365,6 +365,20 @@ public class JavaAPISuite implements Serializable { } @Test + public void javaDoubleRDDHistoGram() { + JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 2.0, 3.0, 4.0)); + // Test using generated buckets + Tuple2<Double[], long[]> results = rdd.histogram(2); + Double[] expected_buckets = {1.0, 2.5, 4.0}; + long[] expected_counts = {2, 2}; + Assert.assertArrayEquals(expected_buckets, results._1); + Assert.assertArrayEquals(expected_counts, results._2); + // Test with provided buckets + long[] histogram = rdd.histogram(expected_buckets); + Assert.assertArrayEquals(expected_counts, histogram); + } + + @Test public void map() { JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 2, 3, 4, 5)); JavaDoubleRDD doubles = rdd.map(new DoubleFunction<Integer>() { |