Write virtual chunk references
Usage
ic_set_virtual_ref(
session,
key,
location,
offset,
length,
etag = NULL,
last_modified = NULL,
validate = TRUE
)
ic_set_virtual_refs(session, path, refs, validate = TRUE)Arguments
- session
a writable
icechunk_session.- key
Zarr chunk key.
- location
URL of the object holding the bytes.
- offset, length
byte range in that object.
- etag, last_modified
optional checksum: reads fail if the object has changed.
- validate
check the location falls within a declared container.
- path
array path.
- refs
data frame of 0-based chunk indices and byte ranges. Indices are either
dim_0, dim_1, ...integer columns (the byterefs layout) or acoordcolumn (list of integer vectors, or comma-separated strings). Byte ranges arelocation(orpath),offsetandlength(orsize). Optionaletagandlast_modified(POSIXct or seconds) set a per-chunk checksum; etag wins when both are present.
Examples
ex <- ic_example_repo()
repo <- ic_repo_open(ex$path, authorize = ex$authorize)
s <- ic_session_writable(repo, "main")
grid <- paste0(ex$authorize, "grid.bin")
# point from_bin's last chunk at the first block of grid.bin instead
ic_set_virtual_ref(s, "from_bin/c/3/0", grid, offset = 0, length = 3072)
# or many at once, one row per chunk (dim_* are chunk indices)
ic_set_virtual_refs(s, "/from_bin", data.frame(
dim_0 = 0:1, dim_1 = 0L, location = grid, offset = c(3072, 0), length = 3072))
ic_chunk_refs(s, "/from_bin")[, c("coord", "offset")]
#> coord offset
#> 1 0,0 3072
#> 2 1,0 0
#> 3 3,0 0
#> 4 2,0 6144
ic_commit(s, "rearranged from_bin")
#> [1] "BD13VC30R96DTB56M9CG"