Skip to contents

Plans every array, fetches all the plans with one zaro_fetch() (so HTTP chunks of all the arrays share one connection pool and go out concurrently, and touching byte ranges merge), then decodes each array. Each result is what zaro_read(store, path) returns. Useful for reading a dataset's coordinate arrays at open, where each array is small and the cost is the round trips.

Usage

zaro_read_arrays(store, paths, metas = NULL, verbose = zaro_verbose())

Arguments

store

a store from zaro(), or a zaro_dataset() (then paths are array names in the dataset).

paths

character vector of array paths (or dataset names).

metas

optional list of array metadata, one per path (taken from the dataset when store is one, else read).

verbose

logical. Emit diagnostic messages. Default getOption("zaro.verbose", TRUE).

Value

A named list of arrays, one per path, each with dim in Zarr order as from zaro_read(). Fetch statistics are in attr(, "stats").

Examples

f <- system.file("extdata", "example.zarr", package = "zaro")
ds <- zaro_dataset(f)
#> [zaro] opening local store: /usr/local/lib/R/site-library/zaro/extdata/example.zarr
#> [zaro] found zarr.json at root (Zarr V3)
#> [zaro] reading consolidated metadata (6 entries)
xy <- zaro_read_arrays(ds, c("lon", "lat", "time"))
#> [zaro] read 3 array(s), 3 chunk(s) in 0 HTTP request(s)
lengths(xy)
#>  lon  lat time 
#>   16    8    3 
attr(xy, "stats")$requests   # 0 for a local store, one pool for HTTP
#> [1] 0