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]
*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::CompTypemtype(sizeof(Class));

    mtype.insertMember("MD", HOFFSET(Class, dMD), datatype);

    H5::DataSetdataset = 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]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
___________________________________________________________________________
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