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.

Value

Object of class H5A.

Details

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.

Methods

get_info()

This function implements the HDF5-API function H5Aget_info. Please see the documentation at https://docs.hdfgroup.org/hdf5/develop/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/develop/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/develop/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/develop/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/develop/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/develop/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

flags

Conversion rules for integer values. See also h5const

drop

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/develop/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

robj

The object to write into the attribute

mem_type

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/develop/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/develop/group___h5_f.html for details.

Author

Holger Hoefling

Examples

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]  0.6417311 -0.3901093 -0.9482175  1.0112757 -1.3409406 -0.4102026
#>  [7] -0.4538681  0.3657511  0.3387519 -1.8475720
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()