|
Now we’ll calculate the mean of our dataset.
1 |
|
There are similar methods for other statistics operation such as max, standard deviation, …etc.
Every time one of this method is invoked , Spark performs the operation on the entire RDD data. If more than one operations performed, it will repeat again and again which is very inefficient. To solve this, Spark provides “StatCounter” class which executes once and provides results of all basic statistics operations in the same time.
1 |
|
Now results can be accessed as follows,
1 2 3 4 5 6 7 |
|
摘自:http://www.sparkexpert.com/tag/rdd/