| collect_shard | R Documentation |
Evaluates a delarr pipeline in parallel using shard::shard_map(). This
gives proper multi-process parallelism with shared-memory I/O, including
parallel reductions.
collect_shard(x, workers = NULL, chunk_size = NULL, optimize = TRUE)
x |
A |
workers |
Number of worker processes. Defaults to
|
chunk_size |
Column chunk size for sharding. If |
optimize |
Logical; run DAG optimizations before evaluation. |
Pipelines that require full-matrix evaluation (row-wise center/scale/zscore/
detrend), paired RHS delarrs (d_map2 with two delarrs), or generic
(user-supplied) reductions automatically fall back to sequential collect().
A materialised matrix or vector.
if (requireNamespace("shard", quietly = TRUE)) {
old_conn <- getAllConnections()
mat <- matrix(rnorm(100), 10, 10)
darr <- delarr_shard(mat)
result <- collect_shard(darr |> d_map(~ .x^2), workers = 2)
all.equal(result, mat^2)
new_conn <- setdiff(getAllConnections(), old_conn)
for (con in new_conn) try(close(getConnection(con)), silent = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.