Hi,

Working with packet table with compound data type with variable length strings; hdf5-1.8.5 and hdf-java-2.6.1-src(May 10 2010)

The table creates sucessfully, gets the columns from the compund datatype correctly, has the correct number of rows during a run. HDFView shows a table with cells with some square blocks. hdump shows all the text with each character in their own double quotes. I'm trying to use H5T_C_S1 as the predefined datatype for the variable length type set up for the compound datatype.

Is there another way? Seems so close yet I can't find what I'm doing incorrectly. Below is the code and the results of the table as shown by an h5dump:

------------code--------------------
void QBPersistence::recordEvent(std::string title, std::string groupName, std::string eventName, std::string eventValue, std::string eventUnit)
{
   if(parallel) return;
   bool startIt = false;
   boost::unordered_map<std::string, hid_t> groupTrail;
   hid_t groupID = openGroupBy(groupName, groupTrail, startIt);
   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<<" "<<eventValue<<" "<<eventUnit<< ".\n";
           throw QBPersistenceException(ss.str());
       }
       H5Tclose(compoundID);
       H5Tclose(vlenID);
   }
   /* Initialize packet table's "current record" */
   herr_t err = H5PTcreate_index(packetTableID);
   if(err < 0)
   {

   }
   boost::gregorian::date today = boost::gregorian::day_clock::local_day();
// boost::posix_time::date_time today_time;// = boost::local_time::local_date_time();
   boost::gregorian::date::ymd_type ymd = today.year_month_day();

   std::stringstream ss;
   ss<<ymd.month.as_long_string() << "/"<< ymd.day << "/" << ymd.year;
   std::string eventTime=ss.str();
   p_data[0].set.len=(size_t)4;
   p_data[0].set.p=(void*)"Test";//title.c_str();
   p_data[0].date_time.len=(size_t)eventTime.length();
   p_data[0].date_time.p=(void*)eventTime.c_str();
   p_data[0].name.len=(size_t)eventName.length();
   p_data[0].name.p=(void*)eventName.c_str();
   if(eventValue.length()==0)
   {
       eventValue=" ";
   }
   p_data[0].value.len=(size_t)eventValue.length();
   p_data[0].value.p=(void*)eventValue.c_str();
   if(eventUnit.length()==0)
   {
       eventUnit=" ";
   }
   p_data[0].units.len=(size_t)eventUnit.length();
   p_data[0].units.p=(void*)eventUnit.c_str();
   err=H5PTappend(packetTableID, (hsize_t)1, p_data);
   if (err < 0)
   {
       std::stringstream ss;
ss <<"Failed record to Events table, for " << groupName << " with return: " << err<<" "<< eventName<<" "<<eventValue<<" "<<eventUnit << ".\n";
       throw QBPersistenceException(ss.str());
   }
   H5PTclose(packetTableID);
   closeGroupPath(groupTrail);
}

--------------------------------

------------h5dump result for packet table--------------------
<SDataset Name="Events" OBJ-XID="xid_10784" H5Path= "/rec/Events" Parents="xid_800" H5ParentPaths="/rec">
        <SStorageLayout>
           <SChunkedLayout Ndims="1">
              <SChunkDimension DimSize="100" />
              <SRequiredFilter>
              </SRequiredFilter>
           </SChunkedLayout>
        </SStorageLayout>
<SFillValueInfo FillTime="FillOnAlloc" AllocationTime="Incremental">
           <SFillValue>
                 <SData>
                    <!-- Compound fill not yet implemented. -->
                    <SNoData />
                 </SData>
           </SFillValue>
        </SFillValueInfo>
        <SDataspace>
           <SSimpleDataspace Ndims="1">
              <SDimension  DimSize="20" MaxDimSize="UNLIMITED"/>
           </SSimpleDataspace>
        </SDataspace>
        <SDataType>
           <SCompoundType>
              <SField FieldName="Set">
                 <SDataType>
                    <SVLType>
                       <SDataType>
                          <SAtomicType>
<SStringType Cset="H5T_CSET_ASCII" StrSize="1" StrPad="H5T_STR_NULLTERM"/>
                          </SAtomicType>
                       </SDataType>
                    </SVLType>
                 </SDataType>
              </SField>
              <SField FieldName="Date Time">
                 <SDataType>
                    <SVLType>
                       <SDataType>
                          <SAtomicType>
<SStringType Cset="H5T_CSET_ASCII" StrSize="1" StrPad="H5T_STR_NULLTERM"/>
                          </SAtomicType>
                       </SDataType>
                    </SVLType>
                 </SDataType>
              </SField>
              <SField FieldName="Name">
                 <SDataType>
                    <SVLType>
                       <SDataType>
                          <SAtomicType>
<SStringType Cset="H5T_CSET_ASCII" StrSize="1" StrPad="H5T_STR_NULLTERM"/>
                          </SAtomicType>
                       </SDataType>
                    </SVLType>
                 </SDataType>
              </SField>
              <SField FieldName="Value">
                 <SDataType>
                    <SVLType>
                       <SDataType>
                          <SAtomicType>
<SStringType Cset="H5T_CSET_ASCII" StrSize="1" StrPad="H5T_STR_NULLTERM"/>
                          </SAtomicType>
                       </SDataType>
                    </SVLType>
                 </SDataType>
              </SField>
              <SField FieldName="Units">
                 <SDataType>
                    <SVLType>
                       <SDataType>
                          <SAtomicType>
