Hi HDF5 Expert,
I am trying to use ZSTD filter plugin here on a data with 30000 by 6912, as shown by the below, to write the data. It works !!!. Something wired is that I found the filter is called twice even though I write the whole chunk(data) with a single H5Dwrite. Anyone can help to explain it why? Also, Once I had a few attributes on the dataset “A”, it seems to be called more than 2 times.
Thanks for your help.
Bin
==========
GROUP “/” {
DATASET “A” {
DATATYPE H5T_STD_I16LE
DATASPACE SIMPLE { ( 30000, 6912 ) / ( 30000, 6912 ) }
STORAGE_LAYOUT {
CHUNKED ( 30000, 6912 )
SIZE 326796913 (1.269:1 COMPRESSION)
}
FILTERS {
USER_DEFINED_FILTER {
FILTER_ID 32015
COMMENT Zstandard compression: http://www.zstd.net
PARAMS { 11 }
}
}
=======
I used the https://github.com/aparamon/HDF5Plugin-Zstandard
I just added a printf right after the ZSTD_compress. It is printed twice and I think the filter is called twice.
Both calls have the same origSize but the the first one is compressed real well.
aggression = 11, origSize =414720000, compSize = 12678
aggression = 11, origSize =414720000, compSize = 326796913
=====
my code looks like the below:
DLL_EXPORT size_t zstd_filter(unsigned int flags, size_t cd_nelmts,
const unsigned int cd_values[], size_t nbytes,
size_t *buf_size, void **buf)
{
…
inbuf = buf;
size_t origSize = nbytes; / Number of bytes for output (compressed) buffer */
if (flags & H5Z_FLAG_REVERSE)
{
…
}
else
{
int aggression;
if (cd_nelmts > 0)
aggression = (int)cd_values[0];
else
aggression = ZSTD_CLEVEL_DEFAULT;
size_t compSize = ZSTD_compressBound(origSize);
compSize = ZSTD_compress(outbuf, compSize, inbuf, origSize, aggression);
printf(" aggression = %d, origSize =%zu, compSize = %zu \n", aggression, origSize, compSize);
…
}
return 0;
}