January 2019
Beginner to intermediate
154 pages
4h 31m
English
The collect() action returns all the elements of an RDD to the driver program. You should only use collect() if you are sure about the size of your final output. If the size of the final output is huge, then your driver program might crash while receiving the data from the executors. The use of collect() is not advised in production. The following example collects all the elements of an RDD containing numbers from 0 to 9:
#Pythonspark.sparkContext.parallelize(range(10)).collect()Out[26]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Read now
Unlock full access