Hi all,

Thanks for your suggestions.  I'm still missing something, though.  Using
the h5group.cpp example, I can get my code to create a chunked dataset, but
I can't write anything to it.

            std::string dataset_name = function_that_returns_name();
            std::string dataset_value = function_that_returns_value();

            // Is the size the size of the buffer, or the length of the
string? (should I include the null-terminator?)
            hsize_t dataset_length = dataset_value.length() + 1;
            StrType datatype(0, dataset_length);
            hsize_t sdims[1];
            sdims[0] = dataset_length;
            DataSpace dataspace(1, sdims);

            DSetCreatPropList plist;
            hsize_t chunk_dims[1];
            chunk_dims[0] = 24;
            plist.setChunk(1, chunk_dims);

            DataSet sim_details = group.createDataSet(dataset_name,
datatype, dataspace, plist);

            // This raises a bad pointer exception.
            sim_details.write(dataset_value, datatype);


  #009: H5FDsec2.c line 846 in H5FD_sec2_write(): file write failed: time =
Tue Dec 11 16:59:46 2012
, filename = 'test.h5', file descriptor = 3, errno = 14, error message =
'Bad address', buf = 0x7f9be0b5a1f8, size = 4115328, offset = 184320
    major: Low-level I/O
    minor: Write failed
terminate called after throwing an instance of 'H5::DataSetIException'

Nathan


On Tue, Dec 11, 2012 at 4:26 PM, Peter Cao <[email protected]> wrote:

>  for fixed langth, just replace the H5T_VARIABLE with the length you want
> to set.
>
>
> On 12/11/2012 12:32 PM, Nathan Smith wrote:
>
> I know the length of the string a priori.  Can you point me to an example
> of writing out a fixed length string that uses compression?
>
>  Thanks!
>
>  Nathan
>
>  On Tue, Dec 11, 2012 at 12:29 PM, Dana Robinson <[email protected]>wrote:
>
>> Hi Nathan,
>>
>>  On Tue, Dec 11, 2012 at 11:20 AM, Nathan Smith 
>> <[email protected]>wrote:
>>
>>> 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.
>>>
>>
>>  Variable-length data cannot be compressed due to the way we store it in
>> the HDF5 library.
>>
>>  Dana
>>
>> _______________________________________________
>> Hdf-forum is for HDF software users discussion.
>> [email protected]
>> http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
>>
>>
>
>
> _______________________________________________
> Hdf-forum is for HDF software users 
> [email protected]http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
>
>
>
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> [email protected]
> http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
>
>
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to