Reading array type attribute #632
Unanswered
katnellayappan
asked this question in
Questions
Replies: 2 comments 2 replies
-
HDF5 allows for something they call composite datatypes. If I understand correctly, those would allow people to store a single element which has datatype Can you please try and add a bit more information about the actual HDF5 file? One way would be to use h5dump -Hp -a /path/to/attribute file.h5 |
Beta Was this translation helpful? Give feedback.
2 replies
-
Thank you! That helped.
…-Kat.
From: Luc Grosheintz ***@***.***>
Sent: Friday, November 4, 2022 6:57 AM
To: BlueBrain/HighFive ***@***.***>
Cc: Kat Nellayappan ***@***.***>; Author ***@***.***>
Subject: Re: [BlueBrain/HighFive] Reading array type attribute (Discussion #632)
EXTERNAL MAIL
Okay, this is a scalar dataspace, i.e. the number of elements is one. However, the type of that single element is an array of 12 32-bit integers. You can then get the datatype, by doing:
const auto& datatype = attribute.getDataType();
if(datatype.getClass() == DataTypeClass::Compound) {
auto size_in_bytes = datatype.getSize();
// Try to figure out how many elements this results in.
}
How to proceed depends on your application. With some luck you know that it's an array of 32-bit integers. If that's the case you can figure out the number of elements by dividing the size of the datatype by sizeof(int) (or sizeof(std::int32_t)).
If not, it seem you'll need to use HDF5 directly. You can find details in the HDF5 User Guide: 6.5.1.2. Properties of Composite Datatypes. Available here:
https://portal.hdfgroup.org/display/HDF5/HDF5+User%27s+Guide<https://urldefense.com/v3/__https:/portal.hdfgroup.org/display/HDF5/HDF5*User*27s*Guide__;KyUr!!EHscmS1ygiU1lA!Au-VrYY_OzfzLFyHfIEgOnVjEf90sGoyWutE0r7hmJis3LWLTaNjldLUoj82VRQ2mSkHvx8UpGURCVmZYKWa$>
You can obtain the HDF5 identifier of any object by its member .getId(), e.g. datatype.getId().
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https:/github.com/BlueBrain/HighFive/discussions/632*discussioncomment-4057145__;Iw!!EHscmS1ygiU1lA!Au-VrYY_OzfzLFyHfIEgOnVjEf90sGoyWutE0r7hmJis3LWLTaNjldLUoj82VRQ2mSkHvx8UpGURCThc4S40$>, or unsubscribe<https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AIU2JOSDQQJSH2LSXWHGES3WGUI4TANCNFSM6AAAAAARVJ3V2Y__;!!EHscmS1ygiU1lA!Au-VrYY_OzfzLFyHfIEgOnVjEf90sGoyWutE0r7hmJis3LWLTaNjldLUoj82VRQ2mSkHvx8UpGURCap0ZGv_$>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have a HDF5 database and one of the datasets in it has an array type attribute. I'm trying to figure out how many elements are in the array but I'm having difficulty in figuring that out.
I tried using the following code snippet but it doesn't give me the correct answer:
numAttrElems is always 1 and in my database, I know that the attribute has 12 elements in the array.
Could someone please let me know correct way to get number of elements in the array type attribute?
-Kat
Beta Was this translation helpful? Give feedback.
All reactions