close.HDF5Matrix

close.HDF5Matrix

OTHER

1 Description

Close an HDF5Matrix object and release file resources immediately. This is the standard R interface for resource cleanup.

2 Usage

close.HDF5Matrix(con, ...)

3 Arguments

Parameter Description
con An object

4 Value

Invisible

5 Details

Closes the HDF5 dataset without waiting for garbage collection. After calling close(), is_valid() returns FALSE and any further operations on the object will fail. The file is immediately accessible by other tools such as HDFView.

Both syntaxes work:

For emergency closure of all open HDF5 objects in the session, see hdf5_close_all.

6 Examples

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

X  <- hdf5_create_matrix(tmp, "data/matrix", data = matrix(rnorm(100), 10, 10))

# Open matrix
X <- hdf5_matrix(tmp, "data/matrix")
data <- X[1:5, 1:5]

# Close using S3 method (recommended)
close(X)

# Or using R6 method (still works)
# X$close()

X$is_valid()  # FALSE

unlink(tmp)
}

7 See Also

hdf5_matrix for opening datasets, hdf5_close_all for closing all open objects