delarr_hdf5: Create a delayed array sourced from an HDF5 dataset

View source: R/delarr-backends.R

delarr_hdf5R Documentation

Create a delayed array sourced from an HDF5 dataset

Description

Uses hdf5r to lazily read slices from disk on demand.

Usage

delarr_hdf5(path, dataset)

Arguments

path

Path to the HDF5 file.

dataset

Name of the dataset within the file.

Value

A delarr that streams data from the HDF5 dataset.

Examples

if (requireNamespace("hdf5r", quietly = TRUE)) {
  # Create a temporary HDF5 file
  tf <- tempfile(fileext = ".h5")
  data <- matrix(1:20, nrow = 4, ncol = 5)

  # Write test data
  f <- hdf5r::H5File$new(tf, mode = "w")
  f$create_dataset("X", robj = data)
  f$close_all()

  # Load as delayed array
  darr <- delarr_hdf5(tf, "X")
  darr

  # Apply operations and collect
  result <- darr |> d_map(~ .x * 2) |> collect()
  result

  # Clean up
  unlink(tf)
}

delarr documentation built on July 1, 2026, 1:06 a.m.