Main Content

Reference (H5R)

HDF5 references

Description

Use the MATLAB® HDF5 reference interface, H5R, to create and access information about references to HDF5 objects.

Functions

H5R.create

Create reference

ref = H5R.create(locID,objname,reftype,spaceID) creates a reference ref of the type specified in reftype pointing to the object specified by objname and locID.

 Details

H5R.dereference

Open object specified by reference

output = H5R.dereference(dsID,reftype,ref) returns an identifier to the object specified by ref in the dataset specified by dsID. This syntax corresponds to the H5Rdereference interface in version 1.8 of the HDF5 C library.

output = H5R.dereference(dsID,plistID,reftype,ref) returns an identifier to the object specified by ref in the dataset specified by dsID and with additional property list plistID. This syntax corresponds to the H5Rdereference interface in version 1.10 of the HDF5 C library.

 Details

H5R.get_name

Name of referenced object

name = H5R.get_name(locID,reftype,ref) returns the name of the object identified by ref of type reftype located in a dataset or group locID.

name = H5R.get_name(locID,reftype,ref,"TextEncoding",encoding) specifies the text encoding to use to interpret the reference name.

 Details

H5R.get_obj_type

Type of referenced object

objtype = H5R.get_obj_type(locID,reftype,ref) returns the type of object that an object reference points to. This syntax corresponds to the H5Rget_obj_type interface in version 1.8 of the HDF5 C library.

 Details

H5R.get_region

Copy of dataspace of specified region

spaceID = H5R.get_region(fileID,reftype,ref) returns a dataspace with the specified region selected. fileID is used to identify the file containing the referenced region and can be any identifier for any object in the file.

Examples

expand all

Create a double-precision dataset and a reference dataset.

fid = H5F.create("myfile.h5");
type1ID = H5T.copy("H5T_NATIVE_DOUBLE");
dims = [10 5];
h5_dims = fliplr(dims);
h5_maxdims = h5_dims;
space1ID = H5S.create_simple(2,h5_dims,h5_maxdims);
dcpl = "H5P_DEFAULT";
dset1ID = H5D.create(fid,"my_double",type1ID,space1ID,dcpl);
type2ID = "H5T_STD_REF_OBJ";
space2ID = H5S.create("H5S_SCALAR");
dset2ID = H5D.create(fid,"my_ref",type2ID,space2ID,dcpl);
refData = H5R.create(fid,"my_double","H5R_OBJECT",-1);
dxpl = "H5P_DEFAULT";
H5D.write(dset2ID,"H5ML_DEFAULT","H5S_ALL","H5S_ALL",dxpl,refData);
H5D.close(dset2ID);
H5S.close(space2ID);
H5D.close(dset1ID);
H5S.close(space1ID);
H5F.close(fid);

Use the H5R.dereference to return an object identifier using the object reference.

plist = "H5P_DEFAULT";
space = "H5S_ALL";
fid = H5F.open("example.h5");
dsetID = H5D.open(fid,"/g3/reference");
refData = H5D.read(dsetID,"H5T_STD_REF_OBJ",space,space,plist);
derefDsetID = H5R.dereference(dsetID,"H5R_OBJECT",refData(:,1));
H5D.close(derefDsetID);
H5D.close(dsetID);
H5F.close(fid);

Version History

Introduced before R2006a

expand all