Re: Can anyone explain Spark behavior for below? Kudos in Advance

2015-12-27 Thread Jeff Zhang
Not sure what you try to do, but the result is correct.

Scenario 2:

Partition 1 ("12", "23")
("","12") => "0"
("0","23") => "1"

Partition 2 ("","345")
("","") => "0"
("0","345") => "1"

Final merge:
("1","1") => "11"




On Mon, Dec 28, 2015 at 7:14 AM, Prem Spark  wrote:

> Scenario1:
> val z = sc.parallelize(List("12","23","345",""),2)
> z.aggregate("")((x,y) => math.min(x.length, y.length).toString, (x,y) => x
> + y)
> res143: String = 10
>
> Scenario2:
> val z = sc.parallelize(List("12","23","","345"),2)
> z.aggregate("")((x,y) => math.min(x.length, y.length).toString, (x,y) => x
> + y)
> res144: String = 11
>
> why the result is different . I was expecting 10 for both. also for the
> first Partition
>



-- 
Best Regards

Jeff Zhang


Can anyone explain Spark behavior for below? Kudos in Advance

2015-12-27 Thread Prem Spark
Scenario1:
val z = sc.parallelize(List("12","23","345",""),2)
z.aggregate("")((x,y) => math.min(x.length, y.length).toString, (x,y) => x
+ y)
res143: String = 10

Scenario2:
val z = sc.parallelize(List("12","23","","345"),2)
z.aggregate("")((x,y) => math.min(x.length, y.length).toString, (x,y) => x
+ y)
res144: String = 11

why the result is different . I was expecting 10 for both. also for the
first Partition