value {SparkR} | R Documentation |
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.
value(bcast) ## S4 method for signature 'Broadcast' value(bcast) broadcast(sc, object)
bcast |
The broadcast variable to get |
sc |
Spark Context to use |
object |
Object to be broadcast |
## 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)