-
Notifications
You must be signed in to change notification settings - Fork 160
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 the option for using blosc filter #980
base: master
Are you sure you want to change the base?
Conversation
# I install hdf5-blosc to the default path | ||
set(blosc_filter_DIR /usr/local/lib/) | ||
target_link_libraries(HighFive INTERFACE blosc_filter) | ||
target_link_directories(HighFive INTERFACE /usr/local/include/) |
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.
We will have to fix that.
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.
Since blosc is an extra plugin of hdf5, it is necessary to compile and link this external libraries. hdf5-blosc can not be found using find_package macro since it is packaged too simple here. I haven't figured out an elegant way to link this library.
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.
What I mean is that hard coded path to your system is not the valid way to give access to blosc.
inline herr_t h5p_set_blosc(hid_t plist_id, const unsigned int *cd_values) { | ||
char *version, *date; | ||
if (register_blosc(&version, &date) < 0) { | ||
HDF5ErrMapper::ToException<PropertyException>("Blosc filter unavailable."); | ||
} | ||
|
||
herr_t err = H5Pset_filter(plist_id, FILTER_BLOSC, H5Z_FLAG_OPTIONAL, 7, cd_values); | ||
if (err < 0) { | ||
HDF5ErrMapper::ToException<PropertyException>("Error setting blosc property"); | ||
} | ||
return err; | ||
} |
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.
@1uc I don't think this is how you think how your wrapper, right?
We will need to put this helper in an other place?
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.
Unlike szip, a built-in filter in hdf5, blosc filter must be registered before use. Perhaps a register wrapper should be added here.
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.
Here I'd prefer splitting it differently:
inline herr_t h5p_set_filter(....) {
herr_t err = H5Pset_filter(...);
if (err < 0) {
HDF5ErrMapper::ToException<PropertyException>("Error setting setting filter.");
}
return err;
}
Then in Blosc
we do the other half:
inline void Blosc::apply(const hid_t hid) const {
char *version, *date;
if (register_blosc(&version, &date) < 0) {
HDF5ErrMapper::ToException<PropertyException>("Blosc filter unavailable.");
}
detail::h5p_set_filter(plist_id, FILTER_BLOSC, H5Z_FLAG_OPTIONAL, 7, cd_values);
}
If you want the error message to contain the word "blosc" when set_filter
fail, one would need to catch and rethrow with a different error message.
To avoid the issue with forcing an optional dependency (blosc) on all users, we'll need to rework the PR. I think we can safely move all blocs related code to To fix the build-system maybe the following works:
This has the advantage (for us) that we don't specify how to find/link to blosc, it's left up to the user. This is different everywhere and we're likely to get it wrong if blosc doesn't have |
#include "blosc_filter.h" | ||
|
||
inline herr_t h5p_set_blosc(hid_t plist_id, const unsigned int *cd_values) { | ||
char *version, *date; |
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.
These are both leaked, because register_blosc
uses strdup
which requires us to call free
.
} | ||
|
||
inline void Blosc::apply(const hid_t hid) const { | ||
detail::h5p_set_blosc(hid, _cd_values); |
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.
This function likely can't be called twice. Therefore, if two property lists with Blosc are created I suspect a misleading error message will be printed. It's unclear if it'll work, because register_blosc
seems to unconditionally return 1;
(despite defining and setting a retval
).
See #978
This PR adds a custom blosc filter and has been tested in create_dataset_double.cpp in examples folder.