I am reading hdf5 file which has String dataset values with fixed length
size and the number of dimensions is 1. I am using HDF 1.10.1 Windows10
x64.
I allocate array of pointers to read the data values in the same way as
given in the hdf5 documentation. Here is the code which is reading the
string dataset values.
In this code, the dynamic 2D array of pointers is not initialized as per
the standard way using a loop.
I would like to know, what are other possible ways to allocate the buffer
to read 1 dimension string dataset values?
Can we simply read the 1 dimension dataset values by passing arrays
pointed to the buffer?
Any insight is greatly appreciated.
it's easier to have just one contiguous buffer of type char* with a single allocation for doing the I/O. If your strings are all of fixed length, you can pack all those independent strings into a single char* buffer . Then do I/O on that one-dimensional buffer of chars, and when you need them as strings, you extract them from this char* buffer.
···
On 27.07.2017 20:49, Deepak 8 Kumar wrote:
I am reading hdf5 file which has String dataset values with fixed length size and the number of dimensions is 1. I am using HDF 1.10.1 Windows10 x64.
I allocate array of pointers to read the data values in the same way as given in the hdf5 documentation. Here is the code which is reading the string dataset values.
In this code, the dynamic 2D array of pointers is not initialized as per the standard way using a loop.
I would like to know, what are other possible ways to allocate the buffer to read 1 dimension string dataset values?
Can we simply read the 1 dimension dataset values by passing arrays pointed to the buffer?
Any insight is greatly appreciated.
--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362
If I allocate just one contiguous buffer of type char*, it reads only the
first element. Rest of the elements are not in the buffer.
unique_ptr<char[]> pdataset_buffer = make_unique<char
[]>(number_of_elements * size);
char* buffer = pdataset_buffer.get();
HDF5_Utility::check_error(H5Dread(dataset_id, dataset_type_id, H5S_ALL,
H5S_ALL, H5P_DEFAULT, buffer));
···
From: Werner Benger <werner@cct.lsu.edu>
To: hdf-forum@lists.hdfgroup.org
Date: 07/28/2017 05:56 AM
Subject: Re: [Hdf-forum] How to read Fixed Length String Dataset
values
Sent by: "Hdf-forum" <hdf-forum-bounces@lists.hdfgroup.org>
Hi,
it's easier to have just one contiguous buffer of type char* with a
single allocation for doing the I/O. If your strings are all of fixed
length, you can pack all those independent strings into a single char*
buffer . Then do I/O on that one-dimensional buffer of chars, and when you
need them as strings, you extract them from this char* buffer.
On 27.07.2017 20:49, Deepak 8 Kumar wrote:
I am reading hdf5 file which has String dataset values with fixed length
size and the number of dimensions is 1. I am using HDF 1.10.1 Windows10
x64.
I allocate array of pointers to read the data values in the same way as
given in the hdf5 documentation. Here is the code which is reading the
string dataset values.
In this code, the dynamic 2D array of pointers is not initialized as per
the standard way using a loop.
I would like to know, what are other possible ways to allocate the buffer
to read 1 dimension string dataset values?
Can we simply read the 1 dimension dataset values by passing arrays
pointed to the buffer?
Any insight is greatly appreciated.
I am getting all the elements in the buffer with just one contiguous
buffer of type char*. Thanks for all the help.
···
From: Werner Benger <werner@cct.lsu.edu>
To: hdf-forum@lists.hdfgroup.org
Date: 07/28/2017 05:56 AM
Subject: Re: [Hdf-forum] How to read Fixed Length String Dataset
values
Sent by: "Hdf-forum" <hdf-forum-bounces@lists.hdfgroup.org>
Hi,
it's easier to have just one contiguous buffer of type char* with a
single allocation for doing the I/O. If your strings are all of fixed
length, you can pack all those independent strings into a single char*
buffer . Then do I/O on that one-dimensional buffer of chars, and when you
need them as strings, you extract them from this char* buffer.
On 27.07.2017 20:49, Deepak 8 Kumar wrote:
I am reading hdf5 file which has String dataset values with fixed length
size and the number of dimensions is 1. I am using HDF 1.10.1 Windows10
x64.
I allocate array of pointers to read the data values in the same way as
given in the hdf5 documentation. Here is the code which is reading the
string dataset values.
In this code, the dynamic 2D array of pointers is not initialized as per
the standard way using a loop.
I would like to know, what are other possible ways to allocate the buffer
to read 1 dimension string dataset values?
Can we simply read the 1 dimension dataset values by passing arrays
pointed to the buffer?
Any insight is greatly appreciated.