hdf5_close_all

hdf5_close_all

HDF5MATRIX_CORE

1 Description

Finds and closes all HDF5Matrix objects in the specified environment.

2 Usage

hdf5_close_all(envir = .GlobalEnv, verbose = TRUE)

3 Arguments

Parameter Description
envir Environment to search (default: .GlobalEnv)
verbose Show details (default: TRUE)

4 Value

Invisible vector of closed filenames

5 Details

This function:

Note: Only finds objects in the specified environment. Objects inside functions or other environments are not affected.

6 Examples

\donttest{
tmp1 <- tempfile(fileext = ".h5")
tmp2 <- tempfile(fileext = ".h5")

X  <- hdf5_create_matrix(tmp1, "data/A", data = matrix(rnorm(100), 10, 10))
Y  <- hdf5_create_matrix(tmp2, "data/B", data = matrix(rnorm(100), 10, 10))

X <- hdf5_matrix(tmp1, "data/A")
Y <- hdf5_matrix(tmp2, "data/B")

# Both open
X$is_valid()  # TRUE
Y$is_valid()  # TRUE

# Close all at once
hdf5_close_all()

# Both closed
X$is_valid()  # FALSE
Y$is_valid()  # FALSE

# Cleanup
unlink(c(tmp1, tmp2))
}