Learn R Programming

BigDataStatMeth (version 2.0.3)

close.HDF5Matrix: 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 HDF5Matrix
close(con, ...)

Value

Invisible NULL

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.

See Also

hdf5_matrix for opening datasets, hdf5_close_all for closing all open objects

Examples

Run this code
# \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)
# }

Run the code above in your browser using DataLab