collectAsMap

fun <K, V> JavaRDD<Tuple2<K, V>>.collectAsMap(): Map<K, V>

Return the key-value pairs in this RDD to the master as a Map.

Warning: this doesn't return a multimap (so if you have multiple values to the same key, only one value per key is preserved in the map returned)

Note: this method should only be used if the resulting data is expected to be small, as all the data is loaded into the driver's memory.