- References to Dataset Regions
- Creating and Storing References to Dataset Regions
- Reading References to Dataset Regions
- Programming Example
References to Dataset RegionsPreviously you learned about creating, reading, and writing dataset selections. Here you will learn how to store dataset selections in a file, and how to read them back using references to dataset regions.
A dataset region reference points to the dataset selection by storing the relative file address of the dataset header and the global heap offset of the referenced selection. The selection referenced is located by retrieving the coordinates of the areas in the selection from the global heap. This internal mechanism of storing and retrieving dataset selections is transparent to the user. A reference to a dataset selection (a region) is constant for the life of the dataset.
Creating and Storing References to Dataset RegionsThe following steps are involved in creating and storing references to dataset regions:
- Create a dataset in which to store the dataset regions (the selections).
- Create selections in the dataset(s).
The dataset(s) should already exist in the file.
- Create references to the selections and store them in a buffer.
- Write the dataset region references to the file.
- Close all objects.
Reading References to Dataset RegionsThe following steps are involved in reading references to dataset regions and referenced dataset regions (selections).
- Open and read the dataset containing references to the dataset regions.
H5T_STD_REF_DSETREGmust be used during the read operation.
h5rdeference_fto obtain the dataset identifier from the read dataset region reference.
h5rget_region_fto obtain the dataspace identifier for the dataset containing the selection from the read dataset region reference.
- Obtain information about the selection or read selected data from
- Close all objects when they are no longer needed.
The examples below create a dataset in a file, and write references to regions in the dataset to a dataset of region references. (The regions in the dataset are selected using H5Sselect_hyperslab / h5sselect_hyperslab_f and H5Sselect_elements / h5sselect_elements_f.)
Then it reopens the file, dereferences the references and outputs the referenced regions to the screen.
A dataset region reference dataset can be created by calling H5Dcreate / h5dcreate_f with a a datatype of
The dataspace selections are stored as references in the dataset of region references, using the H5Rcreate / h5rcreate_f call, and passing in
hdset_ref_ref_tfor the reference type.
The dataset with the region references is read by calling H5Dread / h5dread_f with a datatype of
The H5Rdereference / h5rdereference_f opens the dataset, using its reference, and returns the dataset identifier.
H5R_DATASET_REGIONis passed in as the reference type.
The H5Rget_region / h5rget_region_f call obtains the spacial information ( dataspace and selection ) for the region reference.
- - Last modified: 21 December 2016