Assert.assertEquals(new Tuple2<String, Double>("Hello", 1.0), cartesian.first());
}
@Test
public void javaDoubleRDD() {
JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 1.0, 2.0, 3.0, 5.0, 8.0));
JavaDoubleRDD distinct = rdd.distinct();
Assert.assertEquals(5, distinct.count());
JavaDoubleRDD filter = rdd.filter(new Function<Double, Boolean>() {
@Override
public Boolean call(Double x) {
return x > 2.0;
}
});
Assert.assertEquals(3, filter.count());
JavaDoubleRDD union = rdd.union(rdd);
Assert.assertEquals(12, union.count());
union = union.cache();
Assert.assertEquals(12, union.count());
Assert.assertEquals(20, rdd.sum(), 0.01);
StatCounter stats = rdd.stats();
Assert.assertEquals(20, stats.sum(), 0.01);
Assert.assertEquals(20/6.0, rdd.mean(), 0.01);