-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method to retrieve path from Node or Dataset (issue #314). Add method "rename" #346
Conversation
Added lines 115-118
Added lines 165-182
Added lines 34-37
Added lines 29-45
Added lines 28-31
Added lines 30-46
Renaming obgects and moving them (actually their links) in HDF5 library is done via `herr_t H5Lmove( hid_t src_loc_id, const char *src_name, hid_t dest_loc_id, const char *dest_name, hid_t lcpl_id, hid_t lapl_id )` command https://portal.hdfgroup.org/display/HDF5/H5L_MOVE The documentation says the following: `hid_t src_loc_id IN: Original location identifier; may be a file, group, dataset, named datatype or attribute identifier` But I only could do this if `src_loc_id` is id of `File` or `Group`. Therefore now `File` and `Group` has the ability to move their objects to other places
Also I added the method |
A first question is : could you add some tests in |
This example tries to create group, dataset in that group and attribute to this dataset. After this is done one tries to retrieve path to objects and name for attribute. Then one moves created dataset to another place and all intermediate groups that are divided by the `/` sign will be created automatically. And finally we can still use the moved dataset to create new attribute (the `id` of dataset is still available after it is moved).
Thanks! Do you think the tests could be added to |
@tdegeus actually I don't know how test should look like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, seems like nice functionality (that I think I wanted to have at some point). Some nudges here…
inline std::string Attribute::getAttributeName() const { | ||
const size_t maxLength = 255; | ||
char buffer[maxLength + 1]; | ||
ssize_t retcode = H5Aget_name( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me that this code repeats itself several times, save for this little function. Could probably be deduplicated? Also the naming could be shortened to getName
and getPath
without repeating the class name in the method name…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I absolutely agree with your proposition about changing the names of the methods. So now they are called getName
and getPath
Seems to me that this code repeats itself several times, save for this little function. Could probably be deduplicated?
I still don't fully understand how this library works because I have huge number of errors inside the project :)
I guess this is beacause one namespace is divided in many .hpp
files and when I compile the code it works because those files are combined I think.
But editing the code is difficult in such conditions. In this case creating new small functions that decrease the number of code lines would make the code less readable for me and probably for other developpers who probably would read this code.
So if you don't mind I would leave it as is.
@KerimMatlab Nice features you introduced! I do have some suggestions to improve. If you agree I'll directly push them to the pull request. My comments are that:
|
Why there are three declined status (Review required, All checks have failed, Merging is blocked)? |
The "1 failing check" is because the continuous integration (CI) is firing an error. In this project all compiler warning do this. You can click on details to check out the reason. Furthermore this project requires at least one reviewer to explicitly approve before the PR can be merged by somebody with the proper rights. |
Let me know if you're ok if I push some suggestions (we can always revert some of them) |
I wasn't sure if the naming should be changed. You're already passing in an object, so in my opinion, the I'll have a look deduplicating the other code… |
Deduplicate code.
@matz-e I just replaced |
You did it almost correctly! The only thing that needed improvement was that you did not allow for a variably length, by hand-specifying it. I corrected it, along with another issue that appeared for a reason unclear to me. Anyway since it was a bug it is good that it is now fixed. |
Very nice cleanup @KerimMatlab and @matz-e ! |
I was just giving it another look to approve; One last thing (sorry!): could we have a test for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, @KerimMatlab and @tdegeus! Apologies that this dragged on for a while.
Merging after no additional dissenting feedback received. |
Thank you again for your contributions! |
Sometimes you need to retrieve the name and the path of the node (File/Group) or dataset and attribute.
For
File/Group/Dataset
hdf5 uses function:ssize_t H5Iget_name( hid_t obj_id, char *name, size_t size )
and this returnes path to these objectsFor attribute it uses another function:
ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf )
To check the implemented function you can run: