diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-29 20:26:21 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-29 20:26:21 (GMT) |
commit | f503a7249136b967e010bbccc413a866947b3def (patch) | |
tree | 8adf168462479d39e2880d6b7fb6a8cf68cf2976 /tools/h5repack/h5repack_copy.c | |
parent | 5db6c61f18198ac4477a6ba99d405ff82cf467a7 (diff) | |
download | hdf5-f503a7249136b967e010bbccc413a866947b3def.zip hdf5-f503a7249136b967e010bbccc413a866947b3def.tar.gz hdf5-f503a7249136b967e010bbccc413a866947b3def.tar.bz2 |
[svn-r7994] Purpose:
h5repack new features
Description:
added checking routines for the filters that were applied to the output file
added tests for szip filter
Solution:
Platforms tested:
linux
solaris
(IRIX is not available)
:
Misc. update:
Diffstat (limited to 'tools/h5repack/h5repack_copy.c')
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 111 |
1 files changed, 98 insertions, 13 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 2afc94b..4d56ae6 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -19,6 +19,11 @@ #include "H5private.h" #include "h5repack.h" +static int filter_this(const char* name, + pack_opt_t *options, + pack_info_t *obj); /* info about object to filter */ + + /*------------------------------------------------------------------------- * Function: copy_file * @@ -39,7 +44,6 @@ int copy_file(const char* fnamein, { hid_t fidin; hid_t fidout; - int nobjects=0; trav_table_t *travt=NULL; /*------------------------------------------------------------------------- @@ -161,6 +165,8 @@ int do_copy_file(hid_t fidin, hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + hsize_t dsize_in; /* input dataset size before filter */ + hsize_t dsize_out; /* output dataset size after filter */ int i, j; /*------------------------------------------------------------------------- @@ -191,7 +197,7 @@ int do_copy_file(hid_t fidin, * copy attrs *------------------------------------------------------------------------- */ - if (copy_attr(grp_in,grp_out,options,travt,fidout)<0) + if (copy_attr(grp_in,grp_out,options)<0) goto error; if (H5Gclose(grp_out)<0) @@ -239,6 +245,12 @@ int do_copy_file(hid_t fidin, */ if ( ! H5Tequal(mtype_id, H5T_STD_REF_OBJ) ) { + + /* the information about the object to be filtered */ + pack_info_t filt_obj; + + /* get the storage size of the input dataset */ + dsize_in=H5Dget_storage_size(dset_in); /*------------------------------------------------------------------------- * read to memory @@ -254,21 +266,41 @@ int do_copy_file(hid_t fidin, goto error; /*------------------------------------------------------------------------- + * apply the filter; check first if the object is to be filtered. + * if the filter could not be applied, continue + *------------------------------------------------------------------------- + */ + if (filter_this(travt->objs[i].name,options,&filt_obj)) + { + if (apply_filter(dcpl_id,H5Tget_size(mtype_id),options,&filt_obj)<0) + continue; + } + + /*------------------------------------------------------------------------- * create/write dataset/close *------------------------------------------------------------------------- */ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,ftype_id,space_id,dcpl_id))<0) goto error; - if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - goto error; + if (dsize_in) { + if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + goto error; + } /*------------------------------------------------------------------------- * copy attrs *------------------------------------------------------------------------- */ - if (copy_attr(dset_in,dset_out,options,travt,fidout)<0) + if (copy_attr(dset_in,dset_out,options)<0) goto error; + + /*------------------------------------------------------------------------- + * store the storage sizes + *------------------------------------------------------------------------- + */ + dsize_out=H5Dget_storage_size(dset_out); + /*close */ if (H5Dclose(dset_out)<0) goto error; @@ -317,7 +349,7 @@ int do_copy_file(hid_t fidin, * copy attrs *------------------------------------------------------------------------- */ - if (copy_attr(type_in,type_out,options,travt,fidout)<0) + if (copy_attr(type_in,type_out,options)<0) goto error; if (H5Tclose(type_in)<0) @@ -372,8 +404,6 @@ int do_copy_file(hid_t fidin, break; } } - - /*------------------------------------------------------------------------- * the root is a special case, we get an ID for the root group @@ -389,7 +419,7 @@ int do_copy_file(hid_t fidin, if ((grp_in = H5Gopen(fidin,"/"))<0) goto error; - if (copy_attr(grp_in,grp_out,options,travt,fidout)<0) + if (copy_attr(grp_in,grp_out,options)<0) goto error; if (H5Gclose(grp_out)<0) @@ -438,9 +468,7 @@ error: int copy_attr(hid_t loc_in, hid_t loc_out, - pack_opt_t *options, - trav_table_t *travt, - hid_t fidout /* for saving references */ + pack_opt_t *options ) { hid_t attr_id; /* attr ID */ @@ -456,7 +484,6 @@ int copy_attr(hid_t loc_in, char name[255]; int n, j; unsigned u; - int have_ref=0; if ((n = H5Aget_num_attrs(loc_in))<0) goto error; @@ -576,3 +603,61 @@ error: return -1; } + + + +/*------------------------------------------------------------------------- + * Function: filter_this + * + * Purpose: find the object name NAME (got from the traverse list) + * in the repack options list; assign the filter information OBJ + * + * Return: 0 not found, 1 found + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: December 19, 2003 + * + *------------------------------------------------------------------------- + */ + +static +int filter_this(const char* name, /* object name from traverse list */ + pack_opt_t *options, /* repack options */ + pack_info_t *obj) /* info about object to filter */ +{ + char *pdest; + int result; + int i; + + /* if we are applying to all objects just return true */ + if (options->all_filter) + { + /* assign the global filter and chunk info to the OBJ info */ + obj->filter=options->filter_g; + obj->chunk=options->chunk_g; + return 1; + } + + for ( i=0; i<options->op_tbl->nelems; i++) + { + if (strcmp(options->op_tbl->objs[i].path,name)==0) + { + *obj=options->op_tbl->objs[i]; + return 1; + } + + pdest = strstr(name,options->op_tbl->objs[i].path); + result = (int)(pdest - name); + + /* found at position 1, meaning without '/' */ + if( pdest != NULL && result==1 ) + { + *obj=options->op_tbl->objs[i]; + return 1; + } + } + + return 0; +} + |