Compund DataType in Packet Table

Hi,

Is it possible to write compound datatype, such as 'Struct' in packet table?

e.g. suppose if I have a structure,

struct myInfo
{
    char name[20];
    int age;
    float height;
}myInfo;

The packet table should look like:

Name Age Height
xyz 20 5.7

I mean like a table.

Is it possible? I tried creating compound data type but, to insert fields I
need to use Table APIs.
And it doesn't work for me. Any help?

···

-----
Best Regards,
Santosh
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/Compund-DataType-in-Packet-Table-tp1923252p1923252.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hi Santosh, yes it is possible to create the struct you describe into a
packet table. See my post entitled "Possible to pack bit types into compound
data types?" click
http://hdf-forum.184993.n3.nabble.com/Possible-to-pack-bit-types-into-compound-data-types-td1131024.html#a1168717
here and you'll see example code doing just what you want, in C++.

Beware, however, that it is NOT possible to pack multiple single bit named
entities into the same byte in HDF5, keep reading down the above post for
more background.

Steve

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/Compund-DataType-in-Packet-Table-tp1923252p1923365.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Steve,

Thank you very much for your immediate reply. Could you do me a favor and
let me know how I can do this with C APIs? I'm not familiar with these APIs
much as I have not built c++ libraries for HDF5.

···

-----
Best Regards,
Santosh
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/Compund-DataType-in-Packet-Table-tp1923252p1928757.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hi Santosh - your best bet is in fact to download the HDF5 source, and open
the files that implement the classes in the example, and cut & paste the
contents of the relevant methods.

This is a technique I've used myself where the C++ implementation is broken
for my compiler (such as the "read" constructor of the packet table class).

The code in my example is just 2 constructors & two methods. But going to
the HDF5 C++ source is instructive - the classes are basically just wrappers
for a bunch of C code, so they're easy to understand and copy, but written
by people who know what they're doing - i.e. not me :slight_smile:
Steve

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/Compund-DataType-in-Packet-Table-tp1923252p1929708.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Dear Steve,

That was great, the solution you provided. I tried it and surprised....:slight_smile: It
worked for me. Thanks a lot.

One more question, do you have any idea about how we can write variable
length data in packet table.

I checked for the API 'H5PTcreate_vl' but it is not available in HDF5
version I'm using here i.e. 1.8.5.

Do you have any magic with you to surprise me one more time? :wink:

···

-----
Best Regards,
Santosh
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/Compund-DataType-in-Packet-Table-tp1923252p1930198.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Sorry, Santosh, no - to quote Scott in his reply to your other thread:

IIRC, the variable length Packet Table is disabled by default because it has
some serious memory leak issues.

See
http://hdf-forum.184993.n3.nabble.com/Performance-issues-with-Packet-Table-td1903029.html
here

So for now, I think it's unusable.
Steve

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/Compund-DataType-in-Packet-Table-tp1923252p1944874.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hi Santosh,

It is possible to put variable length data in a H5PTcreate_fl packet table in 1.8.5. For example:

···

-------------
     typedef struct Particle
     {
         hvl_t set;
         hvl_t date_time;
         hvl_t name;
         hvl_t value;
         hvl_t units;
     };
     Particle p_data[1];
     std::string packetTableName="Events";
     hid_t packetTableID=H5PTopen(groupID, packetTableName.c_str());
     if(packetTableID==H5I_BADID)
     {
         hid_t vlenID=H5Tvlen_create(H5T_C_S1);
         if(vlenID < 0)
         {
             std::stringstream ss;
             ss << "Failed variable length create, " << groupName << " with return: " << packetTableID<<" "<< eventName<<" "<<eventValue<<" "<<eventUnit<< ".\n";
             throw QBPersistenceException(ss.str());
         }
         hid_t compoundID=H5Tcreate(H5T_COMPOUND, sizeof (Particle) );
         H5Tinsert(compoundID, "Set", HOFFSET(Particle, set), vlenID);
         H5Tinsert(compoundID, "Date Time", HOFFSET(Particle, date_time), vlenID);
         H5Tinsert(compoundID, "Name", HOFFSET(Particle, name), vlenID);
         H5Tinsert(compoundID, "Value", HOFFSET(Particle, value), vlenID);
         H5Tinsert(compoundID, "Units", HOFFSET(Particle, units), vlenID);
         H5Tpack( compoundID ) ;
         packetTableID=H5PTcreate_fl(groupID, packetTableName.c_str(), compoundID, (hsize_t)100, -1);
         if(packetTableID==H5I_BADID)
         {
             H5Tclose(compoundID);
             H5Tclose(vlenID);
             std::stringstream ss;
             ss << "Failed make packet table in group, " << groupName << " with return: " << packetTableID<<" eventName="<< eventName<<" "<<eventValue<<" "<<eventUnit<< ".\n";
             throw QBPersistenceException(ss.str());
         }
         H5Tclose(compoundID);
         H5Tclose(vlenID);
     }

....proceed to populate with data...
-------------

Notice if the table can't be opened then it is created with "H5PTcreate_fl" and setup to take compound data type with variable length c string data. The HDFView won't show these properly but custom retrieval can get this data.

Also it won't work with parallel hdf5 at this point.

On 11/19/2010 07:17 AM, santoshdarekar wrote:

Dear Steve,

That was great, the solution you provided. I tried it and surprised....:slight_smile: It
worked for me. Thanks a lot.

One more question, do you have any idea about how we can write variable
length data in packet table.

I checked for the API 'H5PTcreate_vl' but it is not available in HDF5
version I'm using here i.e. 1.8.5.

Do you have any magic with you to surprise me one more time? :wink:

-----
Best Regards,
Santosh