Reduce and grouping transformation with paired key-value RDDs

In this recipe, we explore reduce and group by key. The reduceByKey() and groupbyKey() operations are much more efficient and preferred to reduce() and groupBy() in most cases. The functions provide convenient facilities to aggregate values and combine them by key with less shuffling, which is problematic on large data sets.

Get Apache Spark 2.x Machine Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.