Hi,

I have some code to read in an array of vlen strings from an attribute attached 
to a packet table:

void
getTags(H5::DataSet& dataset, std::vector<std::string>& sTags)
{
    std::cout << __FUNCTION__ << " called" << std::endl;
    hsize_t aDim; // Num of attributes
    H5::Attribute tags = dataset.openAttribute("tags");
    tags.getSpace().getSimpleExtentDims(&aDim); // We know this is 1 dimensional

   // Prepare data structures
    sTags.resize(aDim);
    char** readBuff = new char*[aDim];
    
    // Set datatype for the array
    H5::PredType paramTag_t = H5::PredType::C_S1;
    paramTag_t.setSize(H5T_VARIABLE);
    
   // Read
    tags.read(paramTag_t,readBuff);
    
    for(int i=0; i<aDim; ++i)
    {
        sTags[i].assign(readBuff[i]);
    }
    
    // Clean up
    H5Dvlen_reclaim(paramTag_t.getId(), tags.getSpace().getId(), H5P_DEFAULT, 
readBuff);
    delete[] readBuff;
    std::cout << __FUNCTION__ << " ended" << std::endl;
}


Typically, I call this function from within main() on a H5::DataSet object (the 
packet table opened as a DataSet to access the attribute).  However, if I try 
to read the attribute twice using the following code:

int main (int argc, const char * argv[])
{
    std::vector<std::string> sTags;  // Store elements in the attribute

    H5::H5File file(argv[1],H5F_ACC_RDONLY,H5P_DEFAULT,H5P_DEFAULT);       
    H5::DataSet parms = file->openDataSet("thePacketTable"); // Open as dataset 
to access attrib
    
    // Call getTags twice
    getTags(parms, sTags);  // Okay
    
    getTags(parms, sTags);  // Bombs

    return EXIT_SUCCESS;
}


I get the error output at the second call:

getTags called
getTags ended
getTags called
HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:
  #000: H5A.c line 1085 in H5Aread(): unable to read attribute
    major: Attribute
    minor: Read failed
  #001: H5A.c line 1165 in H5A_read(): datatype conversion failed
    major: Attribute
    minor: Unable to encode value
  #002: H5T.c line 4765 in H5T_convert(): data type conversion failed
    major: Attribute
    minor: Unable to encode value
  #003: H5Tconv.c line 3029 in H5T_conv_vlen(): unable to convert between src 
and dest datatypes
    major: Datatype
    minor: Feature is unsupported
  #004: H5T.c line 4481 in H5T_path_find(): no appropriate function for 
conversion path
    major: Datatype
    minor: Unable to initialize object
Error: H5Aread failed


Is this a bug, or am I doing something silly?

Thanks,

Chris


--
Dr Chris Jewell
Lecturer in Biostatistics
Institute of Fundamental Sciences
Massey University
Private Bag 11222
Palmerston North 4442
New Zealand
Tel: +64 (0) 6 350 5701 Extn: 3586


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

Reply via email to