grimbough / Rarr

A simple native R reader for Zarr Arrays
https://bioconductor.org/packages/Rarr/
MIT License
34 stars 5 forks source link

Read/writing string datasets can fail #7

Closed grimbough closed 1 year ago

grimbough commented 1 year ago

Why does this not work?

library(Rarr)
tf <- file.path(tempdir(), "strings.zr")
x <- matrix(LETTERS, ncol = 2)
write_zarr_array(x, tf, chunk_dim = c(5,2), nchar = 1)
read_zarr_array(tf)
#> Error in .format_chunk(decompressed_chunk, metadata, alt_chunk_dim): Decompresed data doesn't match expected chunk size.
grimbough commented 1 year ago

Because writeBin() adds null terminators to the strings, so they are actually of length 2 rather than 1.