Learn R Programming

multidplyr (version 0.0.0.9000)

cluster_call: Call a function on each node of a cluster

Description

`cluster_call()` executes the code on each worker and returns the results; `cluster_send()` executes the code ignoring the result. Jobs are submitted to workers in parallel, and then we wait until they're complete.

Usage

cluster_call(cluster, code, ptype = list())

cluster_send(cluster, code)

Arguments

cluster

A cluster.

code

An expression to execute on each worker.

ptype

Determines the output type. The default returns a list, which will always succeed. Set to a narrower type to simplify the output.

Value

A list of results with one element for each worker in `cluster`.

Examples

Run this code
# NOT RUN {
cl <- default_cluster()

# Run code on each cluster and retrieve results
cluster_call(cl, Sys.getpid())
cluster_call(cl, runif(1))

# use ptype to simplify
cluster_call(cl, runif(1), ptype = double())

# use cluster_send() to ignore results
cluster_send(cl, x <- runif(1))
cluster_call(cl, x, ptype = double())
# }

Run the code above in your browser using DataLab