Please see The HDF Group's new Support Portal for the latest information.
Contents:
Programming Example (C, Fortran, C++):
Creating an Extendible Dataset
An extendible dataset is one whose dimensions can grow. HDF5 allows you to define a dataset to have certain initial dimensions, then to later increase the size of any of the initial dimensions.
HDF5 requires you to use chunking to define extendible datasets. This makes it possible to extend datasets efficiently without having to excessively reorganize storage. (To use chunking efficiently, be sure to see the advanced topic, Chunking in HDF5.)
The following operations are required in order to extend a dataset:
- Declare the dataspace of the dataset to have unlimited dimensions for all dimensions that might eventually be extended.
- Set dataset creation properties to enable chunking.
- Create the dataset.
- Extend the size of the dataset.
Programming Example
Description
This example shows how to create a 3 x 3 extendible dataset, write to that dataset, extend the dataset to 10x3, and write to the dataset again.-
[C example ]
-
h5_extend.c
[FORTRAN example ] -
h5_extend.f90
[C++ example ] -
h5tutr_extend.cpp
Remarks
-
An unlimited dimension dataspace is specified with the H5Screate_simple / h5screate_simple_f call, by passing in
H5S_UNLIMITED
as an element of the maxdims array. -
The H5Pcreate / h5pcreate_f call creates a new property as an instance of a property list class. For creating an extendible array dataset, pass in H5P_DATASET_CREATE for the property list class.
-
The H5Pset_chunk / h5pset_chunk_f call modifies a Dataset Creation Property List instance to store a chunked layout dataset and sets the size of the chunks used.
-
To extend an unlimited dimension dataset use the the H5Dset_extent / h5dextent_f call.
Please be aware that after this call, the dataset's dataspace must be refreshed with H5Dget_space / h5dget_space_f before more data can be accessed. -
The H5Pget_chunk / h5pget_chunk_f call retrieves the size of chunks for the raw data of a chunked layout dataset.
-
Once there is no longer a need for a Property List instance, it should be closed with the H5Pclose / h5pclose_f call.
- - Last modified: 21 December 2016