Skip to content

Commit

Permalink
Update embedded PyTables code to v3.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Aug 27, 2024
1 parent ad7622d commit 9feaf95
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/information.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ HDF5 compression filters and compression libraries sources were obtained from:
(commit `49e3b65 <https://github.com/nexusformat/HDF5-External-Filter-Plugins/tree/49e3b65eca772bca77af13ba047d8b577673afba>`_)
using LZ4.
* `bitshuffle plugin <https://github.com/kiyo-masui/bitshuffle>`_ (v0.5.1) using LZ4 and ZStd.
* bzip2 plugin (from `PyTables <https://github.com/PyTables/PyTables/>`_ v3.9.2)
* bzip2 plugin (from `PyTables <https://github.com/PyTables/PyTables/>`_ v3.10.1)
using `BZip2 <https://sourceware.org/git/bzip2.git>`_ (v1.0.8).
* `hdf5-blosc plugin <https://github.com/Blosc/hdf5-blosc>`_ (v1.0.1)
using `c-blosc <https://github.com/Blosc/c-blosc>`_ (v1.21.5), LZ4, Snappy, ZLib and ZStd.
* hdf5-blosc2 plugin (from `PyTables <https://github.com/PyTables/PyTables/>`_ v3.9.2)
* hdf5-blosc2 plugin (from `PyTables <https://github.com/PyTables/PyTables/>`_ v3.10.1)
using `c-blosc2 <https://github.com/Blosc/c-blosc2>`_ (v2.15.0), LZ4, ZLib and ZStd.
* `FCIDECOMP plugin <https://gitlab.eumetsat.int/open-source/data-tailor-plugins/fcidecomp>`_
(`v2.0.1 <https://gitlab.eumetsat.int/open-source/data-tailor-plugins/fcidecomp/-/tree/e88f83c03bafcd0769c167dca14aa7aabf728e1b>`_)
Expand Down
20 changes: 20 additions & 0 deletions src/PyTables/hdf5-blosc2/src/blosc2_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ size_t blosc2_filter_function(unsigned flags, size_t cd_nelmts,
/* Filter params that are only set for B2ND */
int ndim = -1;
int32_t chunkshape[BLOSC2_MAX_DIM];
size_t chunksize = typesize;
if (cd_nelmts >= 8) {
/* Get chunk shape for B2ND */
ndim = cd_values[7];
Expand All @@ -321,6 +322,7 @@ size_t blosc2_filter_function(unsigned flags, size_t cd_nelmts,
}
for (int i = 0; i < ndim; i++) {
chunkshape[i] = cd_values[8 + i];
chunksize *= (size_t) cd_values[8 + i];
}
}

Expand Down Expand Up @@ -367,6 +369,14 @@ size_t blosc2_filter_function(unsigned flags, size_t cd_nelmts,

blosc2_storage storage = {.cparams=&cparams, .contiguous=false};

if (ndim > 1 && nbytes != chunksize) {
BLOSC_TRACE_INFO("Filter input size %lu does not match chunk data size %lu "
"(e.g. Fletcher32 checksum added before compression step), "
"using plain Blosc2 instead of B2ND",
nbytes, chunksize);
ndim = -1;
}

if (ndim > 1) {

b2nd_context_t *ctx = NULL;
Expand Down Expand Up @@ -453,6 +463,15 @@ size_t blosc2_filter_function(unsigned flags, size_t cd_nelmts,
/* declare dummy variables */
int32_t cbytes;

/* It would be cool to have a check to detect whether the buffer contains
* an unexpected amout of bytes because of the application of a previous
* filter (e.g. a Fletcher32 checksum), thus disabling B2ND optimizations.
* However, we cannot know before parsing the super-chunk, and that
* operation accepts trailing bytes without reporting their presence.
* Thus such a test can only happen outside of the filter, with more
* information available about the whole pipeline setup.
*/

blosc2_schunk* schunk = blosc2_schunk_from_buffer(*buf, (int64_t)nbytes, false);
if (schunk == NULL) {
PUSH_ERR("blosc2_filter", H5E_CALLBACK, "Cannot get super-chunk from buffer");
Expand Down Expand Up @@ -549,6 +568,7 @@ size_t blosc2_filter_function(unsigned flags, size_t cd_nelmts,
}

blosc2_dparams dparams = BLOSC2_DPARAMS_DEFAULTS;
dparams.schunk = schunk;
dctx = blosc2_create_dctx(dparams);
status = blosc2_decompress_ctx(dctx, chunk, cbytes, outbuf, (int32_t) outbuf_size);
if (status <= 0) {
Expand Down

0 comments on commit 9feaf95

Please sign in to comment.