June 2017
Beginner to intermediate
296 pages
7h 4m
English
Now this is a very important point with key/value RDDs: if you're not going to actually modify the keys from your transformations on the RDD, make sure you call mapValues() or flatMapValues() instead of just map or flatMap. This is important because it's more efficient; getting a little technical, it allows Spark to maintain the partitioning from your original RDD instead of having to shuffle the data around, which can be very expensive when you're running on a cluster.
So anytime you're calling map or flatMap on a key/value RDD, ask yourself, am I actually modifying the key values? If the answer is no, you should be calling mapValues() instead or flatMapValues().
Just to review again, mapValues will ...
Read now
Unlock full access