Skip to contents

The inverse of ic_write_byterefs(), and the "chunk references as a table" view of any Icechunk snapshot. Each array becomes an arrays row (dtype, fill, codec and attributes from its zarr.json); virtual chunks become refs rows with their source path, offset and size; inline and native chunks become rows with a data blob (native chunk bytes are fetched only if native = TRUE). Distinct locations become sources, with etag / mtime from the chunk checksums.

Usage

ic_to_byterefs(session, dsn = NULL, native = TRUE)

Arguments

session

an icechunk_session.

dsn

optional path of a SQLite file to write (requires DBI and RSQLite); it must not exist.

native

fetch native chunk bytes into data (else those rows have present = 1 and no location; a byterefs reader cannot use them).

Value

a byterefs object (invisibly if dsn is given).

Details

What Icechunk does not hold is reconstructed or left empty: source size is NA, and placements are synthesised so the global refs view is the identity (one placement per source, covering its chunks). If the repository was written by ic_write_byterefs(), the root group's byterefs entry restores the meta, the remap rules and the verbatim source paths.

Examples

ex <- ic_example_repo()
s <- ic_session_readonly(ic_repo_open(ex$path, authorize = ex$authorize), branch = "main")
br <- ic_to_byterefs(s)
br$arrays[, c("array", "kind", "storage", "shape", "chunks")]
#>      array kind    storage  shape chunks
#> 1 from_bin data referenced 64, 48 16, 48
#> 2  from_nc data referenced 64, 48 64, 48
#> 3    small data referenced   4, 6   2, 3
br$refs("from_bin")[, c("dim_0", "dim_1", "path", "offset", "size")]
#>   dim_0 dim_1                                                          path
#> 1     0     0 /tmp/RtmpVaRScy/icechunk-example-35c9388c5526/source/grid.bin
#> 2     1     0 /tmp/RtmpVaRScy/icechunk-example-35c9388c5526/source/grid.bin
#> 3     2     0 /tmp/RtmpVaRScy/icechunk-example-35c9388c5526/source/grid.bin
#> 4     3     0 /tmp/RtmpVaRScy/icechunk-example-35c9388c5526/source/grid.bin
#>   offset size
#> 1      0 3072
#> 2   3072 3072
#> 3   6144 3072
#> 4   9216 3072
br$sources
#>   source_id                                                        source size
#> 1         1 /tmp/RtmpVaRScy/icechunk-example-35c9388c5526/source/grid.bin   NA
#> 2         2  /tmp/RtmpVaRScy/icechunk-example-35c9388c5526/source/grid.nc   NA
#>   mtime etag
#> 1    NA <NA>
#> 2    NA <NA>