value {SparkR}R Documentation

Broadcast a variable to all workers

Description

value can be used to get the value of a broadcast variable inside a distributed function.

Broadcast a read-only variable to the cluster, returning a Broadcast object for reading it in distributed functions.

Usage

value(bcast)

## S4 method for signature 'Broadcast'
value(bcast)

broadcast(sc, object)

Arguments

bcast

The broadcast variable to get

sc

Spark Context to use

object

Object to be broadcast

Examples

## Not run: 
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, 1:2, 2L)
##D 
##D # Large Matrix object that we want to broadcast
##D randomMat <- matrix(nrow=100, ncol=10, data=rnorm(1000))
##D randomMatBr <- broadcast(sc, randomMat)
##D 
##D # Use the broadcast variable inside the function
##D useBroadcast <- function(x) {
##D   sum(value(randomMatBr) * x)
##D }
##D sumRDD <- lapply(rdd, useBroadcast)
## End(Not run)

[Package SparkR version 0.1 Index]