Hello all,
A couple questions (using hdf5 1.8.4 on linux with g++).
First, I'm wondering if you can create a
unlimited array of strings. I've modified the hdf5 example codes to
generate a file which contains something like:
ATTRIBUTE "A1" {
DATATYPE H5T_STRING {
STRSIZE 7;
STRPAD H5T_STR_SPACEPAD;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
DATASPACE SIMPLE { ( 4 ) / ( H5S_UNLIMITED ) }
DATA {
(0): "Parting", "is such", "sweet ", "sorrow."
}
}
However, this isn't exactly what I want, since the datatype
specifically specifies 7-character strings, and I'd prefer that
neither the length of the string array nor the length of any
individual string was limited. I have a feeling that the answer
to my question is that trying to store an unlimited array of
unlimited length strings is a bad
idea, because one would have to enable chunking for each
element in the string array separately, which would be pretty
wasteful in terms of hdf file storage and access. Let me know
if this suspicion is correct.
Additionally, I'd like to work with unlimited length attributes.
I've successfully created an unlimited length attribute with
something of the form:
// Create the attribute space
hsize_t adims=s.size();
hsize_t amax=H5S_UNLIMITED;
hid_t attr_space=H5Screate_simple(1,&adims,&amax);
// Set attribute chunk with size determined by def_chunk()
hid_t dcpl2=H5Pcreate(H5P_DATASET_CREATE);
hsize_t chunk2=def_chunk(s.size());
int status3=H5Pset_chunk(dcpl2,1,&chunk2);
// Create the attribute
hid_t attr=H5Acreate(dset,"len",H5T_STD_I8LE,attr_space,H5P_DEFAULT,dcpl2);
then, in order to read the attribute later, I can do
// Get attribute dimensions
attr_space=H5Aget_space(attr);
hsize_t adims;
int nadims=H5Sget_simple_extent_dims(attr_space,&adims,0);
One question is that this looks a little unusual to me, as I was
initially thinking that I'd need to use a function named
H5Aget_simple_extent_dims(), but no such function exists. Maybe this
is still ok. However, I'm having trouble resizing the attribute after the
fact. I've tried
hsize_t new_adims=s.size();
int status3=H5Dset_extent(attr,&new_adims);
but this gives me an error:
HDF5-DIAG: Error detected in HDF5 (1.8.4) thread 0:
#000: H5D.c line 1077 in H5Dset_extent(): not a dataset
major: Invalid arguments to routine
minor: Inappropriate type
I've tried using H5Aset_extent(), but no function exists with that
name. So the final question is what I'm doing wrong with
set_extent().
Thank you,
Andrew