Skip to contents

Creates the repository with one virtual chunk container per source prefix (ic_byterefs_containers()), authorises them, writes the store with ic_write_byterefs() and commits.

Usage

ic_repo_from_byterefs(
  br,
  storage,
  target = NULL,
  message = NULL,
  authorize = NULL,
  manifest_split = NULL,
  ...
)

Arguments

br

a byterefs store (see ic_byterefs_read()).

storage

an ic_storage object, or a local path, for the new repository.

target

remap target.

message

commit message.

authorize

credentials for the containers; default inferred from each prefix's scheme (see ic_repo_open()).

manifest_split

manifest splitting, see ic_repo_create(); e.g. c(time = 1) for a daily series, so a day's refs are one manifest.

...

passed to ic_write_byterefs().

Value

the icechunk_repo (invisibly), with attributes snapshot and summary.

Examples

ex <- ic_example_repo()
s <- ic_session_readonly(ic_repo_open(ex$path, authorize = ex$authorize), branch = "main")
br <- ic_to_byterefs(s)

# a new repository from the references: same chunks, same bytes
dst <- tempfile("copy-")
repo2 <- ic_repo_from_byterefs(br, dst, authorize = ex$authorize, message = "a copy")
s2 <- ic_session_readonly(repo2, branch = "main")
identical(ic_get(s2, "from_bin/c/2/0"), ic_get(s, "from_bin/c/2/0"))
#> [1] TRUE
ic_byterefs_compare(br, ic_to_byterefs(s2))
#>       array          check   ok      detail
#> 1         *    array names TRUE            
#> 2  from_bin           kind TRUE   data data
#> 3  from_bin          dtype TRUE     <f4 <f4
#> 4  from_bin           dims TRUE            
#> 5  from_bin          shape TRUE            
#> 6  from_bin         chunks TRUE            
#> 7  from_bin           fill TRUE     NaN NaN
#> 8  from_bin          codec TRUE null | null
#> 9  from_bin          attrs TRUE            
#> 10 from_bin present chunks TRUE      4 vs 4
#> 11 from_bin      locations TRUE    0 differ
#> 12 from_bin        offsets TRUE            
#> 13 from_bin          sizes TRUE            
#> 14 from_bin    inline data TRUE            
#> 15  from_nc           kind TRUE   data data
#> 16  from_nc          dtype TRUE     <f4 <f4
#> 17  from_nc           dims TRUE            
#> 18  from_nc          shape TRUE            
#> 19  from_nc         chunks TRUE            
#> 20  from_nc           fill TRUE     NaN NaN
#> 21  from_nc          codec TRUE null | null
#> 22  from_nc          attrs TRUE            
#> 23  from_nc present chunks TRUE      1 vs 1
#> 24  from_nc      locations TRUE    0 differ
#> 25  from_nc        offsets TRUE            
#> 26  from_nc          sizes TRUE            
#> 27  from_nc    inline data TRUE            
#> 28    small           kind TRUE   data data
#> 29    small          dtype TRUE     <f8 <f8
#> 30    small           dims TRUE            
#> 31    small          shape TRUE            
#> 32    small         chunks TRUE            
#> 33    small           fill TRUE         0 0
#> 34    small          codec TRUE null | null
#> 35    small          attrs TRUE            
#> 36    small present chunks TRUE      4 vs 4
#> 37    small      locations TRUE    0 differ
#> 38    small        offsets TRUE            
#> 39    small          sizes TRUE            
#> 40    small    inline data TRUE            

# with one manifest per chunk row of dimension 0
dst3 <- tempfile("split-")
ic_repo_from_byterefs(br, dst3, authorize = ex$authorize, manifest_split = c("0" = 1))
length(list.files(file.path(dst3, "manifests")))
#> [1] 7