reduceByKeyLocally {SparkR}R Documentation

Merge values by key locally

Description

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.

Usage

reduceByKeyLocally(rdd, combineFunc)

## S4 method for signature 'RDD'
reduceByKeyLocally(rdd, combineFunc)

Arguments

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.

Value

A list of elements of type list(K, V') where V' is the merged value for each key

See Also

reduceByKey

Examples

## 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)

[Package SparkR version 0.1 Index]