h5::create(fd, path, max_dims, chunk_dims, deflate );

Detailed Description

fd - file descriptor, path - how you reach dataset within file, max_dims – tells the size of dataset, the value H5S_UNLIMITED marks given dimension extendable, chunk_dims tells the size of elementary IO operations if specified the rank of max_dims and chunk_dims must match. Empty set:{} indicates no-chunked operations. And finally deflate controls the level of GZIP compression.

Function Documentation

template<typename T >
hid_t h5::create ( hid_t  fd,
const std::string &  path,
std::initializer_list< hsize_t >  max_dims,
std::initializer_list< hsize_t >  chunk_dims = {0},
const int32_t  deflate = 0 
)
inline

T template parameter defines the underlying representation of dataset created within HDF5 filesystem referenced by fd descriptor. path behaves much similar to POSIX files system path: either relative or absolute. HDF5 supports arbitrary number of dimensions which is specified by max_dim, and chunk_size controls how this array is accessed. When chunked access is used keep in mind small values may result in excessive data cache operations.
This function is general, ca

TODO: provide mechanism to specify attributes, filters, ...

Parameters
fdopened HDF5 file descripor
pathfull path where the newly created object will be placed
max_dimssize of the object, H5S_UNLIMITED to mark extendable dimension
chunk_dimsfor better performance data sets maybe stored in chunks, which is a unit size for IO operations. Streaming, and filters may be applied only on chunked datasets.
deflate0-9 controls GZIP compression.
Template Parameters
T[unsigned](int8_t|int16_t|int32_t|int64_t) | (float|double)
Returns
opened dataset descriptor of hid_t, that must be closed with H5Dclose
example:
hid_t ds = create<double>(fd, "matrix/double type",{100,10},{1,10}, 9);
hid_t ds = create<short>(fd, "array/short",{100,10,10});
hid_t ds = create<float>(fd, "stream",{H5S_UNLIMITED},{10}, 9);
hid_t ds = h5::create<float>(fd,"stl/partial",{100,vf.size()},{1,10}, 9);
h5::write(ds, vf, {2,0},{1,10} );
auto rvo = h5::read< std::vector<float>>(ds);
H5Dclose(ds);
See also
open close gzip H5Fcreate H5Fopen H5Fclose H5Dopen H5Dclose
Examples:
arma-partial.cpp, arma-perf.cpp, arma.cpp, blaze.cpp, blitz.cpp, dlib.cpp, eigen3.cpp, itpp.cpp, raw.cpp, stl-perf.cpp, stl.cpp, string.cpp, struct-perf.cpp, struct.cpp, and ublas.cpp.
template<typename T , typename BaseType = typename utils::base<T>::type, size_t Rank = utils::base<T>::rank>
hid_t h5::create ( hid_t  fd,
const std::string &  path,
const T &  ref 
)
inline

create dataset within HDF5 file space with dimensions extracted from references object

Parameters
fdopened HDF5 file descripor
pathfull path where the newly created object will be placed
refstl|arma|eigen valid templated object with dimensions
Template Parameters
T[unsigned](int8_t|int16_t|int32_t|int64_t)| (float|double)
Returns
opened dataset descriptor of hid_t, that must be closed with H5Dclose
example:
#include <hdf5.h>
#include <armadillo>
#include <h5cpp/all>
int main(){
hid_t fd = h5::create("some_file.h5"); // create file
arma::mat M(100,10); // define object
hid_t ds = h5::create(fd,"matrix",M); // create dataset from object
H5Dclose(ds); // close dataset
h5::close(fd); // and file descriptor
}
See also
open close gzip H5Fcreate H5Fopen H5Fclose H5Dopen H5Dclose