close.HDF5Matrix: Close HDF5Matrix

View source: R/S3_core.R

close.HDF5MatrixR Documentation

Close HDF5Matrix

Description

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

Usage

## S3 method for class 'HDF5Matrix'
close(con, ...)

Arguments

con

An HDF5Matrix object

...

Additional arguments (currently ignored)

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:

  • close(X) - Standard R generic (recommended)

  • X$close() - R6 method (still supported)

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

Value

Invisible NULL

See Also

hdf5_matrix for opening datasets, hdf5_close_all for closing all open objects

Examples


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)



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.