Werner,

Thanks for responding. I understand what you're saying and had tried it before. 
During dataset creation, I replaced mtype (Class' type) with mElementType 
(let's say float). This leads to runtime errors.

H5::CompType mtype(sizeof(Class));
mtype.insertMember("MD", HOFFSET(Class, dMD), datatype);
H5::DataSet dataset = solution.createDataSet( "/Well", mElementType, dataspace, 
ds_creatplist );
dataset.write( ObjectArray, mtype );

Further on, during the dataset write, I now substitute:
dataset.write( ObjectArray, mElementType );

This too leads to some complaining. However, the file is written out but with 
junk/wrong values. I am not surprised at this behavior given what I'm doing. 
However, I wonder if there is a way to release the unused space.

Again, for simplicity, let's say I only want to write out the element b from an 
array of the struct
    typedef struct s1_t {
      int    a;
      float  b;
      double c;
    } s1_t[LENGTH];

How can I achieve this without doing:
    s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
which leads to the file size being on the order of sizeof(s1_t) instead of 
sizeof(float))?

Appreciate your time.
Aman

From: Hdf-forum [mailto:[email protected]] On Behalf Of 
Werner Benger
Sent: Friday, July 22, 2016 9:58 AM
To: [email protected]
Subject: Re: [Hdf-forum] [Ext] Re: Writing subset of compound datatype


Hi Aman,

 no, you don't copy anything. You reference your full data structure and 
describe it with the complete memory layout of your data structure, but in the 
file you use a different data type. Currently you are using "mtype" in both the 
creation of the dataset and when writing the data, so in file you get the same 
as in memory. But you dont want that, you want to create a dataset that 
contains only a part of your data structure, so during data set creation time 
you would use a different type, not "mtype".

         Werner

On 22.07.2016 16:07, Aman Verma wrote:
Hi Werner,

I guess what you're implying is that I copy the components being written to 
file (Element belonging to ObjectArray[i]) to a different, more appropriate 
datatype such as an array: ElementTemp[i]. However I want to avoid doing this 
copying at every time step. There also doesn't seem a way to make a reference 
to this data, else I could just use that to write. What am I missing here?

Aman

From: Hdf-forum [mailto:[email protected]] On Behalf Of 
Werner Benger
Sent: Friday, July 22, 2016 7:58 AM
To: [email protected]<mailto:[email protected]>
Subject: [Ext] Re: [Hdf-forum] Writing subset of compound datatype


Hi,

 you probably want a different datatype in the file than in memory, i.e. in 
memory you want a datatype that describes the entire class, but for the file 
type one that only refers to the components written.

       Werner
On 22.07.2016 00:22, Aman Verma wrote:
I want to write, in a single line, the elements: ObjectArray[i].Element 
(0<=i<n) without having to copy the elements into a separate array altogether.
Using CompType and insertMember, I am writing just a subset (including Element) 
of an array of a compound datatype ObjectArray (a class/object in my case).

H5::CompType mtype(sizeof(Class));
mtype.insertMember("MD", HOFFSET(Class, dMD), datatype);
H5::DataSet dataset = solution.createDataSet( "/Well", mtype, dataspace, 
ds_creatplist );
dataset.write( ObjectArray, mtype );

This works fine. However, not unexpectedly, since I am defining the CompType 
with the size of the whole class (Class), while writing out only a subset 
(Element), my .h5 file is bigger (sizeof(Class)) than it should be 
(sizeof(Element)). I am already using compression. Is there a way to 'delete' 
this unused space? Or is there a better way to do what I'm trying to achieve? 
Is using hyperslab the right answer?

Thanks





_______________________________________________

Hdf-forum is for HDF software users discussion.

[email protected]<mailto:[email protected]>

http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.hdfgroup.org_mailman_listinfo_hdf-2Dforum-5Flists.hdfgroup.org&d=CwMD-g&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=Gubd6RtL_7XTb1ohYqqB8g&m=lKbmU4P9LiV-MFkYAWcKHGHdB0pPdG8BSuvpDHzqF4M&s=B8ATgTheCadpzj1Vzl1CaOJxX4aLFeR48nDvXd2HE4k&e=>

Twitter: 
https://twitter.com/hdf5<https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_hdf5&d=CwMD-g&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=Gubd6RtL_7XTb1ohYqqB8g&m=lKbmU4P9LiV-MFkYAWcKHGHdB0pPdG8BSuvpDHzqF4M&s=QqA7m5AzKDNF2kyO9CAAnZPTyo-Qm1ExdLTzF8pI7Qw&e=>




--

___________________________________________________________________________

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




_______________________________________________

Hdf-forum is for HDF software users discussion.

[email protected]<mailto:[email protected]>

http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.hdfgroup.org_mailman_listinfo_hdf-2Dforum-5Flists.hdfgroup.org&d=CwMD-g&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=Gubd6RtL_7XTb1ohYqqB8g&m=Ccaao7t3QAS9kuX_boUykX5qxNp_8iYMo1fDsHPh0gk&s=7rVUnJXuY3hvWgbFymEb24F05PEIbdN9USxwcgTuD0k&e=>

Twitter: 
https://twitter.com/hdf5<https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_hdf5&d=CwMD-g&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=Gubd6RtL_7XTb1ohYqqB8g&m=Ccaao7t3QAS9kuX_boUykX5qxNp_8iYMo1fDsHPh0gk&s=OL2mQPNGNdBrTVC3bgrv0xug7mF-8Do9qc3zycatRYo&e=>



--

___________________________________________________________________________

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
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to