diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-10-19 16:11:16 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-10-19 16:11:16 (GMT) |
commit | 8ef059b4f74a557e2d5f4f11042d617ed33c91a4 (patch) | |
tree | df473244d1c8063ae553d7efa9860d2ed00f9b81 | |
parent | a4c0ed037424ada07720a22ebb15a58f199c5b78 (diff) | |
download | hdf5-8ef059b4f74a557e2d5f4f11042d617ed33c91a4.zip hdf5-8ef059b4f74a557e2d5f4f11042d617ed33c91a4.tar.gz hdf5-8ef059b4f74a557e2d5f4f11042d617ed33c91a4.tar.bz2 |
[svn-r9436] Purpose:
bug fix
Description:
Description:
one case was not handled in the combination of input options (layout and filters)
Solution:
redo the algorythm that handles all cases
Solution:
Platforms tested:
linux
Misc. update:
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | tools/h5repack/Makefile.in | 6 | ||||
-rw-r--r-- | tools/h5repack/h5repack.h | 8 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 23 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 293 | ||||
-rw-r--r-- | tools/h5repack/h5repack_layout.c | 175 |
6 files changed, 209 insertions, 297 deletions
@@ -1156,7 +1156,6 @@ ./tools/h5repack/h5repack.h ./tools/h5repack/h5repack_copy.c ./tools/h5repack/h5repack_filters.c -./tools/h5repack/h5repack_layout.c ./tools/h5repack/h5repack_list.c ./tools/h5repack/h5repack_main.c ./tools/h5repack/h5repack_opttable.c diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 630a4e8..73601d4 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/Makefile.in @@ -52,10 +52,10 @@ DISTCLEAN=h5repack.sh ## Source and object files for programs... ## -PROG_SRC=h5repack.c h5repack_copy.c h5repack_filters.c h5repack_refs.c h5repack_layout.c h5repack_list.c h5repack_main.c h5repack_opttable.c h5repack_parse.c h5repack_verify.c testh5repack_attr.c testh5repack_dset.c testh5repack_main.c testh5repack_make.c testh5repack_util.c +PROG_SRC=h5repack.c h5repack_copy.c h5repack_filters.c h5repack_refs.c h5repack_list.c h5repack_main.c h5repack_opttable.c h5repack_parse.c h5repack_verify.c testh5repack_attr.c testh5repack_dset.c testh5repack_main.c testh5repack_make.c testh5repack_util.c PROG_OBJ=$(PROG_SRC:.c=.lo) -OBJS=h5repack.lo h5repack_filters.lo h5repack_copy.lo h5repack_refs.lo h5repack_layout.lo h5repack_list.lo h5repack_main.lo h5repack_opttable.lo h5repack_parse.lo h5repack_verify.lo -TEST_OBJS=h5repack.lo h5repack_filters.lo h5repack_copy.lo h5repack_refs.lo h5repack_layout.lo h5repack_list.lo h5repack_opttable.lo h5repack_parse.lo h5repack_verify.lo testh5repack_attr.lo testh5repack_dset.lo testh5repack_main.lo testh5repack_make.lo testh5repack_util.lo +OBJS=h5repack.lo h5repack_filters.lo h5repack_copy.lo h5repack_refs.lo h5repack_list.lo h5repack_main.lo h5repack_opttable.lo h5repack_parse.lo h5repack_verify.lo +TEST_OBJS=h5repack.lo h5repack_filters.lo h5repack_copy.lo h5repack_refs.lo h5repack_list.lo h5repack_opttable.lo h5repack_parse.lo h5repack_verify.lo testh5repack_attr.lo testh5repack_dset.lo testh5repack_main.lo testh5repack_make.lo testh5repack_util.lo PRIVATE_HDR= diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index b5906ae..e4de4d3 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -179,18 +179,12 @@ int print_filters(hid_t dcpl_id); *------------------------------------------------------------------------- */ -int filter_this(const char* name, - pack_opt_t *options, - pack_info_t *pack); /* info about object to filter */ - int apply_filters(const char* name, /* object name from traverse list */ int rank, /* rank of dataset */ hsize_t *dims, /* dimensions of dataset */ hid_t dcpl_id, /* dataset creation property list */ hid_t type_id, /* datatype */ - pack_opt_t *options, /* repack options */ - int has_layout, /* input chunk */ - pack_info_t *obj); /* info about object to filter */ + pack_opt_t *options); /* repack options */ int has_filter(hid_t dcpl_id, H5Z_filter_t filtnin); diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index aeeded0..c015f0a 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -259,7 +259,6 @@ int do_copy_objects(hid_t fidin, #endif /* LATER */ int i, j; int wrote=0; - int has_layout; /*------------------------------------------------------------------------- * copy the suppplied object list @@ -270,7 +269,6 @@ int do_copy_objects(hid_t fidin, { buf=NULL; - has_layout=0; switch ( travt->objs[i].type ) { /*------------------------------------------------------------------------- @@ -359,9 +357,6 @@ int do_copy_objects(hid_t fidin, */ if ( (H5T_REFERENCE!=H5Tget_class(mtype_id))) { - /* the information about the object to be filtered/"layouted" */ - pack_info_t obj; - init_packobject(&obj); /* get the storage size of the input dataset */ dsize_in=H5Dget_storage_size(dset_in); @@ -379,24 +374,12 @@ int do_copy_objects(hid_t fidin, } if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) goto error; - - /*------------------------------------------------------------------------- - * apply the layout; check first if the object is to be modified. - *------------------------------------------------------------------------- - */ - if (layout_this(dcpl_id,travt->objs[i].name,options,&obj)) - { - obj.chunk.rank=rank; - if (apply_layout(dcpl_id,&obj)<0) - goto error; - has_layout=1; - } - + /*------------------------------------------------------------------------- - * apply the filter; check if the object is to be filtered. + * apply the filter *------------------------------------------------------------------------- */ - if (apply_filters(travt->objs[i].name,rank,dims,dcpl_id,mtype_id,options,has_layout,&obj)<0) + if (apply_filters(travt->objs[i].name,rank,dims,dcpl_id,mtype_id,options)<0) goto error; }/*nelmts*/ diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 5056a3f..204e410 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -18,79 +18,160 @@ /*------------------------------------------------------------------------- - * Function: aux_objinsert_filter + * Function: aux_find_obj * - * Purpose: auxiliary function, inserts the filter in object OBJ - * - * Return: void + * Purpose: find the object name NAME (got from the traverse list) + * in the repack options list * *------------------------------------------------------------------------- */ -static void aux_objinsert_filter(pack_info_t *obj, - filter_info_t filt) +static +int aux_find_obj(const char* name, /* object name from traverse list */ + pack_opt_t *options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { - obj->nfilters=1; - obj->filter[0]=filt; - + char *pdest; + int result; + int i; + + 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 i; + } + + 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 i; + } + }/*i*/ + + return -1; } + /*------------------------------------------------------------------------- - * Function: filter_this + * Function: aux_assign_obj * * 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 - * *------------------------------------------------------------------------- */ -int filter_this(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static +int aux_assign_obj(const char* name, /* object name from traverse list */ + pack_opt_t *options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { - char *pdest; - int result; - int i, j; - - /* 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 */ - aux_objinsert_filter( obj, options->filter_g ); - obj->chunk=options->chunk_g; - return 1; - } - - for ( i=0; i<options->op_tbl->nelems; i++) - { - for ( j=0; j<options->op_tbl->objs[i].nfilters; j++) - { - if (options->op_tbl->objs[i].filter[j].filtn != -1 ) - { - 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; - } - } /*if*/ - }/*j*/ - }/*i*/ + + int index, i; + pack_info_t tmp; + + init_packobject(&tmp); + + index = aux_find_obj(name,options,&tmp); + + /* name was on input */ + if (index>=0) + { + + /* applying to all objects */ + if (options->all_layout) + { + /* assign the global layout info to the OBJ info */ + tmp.layout=options->layout_g; + switch (options->layout_g) + { + case H5D_CHUNKED: + tmp.chunk.rank=options->chunk_g.rank; + for ( i=0; i<tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i]=options->chunk_g.chunk_lengths[i]; + break; + default: + break; + }/*switch*/ + } + else + { + tmp.layout = options->op_tbl->objs[index].layout; + switch (tmp.layout) + { + case H5D_CHUNKED: + tmp.chunk.rank = options->op_tbl->objs[index].chunk.rank; + for ( i=0; i<tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i]=options->op_tbl->objs[index].chunk.chunk_lengths[i]; + break; + default: + break; + }/*switch*/ + + } + + /* applying to all objects */ + if (options->all_filter) + { + /* assign the global filter */ + tmp.nfilters=1; + tmp.filter[0]=options->filter_g; + } /* if all */ + else + { + tmp.nfilters=options->op_tbl->objs[index].nfilters; + for ( i=0; i<tmp.nfilters; i++) + { + tmp.filter[i] = options->op_tbl->objs[index].filter[i]; + } + } + + + } /* if index */ + + + /* no input name */ + + else + { + + if (options->all_filter) + { + /* assign the global filter */ + tmp.nfilters=1; + tmp.filter[0]=options->filter_g; + } + + + if (options->all_layout) + { + /* assign the global layout info to the OBJ info */ + tmp.layout=options->layout_g; + switch (options->layout_g) + { + case H5D_CHUNKED: + tmp.chunk.rank=options->chunk_g.rank; + for ( i=0; i<tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i]=options->chunk_g.chunk_lengths[i]; + break; + default: + break; + }/*switch*/ + + } + + + } - return 0; + *obj = tmp; + return 1; + } @@ -115,37 +196,31 @@ int apply_filters(const char* name, /* object name from traverse list */ hsize_t *dims, /* dimensions of dataset */ hid_t dcpl_id, /* dataset creation property list */ hid_t type_id, /* dataset datatype */ - pack_opt_t *options, /* repack options */ - int has_layout, /* input chunk */ - pack_info_t *obj) /* info about object to filter */ -{ - int nfilters; /* number of filters in DCPL */ + pack_opt_t *options) /* repack options */ +{ + int nfilters; /* number of filters in DCPL */ unsigned aggression; /* the deflate level */ hsize_t nelmts; /* number of elements in dataset */ size_t size; /* size of datatype in bytes */ int i; - - /* check first if the object is to be filtered */ - if (filter_this(name,options,obj)==0) - return 0; - + pack_info_t obj; + if (rank==0) goto out; /*------------------------------------------------------------------------- - * filters require CHUNK layout; if we do not have one define a default + * initialize the assigment object *------------------------------------------------------------------------- */ - if (has_layout) - { - layout_this(dcpl_id,name,options,obj); - } - else - { - obj->chunk.rank=rank; - for (i=0; i<rank; i++) - obj->chunk.chunk_lengths[i] = dims[i]; - } + init_packobject(&obj); + + +/*------------------------------------------------------------------------- + * find options + *------------------------------------------------------------------------- + */ + if (aux_assign_obj(name,options,&obj)==0) + return 0; /* check for datasets too small */ @@ -175,8 +250,6 @@ int apply_filters(const char* name, /* object name from traverse list */ return -1; } - - /*------------------------------------------------------------------------- * the type of filter and additional parameter * type can be one of the filters @@ -187,9 +260,24 @@ int apply_filters(const char* name, /* object name from traverse list */ * H5Z_FILTER_SZIP 4 , szip compression *------------------------------------------------------------------------- */ - for ( i=0; i<obj->nfilters; i++) + + if (obj.nfilters) + { + +/*------------------------------------------------------------------------- + * filters require CHUNK layout; if we do not have one define a default + *------------------------------------------------------------------------- + */ + if (obj.layout==-1) + { + obj.chunk.rank=rank; + for (i=0; i<rank; i++) + obj.chunk.chunk_lengths[i] = dims[i]; + } + + for ( i=0; i<obj.nfilters; i++) { - switch (obj->filter[i].filtn) + switch (obj.filter[i].filtn) { default: break; @@ -199,9 +287,9 @@ int apply_filters(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ case H5Z_FILTER_DEFLATE: - aggression=obj->filter[i].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) + if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) return -1; if(H5Pset_deflate(dcpl_id,aggression)<0) return -1; @@ -216,14 +304,14 @@ int apply_filters(const char* name, /* object name from traverse list */ unsigned options_mask; unsigned pixels_per_block; - pixels_per_block=obj->filter[i].cd_values[0]; - if (obj->filter[i].szip_coding==0) + pixels_per_block=obj.filter[i].cd_values[0]; + if (obj.filter[i].szip_coding==0) options_mask=H5_SZIP_NN_OPTION_MASK; else options_mask=H5_SZIP_EC_OPTION_MASK; /* set up for szip data */ - if(H5Pset_chunk(dcpl_id,obj->chunk.rank,obj->chunk.chunk_lengths)<0) + if(H5Pset_chunk(dcpl_id,obj.chunk.rank,obj.chunk.chunk_lengths)<0) return -1; if (H5Pset_szip(dcpl_id,options_mask,pixels_per_block)<0) return -1; @@ -236,7 +324,7 @@ int apply_filters(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ case H5Z_FILTER_SHUFFLE: - if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) + if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) return -1; if (H5Pset_shuffle(dcpl_id)<0) return -1; @@ -247,7 +335,7 @@ int apply_filters(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ case H5Z_FILTER_FLETCHER32: - if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) + if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) return -1; if (H5Pset_fletcher32(dcpl_id)<0) return -1; @@ -255,6 +343,32 @@ int apply_filters(const char* name, /* object name from traverse list */ } /* switch */ }/*i*/ + } + /*obj.nfilters*/ + else + { + /* just apply layout */ + + /* no layout info was found, define the default */ + if (obj.layout==-1) + obj.layout = H5D_CONTIGUOUS; + + + if (H5Pset_layout(dcpl_id, obj.layout)<0) + return -1; + + if (H5D_CHUNKED==obj.layout) { /* set up chunk */ + if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) + return -1; + } + else if (H5D_COMPACT==obj.layout) { + if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0) + return -1; + } + + + } + return 0; out: @@ -264,6 +378,7 @@ out: } + /*------------------------------------------------------------------------- * Function: print_filters * @@ -271,10 +386,6 @@ out: * * Return: 0, ok, -1 no * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 19, 2003 - * *------------------------------------------------------------------------- */ diff --git a/tools/h5repack/h5repack_layout.c b/tools/h5repack/h5repack_layout.c deleted file mode 100644 index 1cf1680..0000000 --- a/tools/h5repack/h5repack_layout.c +++ /dev/null @@ -1,175 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "hdf5.h" -#include "h5test.h" -#include "h5repack.h" - - -static void CANNOT_LAYOUT(pack_opt_t *options) -{ - if (options->verbose) - printf("Warning: This layout cannot be applied, this object\ - requires chunked layout\n"); -} - - - -/*------------------------------------------------------------------------- - * Function: layout_this - * - * Purpose: check if the layout can be applied; - * find the object name NAME (got from the traverse list) - * in the repack options list; assign the layout information OBJ - * - * Return: 0 cannot apply, 1 can, -1 error - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 30, 2003 - * - *------------------------------------------------------------------------- - */ - -int layout_this(hid_t dcpl_id, /* DCPL from input object */ - const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *pack /*OUT*/) /* object to apply layout */ -{ - int nfilters; /* number of filters in the input object */ - H5D_layout_t layout; /* layout */ - char *pdest; - int result; - int i, ret=1; - - /* check if we have filters in the input object */ - if ((nfilters = H5Pget_nfilters(dcpl_id))<0) - return -1; - - /* applying to all objects */ - if (options->all_layout) - { - /* assign the global layout info to the OBJ info */ - pack->layout=options->layout_g; - - switch (options->layout_g) - { - case H5D_CHUNKED: - pack->chunk.rank=options->chunk_g.rank; - for ( i=0; i<pack->chunk.rank; i++) - pack->chunk.chunk_lengths[i]=options->chunk_g.chunk_lengths[i]; - break; - - case H5D_CONTIGUOUS: - case H5D_COMPACT: - if (nfilters) - { - CANNOT_LAYOUT(options); - ret=0; - } - break; - - default: - ret=0; - break; - }/*switch*/ - return ret; - } - - /* find the object */ - for ( i=0; i<options->op_tbl->nelems; i++) - { - layout=options->op_tbl->objs[i].layout; - if ( layout != -1 ) - { - if (strcmp(options->op_tbl->objs[i].path,name)==0) - { - if (nfilters && layout!=H5D_CHUNKED) - { - CANNOT_LAYOUT(options); - return 0; - } - else - { - *pack=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 ) - { - if (nfilters && layout!=H5D_CHUNKED) - { - CANNOT_LAYOUT(options); - return 0; - } - else - { - *pack=options->op_tbl->objs[i]; - return 1; - } - } - } - } - - return 0; -} -/*------------------------------------------------------------------------- - * Function: apply_layout - * - * Purpose: apply a layout to the property list. Valid values for layout are: - * - * H5D_COMPACT - * Store raw data in the dataset object header in file. - * This should only be used for very small amounts of raw data. - * H5D_CONTIGUOUS - * Store raw data separately from the object header in one large chunk - * in the file. - * H5D_CHUNKED - * Store raw data separately from the object header as chunks of data in - * separate locations in the file. - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 30, 2003 - * - *------------------------------------------------------------------------- - */ - -int apply_layout(hid_t dcpl_id, - pack_info_t *obj) /* info about object */ -{ - - - if (H5Pset_layout(dcpl_id, obj->layout)<0) - return -1; - - if (H5D_CHUNKED==obj->layout) { /* set up chunk */ - if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) - return -1; - } - else if (H5D_COMPACT==obj->layout) { - if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0) - return -1; - } - - return 0; -} - |