VarLenType and ragged arrays

I am trying to specify my data as a "ragged array" as
mentioned in the hdf documentation.

I.e. I create a 2-d dataspace containing elements of
compound type: "variable length". This shall give me
efectively a 3-d array with the third dimension of
variable length.

However I cannot find out, how I would specify the actual
length of the variable length. I cannot find anything
in the docs, nor can I find an example. I looked both
in the C and C++ API descriptions.

Could someone possibly point me to something that
is of help in this matter?

Thank you,

···

--
_________________________________________
  _ _ | Roland Schwarz
>_)(_ | aka. speedsnail
> \__) | mailto:roland.schwarz@chello.at
________| http://www.blackspace.at

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Hi Roland,

This is the function I use to write an N-dim array of strings (String is std::string).
(it encapsulates a hid_t in an object, but I have removed that; hence you do not see close functions for a hid_t).
I hope it is clear.

Cheers,
Ger

  void HDF5Record::writeArrayString (hid_t groupHid, const String& name,
           const Array<String>& value)
  {
    // It seems that HDF5 cannot handle empty strings.
    char* emptystr = "__empty__";
    std::vector<char*> ptrs(value.nelements());
    // Copy the string pointers to a vector.
    Array<String>::const_iterator aiter=value.begin();
    for (std::vector<char*>::iterator viter = ptrs.begin();
   viter!=ptrs.end();
   ++aiter, ++viter) {
      if (aiter->empty()) {
  *viter = emptystr;
      } else {
  *viter = (char*)(aiter->c_str());
      }
    }
    // Create the data space for the array.
    const IPosition& shape = value.shape();
    int rank = shape.nelements();
    // Convert the shape to a vector of hsize_t.
    std::vector<hsize_t> ls = HDF5DataSet::fromShape (shape);
    hid_t dsid = H5Screate_simple(rank, &(ls[0]), NULL));
    // Create the attribute.
    hid_t dtid = H5Tcopy (H5T_C_S1);
    H5Tset_size (dtid, H5T_VARIABLE);
    hid_t id = H5Acreate(groupHid, name.c_str(), dtid,
           dsid, H5P_DEFAULT, H5P_DEFAULT);
    H5Awrite(id, dtid, &(ptrs[0]);
  }

Roland Schwarz <roland.schwarz@chello.at> 05/09/08 11:47 AM >>>

I am trying to specify my data as a "ragged array" as
mentioned in the hdf documentation.

I.e. I create a 2-d dataspace containing elements of
compound type: "variable length". This shall give me
efectively a 3-d array with the third dimension of
variable length.

However I cannot find out, how I would specify the actual
length of the variable length. I cannot find anything
in the docs, nor can I find an example. I looked both
in the C and C++ API descriptions.

Could someone possibly point me to something that
is of help in this matter?

Thank you,

···

--
_________________________________________
  _ _ | Roland Schwarz
>_)(_ | aka. speedsnail
> \__) | mailto:roland.schwarz@chello.at
________| http://www.blackspace.at

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Binh-Minh Ribler wrote:

Hi Roland,

Have you looked at H5Tset_size to specify the length of the variable length?

Hmm, yes but

1) I am trying to use th C++ wrappers and
2) I did not understand what it's purpose really is.

In the meantime however I found out that I would need to
wrap my data into a struct

struct hvl_t {
  void* p;
  int len;
}

then have p point to my dynamic array and have len set to its
size.

This works, and I can get something meanigful results with h5dump.

However HDFView does not like this ragged 3-d array. :frowning:

···

Binh-Minh

-----Original Message-----
From: Roland Schwarz [mailto:roland.schwarz@chello.at]
Sent: Friday, May 09, 2008 5:48 AM
To: hdf-forum@hdfgroup.org
Subject: [hdf-forum] VarLenType and ragged arrays

I am trying to specify my data as a "ragged array" as
mentioned in the hdf documentation.

I.e. I create a 2-d dataspace containing elements of
compound type: "variable length". This shall give me
efectively a 3-d array with the third dimension of
variable length.

However I cannot find out, how I would specify the actual
length of the variable length. I cannot find anything
in the docs, nor can I find an example. I looked both
in the C and C++ API descriptions.

Could someone possibly point me to something that
is of help in this matter?

Thank you,

--
_________________________________________
_ _ | Roland Schwarz
>_)(_ | aka. speedsnail
> \__) | mailto:roland.schwarz@chello.at
________| http://www.blackspace.at

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-
subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

--
_________________________________________
  _ _ | Roland Schwarz
>_)(_ | aka. speedsnail
> \__) | mailto:roland.schwarz@chello.at
________| http://www.blackspace.at

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.