@@ -13,9 +13,9 @@ object reduceExample extends App {
13
13
14
14
val listRdd = spark.sparkContext.parallelize(List (1 ,2 ,3 ,4 ,5 ,3 ,2 ))
15
15
16
- println(" output sum using binary : " + listRdd.reduce(_ min _))
17
- println(" output min using binary : " + listRdd.reduce(_ max _))
18
- println(" output max using binary : " + listRdd.reduce(_ + _))
16
+ println(" output min using binary : " + listRdd.reduce(_ min _))
17
+ println(" output max using binary : " + listRdd.reduce(_ max _))
18
+ println(" output sum using binary : " + listRdd.reduce(_ + _))
19
19
20
20
21
21
// Alternatively you can write
@@ -27,7 +27,7 @@ object reduceExample extends App {
27
27
val inputRDD = spark.sparkContext.parallelize(List ((" Z" , 1 ),(" A" , 20 ),(" B" , 30 ),
28
28
(" C" , 40 ),(" B" , 30 ),(" B" , 60 )))
29
29
30
- println(" output max : " + inputRDD.reduce( (a,b)=> (" max" ,a._2 min b._2))._2)
30
+ println(" output min : " + inputRDD.reduce( (a,b)=> (" max" ,a._2 min b._2))._2)
31
31
println(" output max : " + inputRDD.reduce( (a,b)=> (" max" ,a._2 max b._2))._2)
32
32
println(" output sum : " + inputRDD.reduce( (a,b)=> (" Sum" ,a._2 + b._2))._2)
33
33
}
0 commit comments