Why does a count query create a ShuffledRowRDD, before MapPartitionsRDD?

Viewed 65

I wrote a simple query in spark: spark.range(1000).filter(id => id % 2 == 0).count(). The DAG for it is this:

enter image description here

Could somebody please explain to me why we start with a ShuffledRowRDD right away? Filter definitely doesn't cause a shuffle, MapParitionsRDD I understand, we count the number of elements for each partition, then we should shuffle at the end by bringing the result from each partition to the driver.

So, why is there no shuffle at the end, but one in the very beginning?

And why is there 2 MapPartitionsRDDs, what does that mean?

0 Answers
Related