Bioconductor / HDF5Array

HDF5 backend for DelayedArray objects
https://bioconductor.org/packages/HDF5Array
9 stars 13 forks source link

Is it possible to connect to a HDF5 file in a read-only manner? #14

Closed phaverty closed 5 years ago

hpages commented 5 years ago

The low-level function for opening a connection to an HDF5 file is H5Fopen() and is defined in the rhdf5 package. By default, it opens a read/write connection but you can change this by specifying "H5F_ACC_RDONLY" via the flags argument:

fid <- H5Fopen("path/to/file.h5", flags="H5F_ACC_RDONLY")
...
H5Fclose(fid)

The man page for rhdf5::H5Fopen doesn't provide much details but the corresponding C function in the HDF5 C library is documented here and provides more details.

Note that HDF5Array objects, and on-disk DelayedArray objects in general, provide a read-only semantic i.e. they never touch the files/datasets they are pointing at. Furthermore, they are not "connected" to these files in the sense that they don't store open connections to them. Instead they open a new connection each time they need to read data from disk (there are good reasons for choosing this approach). They do this by calling rhdf5::h5read() or HDF5Array::h5mread() which take care of opening/closing the connection each time they are called.

hpages commented 5 years ago

I'm closing this.

@phaverty: feel free to re-open if you want to further discuss this. Thanks!