diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-01-26 23:20:20 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-01-26 23:20:20 (GMT) |
commit | afc3563b76badc2345ca955d7d48fe16cceaf0c8 (patch) | |
tree | a691cf56cc1246acb05f7fc23a050c93f0d7bf6d /tools/h5repack | |
parent | 2a4253ceb8757c935304be24db989bd0f72effe8 (diff) | |
download | hdf5-afc3563b76badc2345ca955d7d48fe16cceaf0c8.zip hdf5-afc3563b76badc2345ca955d7d48fe16cceaf0c8.tar.gz hdf5-afc3563b76badc2345ca955d7d48fe16cceaf0c8.tar.bz2 |
[svn-r8113] Purpose:
new library function H5Pdelete_filter
deletes one or all filters from a dataset creation property list
this was done for the NONE option of h5repack, added tests for this feature
added a test for the new function in /test/dsets.c
Description:
Solution:
Platforms tested:
linux
solaris
AIX
Misc. update:
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 3 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 80 | ||||
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 17 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_main.c | 87 |
4 files changed, 134 insertions, 53 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 2dd1f67..c14d1f0 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -168,6 +168,7 @@ int do_copy_objects(hid_t fidin, for ( i = 0; i < travt->nobjs; i++) { + buf=NULL; switch ( travt->objs[i].type ) { /*------------------------------------------------------------------------- @@ -283,7 +284,7 @@ int do_copy_objects(hid_t fidin, if (rank) { /* filters require CHUNK layout; if we do not have one define a default */ - if (obj.chunk.rank==0) + if (obj.chunk.rank<=0) { obj.chunk.rank=rank; for (j=0; j<rank; j++) diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 8fb45f9..6476595 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -155,7 +155,8 @@ int print_filters(hid_t dcpl_id) * Function: apply_filters * * Purpose: apply the filters in the object to the property list; - * do extra checking in the case of SZIP + * do extra checking in the case of SZIP; delete all filters in the case + * of H5Z_FILTER_NONE present in the PACK_INFO_T filter array * * Return: 0, ok, -1 no * @@ -171,55 +172,55 @@ int apply_filters(hid_t dcpl_id, pack_opt_t *options, /* repack options */ pack_info_t *obj) /* info about object to filter */ { - int nfilters; /* number of filters */ - unsigned filt_flags; /* filter flags */ - H5Z_filter_t filtn; /* filter identification number */ - unsigned cd_values[20]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ - char f_name[256]; /* filter/file name */ - int i, j; + int nfilters; /* number of filters in DCPL */ unsigned aggression; /* the deflate level */ unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; unsigned szip_pixels_per_block; - + int i; + /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id))<0) return -1; - for (i=0; i<nfilters; i++) +/*------------------------------------------------------------------------- + * check if we have the H5Z_FILTER_NONE filter + * if so, just delete all filters from the DCPL and exit + *------------------------------------------------------------------------- + */ + + for ( i=0; i<obj->nfilters; i++) { - cd_nelmts = NELMTS(cd_values); - filtn = H5Pget_filter(dcpl_id, - (unsigned)i, - &filt_flags, - &cd_nelmts, - cd_values, - sizeof(f_name), - f_name); - } + if (obj->filter[i].filtn==H5Z_FILTER_NONE) + { + if (nfilters && H5Pdelete_filter(dcpl_id,H5Z_FILTER_NONE)<0) + return -1; + + return 1; + } + } + + +/*------------------------------------------------------------------------- + * the type of filter and additional parameter + * type can be one of the filters + * H5Z_FILTER_NONE 0, uncompress if compressed + * H5Z_FILTER_DEFLATE 1 , deflation like gzip + * H5Z_FILTER_SHUFFLE 2 , shuffle the data + * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC + * H5Z_FILTER_SZIP 4 , szip compression + *------------------------------------------------------------------------- + */ -/* - the type of filter and additional parameter - type can be one of the filters - H5Z_FILTER_NONE 0, uncompress if compressed - H5Z_FILTER_DEFLATE 1 , deflation like gzip - H5Z_FILTER_SHUFFLE 2 , shuffle the data - H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC - H5Z_FILTER_SZIP 4 , szip compression -*/ - for ( j=0; j<obj->nfilters; j++) + for ( i=0; i<obj->nfilters; i++) { - switch (obj->filter[j].filtn) + switch (obj->filter[i].filtn) { - case H5Z_FILTER_NONE: - + default: break; - case H5Z_FILTER_DEFLATE: - - aggression=obj->filter[j].cd_values[0]; + aggression=obj->filter[i].cd_values[0]; /* set up for deflated data */ if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) @@ -232,7 +233,7 @@ int apply_filters(hid_t dcpl_id, case H5Z_FILTER_SZIP: - szip_pixels_per_block=obj->filter[j].cd_values[0]; + szip_pixels_per_block=obj->filter[i].cd_values[0]; /* check szip parameters */ if (check_szip(obj->chunk.rank, @@ -273,13 +274,10 @@ int apply_filters(hid_t dcpl_id, return -1; break; - - - default: - break; + } /* switch */ - }/*j*/ + }/*i*/ return 0; } diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 2283bc5..bbf0492 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -47,11 +47,15 @@ int has_filter(hid_t dcpl_id, /* if no information about the input filter is requested return exit */ if (filtnin==-1) - return 1; + return 1; /* get information about filters */ if ((nfilters = H5Pget_nfilters(dcpl_id))<0) return -1; + + /* if we do not have filters and the requested filter is NONE, return 1 */ + if (!nfilters && filtnin==H5Z_FILTER_NONE) + return 1; for (i=0; i<nfilters; i++) { @@ -190,11 +194,14 @@ int h5repack_verify(const char *fname, } /*------------------------------------------------------------------------- - * layout check + * layout check; check only if a filter exists *------------------------------------------------------------------------- */ - if (has_layout(dcpl_id,obj)==0) - ret=0; + if (obj->filter[j].filtn>H5Z_FILTER_NONE ) + { + if (has_layout(dcpl_id,obj)==0) + ret=0; + } /*------------------------------------------------------------------------- * close @@ -248,7 +255,7 @@ int h5repack_verify(const char *fname, * filter check *------------------------------------------------------------------------- */ - if (options->all_filter==1){ + if (options->all_filter==1 ){ if (has_filter(dcpl_id,options->filter_g.filtn)==0) ret=0; } diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c index d81f311..fc7d571 100644 --- a/tools/h5repack/testh5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -96,6 +96,82 @@ error: } /*------------------------------------------------------------------------- + * Function: test_filter_none + * + * Purpose: + * + * 1) delete filters form the filter pipeline + * 2) use the h5diff utility to compare the input and output file; + * it returns RET==0 if the objects have the same data + * 3) use API functions to verify the compression/chunking input on the output file + * + * Return: Success: zero + * Failure: 1 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * September, 19, 2003 + * + * + *------------------------------------------------------------------------- + */ +static int +test_filter_none(void) +{ + pack_opt_t pack_options; + diff_opt_t diff_options; + memset(&diff_options, 0, sizeof (diff_opt_t)); + memset(&pack_options, 0, sizeof (pack_opt_t)); + + TESTING(" delete filters"); + +/*------------------------------------------------------------------------- + * test the NONE global option + *------------------------------------------------------------------------- + */ + + if (h5repack_init (&pack_options, 0)<0) + TEST_ERROR; + if (h5repack_addfilter("dset_gzip:NONE",&pack_options)<0) + TEST_ERROR; + if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0) + TEST_ERROR; + if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1) + TEST_ERROR; + if (h5repack_verify(FNAME4OUT,&pack_options)<=0) + TEST_ERROR; + if (h5repack_end (&pack_options)<0) + TEST_ERROR; + +/*------------------------------------------------------------------------- + * test the NONE specific option; uncompress a dataset + *------------------------------------------------------------------------- + */ + + if (h5repack_init (&pack_options, 0)<0) + TEST_ERROR; + if (h5repack_addfilter("dset_gzip:NONE",&pack_options)<0) + TEST_ERROR; + if (h5repack_addfilter("dset1:NONE",&pack_options)<0) + TEST_ERROR; + if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0) + TEST_ERROR; + if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1) + TEST_ERROR; + if (h5repack_verify(FNAME4OUT,&pack_options)<=0) + TEST_ERROR; + if (h5repack_end (&pack_options)<0) + TEST_ERROR; + + PASSED(); + return 0; + +error: + return 1; + + +} + +/*------------------------------------------------------------------------- * Function: test_filter_deflate * * Purpose: @@ -182,7 +258,8 @@ test_filter_deflate(void) TEST_ERROR; if (h5repack_end (&pack_options)<0) TEST_ERROR; - + + PASSED(); #else SKIPPED(); @@ -193,11 +270,8 @@ test_filter_deflate(void) error: return 1; #endif - - } - /*------------------------------------------------------------------------- * Function: test_filter_szip * @@ -347,10 +421,8 @@ error: return 1; #endif - } - /*------------------------------------------------------------------------- * Function: test_filter_checksum * @@ -743,6 +815,9 @@ int main (void) /* test a copy with no filters */ nerrors += test_copy(); + /* test a copy with the delete filters option */ + nerrors += test_filter_none(); + /* test a copy with the deflate filter */ nerrors += test_filter_deflate(); |