Hi all,
I'm very new to HDF5 and am trying to find an example of how to compress a
string written to an HDF5 file. I've been using the C++ API and writing
scalar strings to my dataset, but I can't figure out how to use data
chunking so that I can enable compression. I tried to adapt the example
provided for Java
(http://www.hdfgroup.org/hdf-java-html/javadocs/ncsa/hdf/object/h5/H5ScalarDS.html#create(java.lang.String,
ncsa.hdf.object.Group, ncsa.hdf.object.Datatype, long[], long[], long[],
int, java.lang.Object):
std::string my_string = function_that_populates_string();
std::string dataset_name = function_that_names_dataset();
StrType datatype(0, H5T_VARIABLE);
DataSpace dataspace(H5S_SCALAR);
DSetCreatPropList plist;
hsize_t chunk_dims[1] = {1024};
plist.setChunk(1, chunk_dims);
DataSet dataset = my_group.createDataSet(dataset_name, datatype,
dataspace, plist);
dataset.write(my_string, datatype);
but it throws errors at runtime:
HDF5-DIAG: Error detected in HDF5 (1.8.6) thread 0:
#000: H5D.c line 170 in H5Dcreate2(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#001: H5Dint.c line 431 in H5D_create_named(): unable to create and link
to dataset
major: Dataset
minor: Unable to initialize object
#002: H5L.c line 1640 in H5L_link_object(): unable to create new link to
object
major: Links
minor: Unable to initialize object
#003: H5L.c line 1866 in H5L_create_real(): can't insert link
major: Symbol table
minor: Unable to insert object
#004: H5Gtraverse.c line 929 in H5G_traverse(): internal path traversal
failed
major: Symbol table
minor: Object not found
#005: H5Gtraverse.c line 718 in H5G_traverse_real(): traversal operator
failed
major: Symbol table
minor: Callback failed
#006: H5L.c line 1686 in H5L_link_cb(): unable to create object
major: Object header
minor: Unable to initialize object
#007: H5O.c line 3005 in H5O_obj_create(): unable to open object
major: Object header
minor: Can't open object
#008: H5Doh.c line 295 in H5O_dset_create(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#009: H5Dint.c line 1035 in H5D_create(): unable to construct layout
information
major: Dataset
If I get rid of the provided plist (and hence the chunking), then the code
works without problem. Can anyone point me in the right direction?
Thanks!
Nathan