fold {SparkR}R Documentation

Fold an RDD using a given associative function and a neutral "zero value".

Description

Aggregate the elements of each partition, and then the results for all the partitions, using a given associative function and a neutral "zero value".

Usage

fold(rdd, zeroValue, op)

## S4 method for signature 'RDD'
fold(rdd, zeroValue, op)

Arguments

rdd

An RDD.

zeroValue

A neutral "zero value".

op

An associative function for the folding operation.

Value

The folding result.

See Also

reduce

Examples

## Not run: 
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, list(1, 2, 3, 4, 5))
##D fold(rdd, 0, "+") # 15
## End(Not run)

[Package SparkR version 0.1 Index]