reduceByKeyLocally {SparkR} | R Documentation |
This function operates on RDDs where every element is of the form list(K, V) or c(K, V). and merges the values for each key using an associative reduce function, but return the results immediately to the driver as an R list.
reduceByKeyLocally(rdd, combineFunc) ## S4 method for signature 'RDD' reduceByKeyLocally(rdd, combineFunc)
rdd |
The RDD to reduce by key. Should be an RDD where each element is list(K, V) or c(K, V). |
combineFunc |
The associative reduce function to use. |
A list of elements of type list(K, V') where V' is the merged value for each key
reduceByKey
## Not run:
##D sc <- sparkR.init()
##D pairs <- list(list(1, 2), list(1.1, 3), list(1, 4))
##D rdd <- parallelize(sc, pairs)
##D reduced <- reduceByKeyLocally(rdd, "+")
##D reduced # list(list(1, 6), list(1.1, 3))
## End(Not run)