<SStringType Cset="H5T_CSET_ASCII" StrSize="1" StrPad="H5T_STR_NULLTERM"/>
                          </SAtomicType>
                       </SDataType>
                    </SVLType>
                 </SDataType>
              </SField>
           </SCompoundType>
        </SDataType>
     <!-- Note: format of compound data not specified -->
        <SData>
           <SDataFromFile>
"T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "H" "e" "a" "t" " " "o" "f" " " "F" "o" "r" "m" "a" "t" "i" "o" "n" "-" "1" "0" "6" "." "9" "7" "9" "8" "9" "1" "2" "7" "7" "9" "2" "2" "4" "3" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "E" "l" "e" "c" "t" "r" "o" "n" "i" "c" " " "E" "n" "e" "r" "g" "y" "-" "4" "2" "3" "8" "4" "." "9" "3" "3" "7" "9" "7" "3" "6" "4" "3" "8" "5" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "C" "o" "r" "e" "-" "C" "o" "r" "e" " " "E" "n" "e" "r" "g" "y" "9" "." "6" "8" "3" "1" "8" "5" "0" "8" "3" "0" "4" "4" "7" "7" "4" "2" "e" "-" "3" "1" "6" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "T" "o" "t" "a" "l" " " "E" "n" "e" "r" "g" "y" "-" "4" "7" "6" "7" "." "5" "1" "2" "9" "3" "6" "7" "9" "8" "1" "2" "0" "8" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "F" "e" "r" "m" "i" " " "E" "n" "e" "r" "g" "y" "2" "." "3" "6" "7" "1" "5" "6" "7" "4" "3" "2" "8" "4" "2" "1" "4" "3" "e" "-" "3" "1" "0" "e" "V" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "H" "e" "a" "t" " " "o" "f" " " "F" "o" "r" "m" "a" "t" "i" "o" "n" "-" "9" "6" "." "8" "8" "9" "6" "3" "0" "9" "9" "2" "6" "4" "9" "4" "7" "2" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "E" "l" "e" "c" "t" "r" "o" "n" "i" "c" " " "E" "n" "e" "r" "g" "y" "-" "4" "2" "3" "8" "4" "." "4" "9" "6" "2" "4" "2" "4" "7" "5" "4" "3" "4" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "C" "o" "r" "e" "-" "C" "o" "r" "e" " " "E" "n" "e" "r" "g" "y" "-" "0" "." "0" "9" "6" "4" "6" "8" "6" "9" "0" "1" "7" "3" "3" "3" "4" "7" "5" "9" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "T" "o" "t" "a" "l" " " "E" "n" "e" "r" "g" "y" "-" "4" "7" "7" "6" "." "7" "1" "0" "5" "3" "4" "7" "0" "3" "2" "5" "5" "7" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "F" "e" "r" "m" "i" " " "E" "n" "e" "r" "g" "y" "0" "." "1" "1" "1" "1" "5" "4" "7" "6" "2" "0" "5" "4" "2" "7" "4" "0" "6" "e" "V" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "H" "e" "a" "t" " " "o" "f" " " "F" "o" "r" "m" "a" "t" "i" "o" "n" "-" "1" "9" "4" "." "9" "6" "3" "7" "5" "3" "0" "7" "4" "0" "5" "8" "3" "3" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "E" "l" "e" "c" "t" "r" "o" "n" "i" "c" " " "E" "n" "e" "r" "g" "y" "-" "6" "7" "3" "7" "1" "." "9" "7" "4" "8" "8" "4" "8" "2" "9" "1" "9" "3" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "C" "o" "r" "e" "-" "C" "o" "r" "e" " " "E" "n" "e" "r" "g" "y" "8" "." "6" "9" "5" "5" "5" "5" "3" "6" "6" "8" "0" "5" "9" "3" "9" "2" "e" "-" "3" "2" "2" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "T" "o" "t" "a" "l" " " "E" "n" "e" "r" "g" "y" "-" "6" "4" "5" "5" "." "5" "0" "3" "6" "2" "1" "0" "0" "5" "2" "1" "3" "1" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "F" "e" "r" "m" "i" " " "E" "n" "e" "r" "g" "y" "2" "." "3" "7" "1" "5" "1" "5" "1" "0" "0" "0" "3" "7" "9" "8" "3" "4" "e" "-" "3" "2" "2" "e" "V" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "H" "e" "a" "t" " " "o" "f" " " "F" "o" "r" "m" "a" "t" "i" "o" "n" "-" "1" "8" "6" "." "6" "2" "2" "9" "5" "8" "9" "4" "0" "9" "7" "7" "7" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "E" "l" "e" "c" "t" "r" "o" "n" "i" "c" " " "E" "n" "e" "r" "g" "y" "-" "6" "7" "3" "7" "1" "." "6" "1" "3" "1" "9" "3" "9" "3" "6" "4" "4" "2" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "C" "o" "r" "e" "-" "C" "o" "r" "e" " " "E" "n" "e" "r" "g" "y" "0" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "T" "o" "t" "a" "l" " " "E" "n" "e" "r" "g" "y" "-" "6" "4" "6" "2" "." "5" "2" "4" "2" "3" "8" "0" "0" "5" "8" "8" "4" "4" "k" "C" "a" "l" "/" "m" "o" "l" "T" "e" "s" "t" "A" "u" "g" "u" "s" "t" "/" "3" "/" "2" "0" "1" "0" "F" "e" "r" "m" "i" " " "E" "n" "e" "r" "g" "y" "0" "e" "V"
           </SDataFromFile>
        </SData>
     </SDataset>
--------------------------------


_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to