This class represents an HDF5 attribute. Usually it is easier to read and write attributes for
groups, datasets and committed datatypes using the functions documented in h5attributes
.
Object of class H5A
.
Otherwise, the functionality for attributes is very similar to that of datasets (H5D
),
however with the notable exception that attributes always have to be read and written as a whole.
get_info()
This function implements the HDF5-API function H5Aget_info. Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_a.html for details.
attr_name()
This function implements the HDF5-API function H5Aget_name. Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_a.html for details.
get_space()
This function implements the HDF5-API function H5Aget_space. Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_a.html for details.
get_type(native = TRUE)
This function implements the HDF5-API function H5Aget_type. Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_a.html for details.
get_storage_size()
This function implements the HDF5-API function H5Aget_storage_size. Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_a.html for details.
read_low_level(buffer, mem_type, duplicate_buffer = FALSE)
Only for advanced users. See documentation for read
instead.
This function implements the HDF5-API function H5Aread.
Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_a.html for details.
read(flags = getOption("hdf5r.h5tor_default"), drop = TRUE)
Reads the data of the attribute and returns it as an R-object
Parameters
Conversion rules for integer values. See also h5const
Logical. Should dimensions of length 1 be dropped (R-default for arrays)
write_low_level(buffer, mem_type)
Only for advanced users. See documentation for write
instead.
This function implements the HDF5-API function H5Awrite.
Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_a.html for details.
write(robj, mem_type = NULL,
flush = getOption("hdf5r.flush_on_write"))
Writes the data of robj
to the attribute
Parameters
The object to write into the attribute
The memory data type to use when transferring from HDF5 to intermediate storage. This is an advanced development feature and may be removed in the future.
print(...)
Prints information for the dataset
Parameters
ignored
flush(scope = h5const$H5F_SCOPE_GLOBAL)
This function implements the HDF5-API function H5Fflush. Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_f.html for details.
get_filename()
This function implements the HDF5-API function H5Fget_name. Please see the documentation at https://docs.hdfgroup.org/hdf5/v1_10/group___h5_f.html for details.
fname <- tempfile(fileext = ".h5")
file <- H5File$new(fname, mode = "a")
h5attr(file, "attr_numeric") <- rnorm(10)
a <- file$attr_open("attr_numeric")
a$get_info()
#> corder_valid corder cset data_size
#> 1 0 0 0 80
a$attr_name()
#> [1] "attr_numeric"
a$get_space()
#> Class: H5S
#> Type: Simple
#> Dims: 10
#> Maxdims: 10
a$get_type()
#> Class: H5T_FLOAT
#> Datatype: H5T_IEEE_F64LE
a$get_storage_size()
#> [1] 80
a$read()
#> [1] -1.400043517 0.255317055 -2.437263611 -0.005571287 0.621552721
#> [6] 1.148411606 -1.821817661 -0.247325302 -0.244199607 -0.282705449
a$write(10:1)
a$print()
#> Class: H5A
#> Attribute: attr_numeric
#> Datatype: H5T_IEEE_F64LE
#> Space: Type=Simple Dims=10 Maxdims=10
a$close()
file$close_all()