Reading or writing a compound type partially can be controlled via the mem_type_id argument. Let's say you have a compound type in the file with components A, B, and C. If you'd like to read only A or write to A, just construct an in memory compound type with just an A component. The library will match components by name between the file type and the memory type.
G. From: Hdf-forum [mailto:[email protected]] On Behalf Of Josiah Slack Sent: Thursday, July 18, 2013 7:30 AM To: HDF Users Discussion List Subject: Re: [Hdf-forum] writing part of a compound datatype On Thu, Jul 18, 2013 at 5:05 AM, Vladimir Daskalov <[email protected]> wrote: Hi, i'm not quite sure that i understand your question? Thanks for the response. The question doesn't stand alone very well; it's related to a broader question I had asked earlier. The summary is that I'm interested in constructing compound datatypes on the fly. I am trying to figure out if it's feasible to do something along the lines of 1) get next datum 2) Insert its description into the compound datatype 3) write the datum into the compound datatype, You are trying to: 1. write part of a compound datatype. - "the ability to write part of a compound datatype, rather than all of it in one go." 2. write part of a dataset. - "but none that obviously give me a mechanism for selecting what part of the dataset is to be written." As to the first one, i'm not familiar with a way to do it. (Maybe there is a way, i don't know) The second one: The signature of the H5Dwrite function is: herr_t H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void * buf ) In order to specify which part of the dataset is the passed data referenced by the buf pointer (essentially where in the dataset to store the provided data), you should call herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t *start, const hsize_t *stride, const hsize_t *count, const hsize_t *block ) before H5Dwrite with the same space_id argument as file_space_id in H5Dwrite. Eexample: Assuming you want to store an array([500]) of compound datatype (structures) from the beginning of the dataset to the 500th element. // Create file_space, mem_space, mem_type, dataset, etc. hsize_t start = 0; hsize_t stride = 0; hsize_t count = 500; hsize_t block = 0; H5Sselect_hyperslab( file_space_id, H5S_SELECT_SET, &start, &stride, &count, &block ); H5Dwrite( dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, data ); More info about H5Sselect_hyperslab at: http://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-SelectHyperslab Thanks for this, I'll have a close look at it. Best Regards, V. Daskalov On 18 July 2013 00:13, Josiah Slack <[email protected]> wrote: > > I'd like to pursue a particular detail of the compound datatype thread from yesterday. Specifically, the ability to write part of a compound datatype, rather than all of it in one go. I've spent some time today trying to figure out what's involved, but haven't got a clear idea. I'm assuming that the writing would be accomplished by calling H5Dwrite and passing it the id of a dataset created using H5Dcreate2() - (I'm cribbing from the listing of the sample program h5_compound). H5Dwrite() has a variety of arguments, but none that obviously give me a mechanism for selecting what part of the dataset is to be written. I've got a couple of guesses: > 1. there's some work to be done on the dataset prior to the write that selects what is supposed to be written, or > 2. the property list argument can somehow convey the information. > > Any guidance would be gratefully received. > > -Josiah > > _______________________________________________ > Hdf-forum is for HDF software users discussion. > [email protected] > http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org > _______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org _______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
