reduceByKeyLocally

fun <K, V> JavaRDD<Tuple2<K, V>>.reduceByKeyLocally(func: (V, V) -> V): Map<K, V>

Merge the values for each key using an associative and commutative reduce function, but return the results immediately to the master as a Map. This will also perform the merging locally on each mapper before sending results to a reducer, similarly to a "combiner" in MapReduce.