spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [2/9] git commit: Add tests for the Java implementation.
Date Tue, 26 Nov 2013 08:00:36 GMT
Add tests for the Java implementation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/e58c69d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/e58c69d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/e58c69d9

Branch: refs/heads/master
Commit: e58c69d955ef8faacb794a0c1666b21c1606453e
Parents: 2a37235
Author: Holden Karau <holden@pigscanfly.ca>
Authored: Sun Oct 20 01:17:13 2013 -0700
Committer: Holden Karau <holden@pigscanfly.ca>
Committed: Sun Oct 20 01:17:13 2013 -0700

----------------------------------------------------------------------
 .../src/test/scala/org/apache/spark/JavaAPISuite.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/e58c69d9/core/src/test/scala/org/apache/spark/JavaAPISuite.java
----------------------------------------------------------------------
diff --git a/core/src/test/scala/org/apache/spark/JavaAPISuite.java b/core/src/test/scala/org/apache/spark/JavaAPISuite.java
index 591c1d4..8a9c6e6 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>() {


Mime
View raw message