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....:) 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? ;)
-----
Best Regards,
Santosh
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org