20 #include "ncdispatch.h"
21 #include "nc4internal.h"
24 #include "hdf5internal.h"
28 #include "zdispatch.h"
61 int stat = NC_check_id(ncid,&ncp);
64 if((stat = ncp->dispatch->inq_var_filter_ids(ncid,varid,nfiltersp,ids)))
goto done;
97 int stat = NC_check_id(ncid,&ncp);
100 if((stat = ncp->dispatch->inq_var_filter_info(ncid,varid,
id,nparamsp,params)))
goto done;
124 nc_def_var_filter(
int ncid,
int varid,
unsigned int id,
size_t nparams,
const unsigned int* params)
132 if((stat = NC_check_id(ncid,&ncp)))
return stat;
136 if((stat = NC4_inq_type_fixed_size(ncid, xtype, &fixedsize)))
return stat;
138 if((stat = ncp->dispatch->def_var_filter(ncid,varid,
id,nparams,params)))
goto done;
171 nc_inq_var_filter(
int ncid,
int varid,
unsigned int* idp,
size_t* nparamsp,
unsigned int* params)
175 unsigned int* ids = NULL;
176 int stat = NC_check_id(ncid,&ncp);
189 if((ids = calloc(
sizeof(
unsigned int),nfilters)) == NULL) {stat =
NC_ENOMEM;
goto done;}
193 if(idp) *idp = ids[0];
218 stat = NC_check_id(ncid,&ncp);
220 if((stat = ncp->dispatch->inq_filter_avail(ncid,
id)))
goto done;
228 #ifdef ENABLE_CLIENTSIDE_FILTERS
242 nc_filter_client_register(
unsigned int id,
void* info)
246 NC_FILTER_OBJ_HDF5 client;
247 if(
id == 0 ||info == NULL)
249 memset(&client,0,
sizeof(client));
250 client.hdr.format = NC_FILTER_FORMAT_HDF5;
251 client.sort = NC_FILTER_SORT_CLIENT;
252 client.u.client.id = id;
253 client.u.client.info = info;
255 stat = nc4_global_filter_action(NCFILTER_CLIENT_REG,
id, &client);
271 nc_filter_client_unregister(
unsigned int id)
275 stat = nc4_global_filter_action(NCFILTER_CLIENT_UNREG,
id, NULL);
292 nc_filter_client_inq(
unsigned int id,
void* infop)
296 H5Z_class2_t* hct = (H5Z_class2_t*)infop;
297 NC_FILTER_OBJ_HDF5 client;
298 if(
id == 0 ||infop == NULL)
300 memset(&client,0,
sizeof(client));
301 client.hdr.format = NC_FILTER_FORMAT_HDF5;
302 client.sort = NC_FILTER_SORT_CLIENT;
303 client.u.client.id = id;
304 client.u.client.info = hct;
306 stat = nc4_global_filter_action(NCFILTER_CLIENT_INQ,
id, &client);
308 *hct = *(H5Z_class2_t*)client.u.client.info;
340 if (level < 1 || level > 9)
342 ulevel = (unsigned) level;
377 if(nparams != 1) {stat =
NC_EFILTER;
goto done;}
380 if(levelp) *levelp = (int)params;
381 if(hasfilterp) *hasfilterp = hasfilter;
410 if (level < -131072 || level > 22)
412 ulevel = (unsigned) level;
451 if(nparams != 1) {stat =
NC_EFILTER;
goto done;}
454 if(levelp) *levelp = (int)params;
455 if(hasfilterp) *hasfilterp = hasfilter;
477 nc_def_var_blosc(
int ncid,
int varid,
unsigned subcompressor,
unsigned level,
unsigned blocksize,
unsigned addshuffle)
487 if(addshuffle > (
unsigned)BLOSC_BITSHUFFLE) {stat =
NC_EINVAL;
goto done;}
488 if(subcompressor > (
unsigned)BLOSC_ZSTD) {stat =
NC_EINVAL;
goto done;}
494 params[3] = blocksize;
496 params[5] = addshuffle;
497 params[6] = subcompressor;
528 unsigned* levelp,
unsigned* blocksizep,
unsigned* addshufflep)
544 if(nparams != 7) {stat =
NC_EFILTER;
goto done;}
546 if(blocksizep) *blocksizep = params[3];
547 if(levelp) *levelp = params[4];
548 if(addshufflep) *addshufflep = params[5];
549 if(subcompressorp) *subcompressorp = params[6];
551 if(hasfilterp) *hasfilterp = hasfilter;
int nc_inq_var_blosc(int ncid, int varid, int *hasfilterp, unsigned *subcompressorp, unsigned *levelp, unsigned *blocksizep, unsigned *addshufflep)
Learn whether Blosc compression is on for a variable, and, if so, the settings.
int nc_def_var_zstandard(int ncid, int varid, int level)
Turn on Zstandard compression for a variable.
int nc_inq_var_bzip2(int ncid, int varid, int *hasfilterp, int *levelp)
Learn whether bzip2 compression is on for a variable, and, if so, the level setting.
int nc_def_var_bzip2(int ncid, int varid, int level)
Turn on bzip2 compression for a variable.
EXTERNL int nc_inq_filter_avail(int ncid, unsigned id)
Test if filter is available.
int nc_inq_var_zstandard(int ncid, int varid, int *hasfilterp, int *levelp)
Learn whether Zstandard compression is on for a variable, and, if so, the level setting.
EXTERNL int nc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const unsigned int *params)
Define a new variable filter Assumes HDF5 format using unsigned ints.
EXTERNL int nc_inq_vartype(int ncid, int varid, nc_type *xtypep)
Learn the type of a variable.
int nc_def_var_blosc(int ncid, int varid, unsigned subcompressor, unsigned level, unsigned blocksize, unsigned addshuffle)
Turn on blosc for a variable.
EXTERNL int nc_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t *nparamsp, unsigned int *params)
Find the the param info about filter (if any) associated with a variable and with specified id.
EXTERNL int nc_inq_var_filter(int ncid, int varid, unsigned int *idp, size_t *nparamsp, unsigned int *params)
Find the first filter (if any) associated with a variable.
EXTERNL int nc_inq_var_filter_ids(int ncid, int varid, size_t *nfiltersp, unsigned int *ids)
Find the set of filters (if any) associated with a variable.
Main header file for the C API.
#define NC_EFILTER
Filter operation failed.
#define NC_ENOMEM
Memory allocation (malloc) failure.
#define EXTERNL
Needed for DLL build.
#define NC_EINVAL
Invalid Argument.
#define NC_NOERR
No Error.
#define NC_ENOTBUILT
Attempt to use feature that was not turned on when netCDF was built.
#define NC_ENOFILTER
Filter not defined on variable.
int nc_type
The nc_type type is just an int.