-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding 'sink' arg to blockApply() #10
Comments
FYI, this is what I'm currently using, but I'd prefer to retire this for an 'official' solution. It requires (and doesn't check) that the blockApplyWithRealization <- function(x, FUN, ..., grid = NULL, sink = NULL,
BPREDO = list(), BPPARAM = bpparam()) {
FUN <- match.fun(FUN)
grid <- DelayedArray:::.normarg_grid(grid, x)
nblock <- length(grid)
bplapply(seq_len(nblock), function(b) {
if (DelayedArray:::get_verbose_block_processing()) {
message("Processing block ", b, "/", nblock, " ... ",
appendLF = FALSE)
}
viewport <- grid[[b]]
block <- DelayedArray:::extract_block(x, viewport)
if (!is.array(block)) {
block <- DelayedArray:::.as_array_or_matrix(block)
}
attr(block, "from_grid") <- grid
attr(block, "block_id") <- b
block_ans <- FUN(block, ...)
# NOTE: This is the only part different from DelayedArray::blockApply()
if (!is.null(sink)) {
write_block_to_sink(block_ans, sink, viewport)
block_ans <- NULL
}
if (DelayedArray:::get_verbose_block_processing()) {
message("OK")
}
},
BPREDO = BPREDO,
BPPARAM = BPPARAM)
} |
Hi Pete, This one has been patiently sitting in a corner for a while ;-)
Let's try it:
Create HDF5 realization sink:
Block process:
Close sink and coerce:
This is with DelayedArray 0.15.14. The major difference with the Hope this makes sense, H. |
Hi @PeteHaitch , Was never entirely happy with H. |
Thanks, Herve. I'm not currently working on anything that requires this but it's good to have it there. |
Yeah I realize this arrives kind of late. Oh well, maybe at some point when I've nothing else to do I'll replace |
Hi Hervé,
Will
blockApply()
be gaining asink
orBACKEND
argument? This can be convenient whenblockApply()
-ing over a matrix-like object to create a normalised matrix-like object, for example.Thanks!
The text was updated successfully, but these errors were encountered: