mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r8040] Purpose:
bug fix, code improvment Description: fixed a bug in the parse of chunking function added some auxiliary functions to avoid repeated parts of the code in several places Solution: Platforms tested: linux solaris AIX Misc. update:
This commit is contained in:
parent
feaa5bb9d5
commit
be7ebb248f
@ -178,8 +178,10 @@ int h5repack_addlayout(const char* str,
|
||||
|
||||
obj_list_t *obj_list=NULL; /*one object list for the -t and -c option entry */
|
||||
int n_objs; /*number of objects in the current -t or -c option entry */
|
||||
int j;
|
||||
pack_info_t pack; /*info about layout to extract from parse */
|
||||
int j;
|
||||
|
||||
init_packobject(&pack);
|
||||
|
||||
if (options->all_layout==1){
|
||||
printf("Error: Invalid layout input: all option \
|
||||
|
@ -175,6 +175,10 @@ int do_copy_refobjs_inattr(hid_t loc_in,
|
||||
void read_info(const char *filename,pack_opt_t *options);
|
||||
void close_obj(H5G_obj_t obj_type, hid_t obj_id);
|
||||
|
||||
void init_packobject(pack_info_t *obj);
|
||||
int print_filters(hid_t dcpl_id);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* filters
|
||||
|
@ -231,6 +231,9 @@ int do_copy_file(hid_t fidin,
|
||||
if ((msize=H5Tget_size(mtype_id))==0)
|
||||
goto error;
|
||||
|
||||
if (options->verbose)
|
||||
print_filters(dcpl_id);
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* object references are a special case
|
||||
@ -243,6 +246,7 @@ int do_copy_file(hid_t fidin,
|
||||
|
||||
/* 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);
|
||||
@ -278,6 +282,13 @@ int do_copy_file(hid_t fidin,
|
||||
*/
|
||||
if (filter_this(travt->objs[i].name,options,&obj))
|
||||
{
|
||||
/* filters require CHUNK layout; if we do not have one define a default */
|
||||
if (obj.chunk.rank==0)
|
||||
{
|
||||
obj.chunk.rank=rank;
|
||||
for (j=0; j<rank; j++)
|
||||
obj.chunk.chunk_lengths[j] = dims[j] / 2;
|
||||
}
|
||||
if (apply_filters(dcpl_id,H5Tget_size(mtype_id),options,&obj)<0)
|
||||
continue;
|
||||
}
|
||||
|
@ -29,13 +29,6 @@
|
||||
static void aux_objinsert_filter(pack_info_t *obj,
|
||||
filter_info_t filt)
|
||||
{
|
||||
int j;
|
||||
|
||||
for ( j=0; j<H5_REPACK_MAX_NFILTERS; j++)
|
||||
{
|
||||
obj->filter[j].filtn = -1;
|
||||
}
|
||||
|
||||
obj->nfilters=1;
|
||||
obj->filter[0]=filt;
|
||||
|
||||
@ -101,6 +94,62 @@ int filter_this(const char* name, /* object name from traverse list */
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: print_filters
|
||||
*
|
||||
* Purpose: print the filters in DCPL
|
||||
*
|
||||
* Return: 0, ok, -1 no
|
||||
*
|
||||
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: December 19, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int print_filters(hid_t dcpl_id)
|
||||
{
|
||||
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 */
|
||||
size_t cd_num; /* filter client data counter */
|
||||
char f_name[256]; /* filter/file name */
|
||||
char s[64]; /* temporary string buffer */
|
||||
int i;
|
||||
|
||||
/* get information about filters */
|
||||
if ((nfilters = H5Pget_nfilters(dcpl_id))<0)
|
||||
return -1;
|
||||
|
||||
for (i=0; i<nfilters; i++)
|
||||
{
|
||||
cd_nelmts = NELMTS(cd_values);
|
||||
filtn = H5Pget_filter(dcpl_id,
|
||||
i,
|
||||
&filt_flags,
|
||||
&cd_nelmts,
|
||||
cd_values,
|
||||
sizeof(f_name),
|
||||
f_name);
|
||||
|
||||
f_name[sizeof(f_name)-1] = '\0';
|
||||
sprintf(s, "Filter-%d:", i);
|
||||
printf(" %-10s %s-%u %s {", s,
|
||||
f_name[0]?f_name:"method",
|
||||
(unsigned)filtn,
|
||||
filt_flags & H5Z_FLAG_OPTIONAL?"OPT":"");
|
||||
for (cd_num=0; cd_num<cd_nelmts; cd_num++) {
|
||||
printf("%s%u", cd_num?", ":"", cd_values[cd_num]);
|
||||
}
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: apply_filters
|
||||
@ -127,9 +176,7 @@ int apply_filters(hid_t dcpl_id,
|
||||
H5Z_filter_t filtn; /* filter identification number */
|
||||
unsigned cd_values[20]; /* filter client data values */
|
||||
size_t cd_nelmts; /* filter client number of values */
|
||||
size_t cd_num; /* filter client data counter */
|
||||
char f_name[256]; /* filter/file name */
|
||||
char s[64]; /* temporary string buffer */
|
||||
int i, j;
|
||||
unsigned aggression; /* the deflate level */
|
||||
unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK;
|
||||
@ -149,22 +196,7 @@ int apply_filters(hid_t dcpl_id,
|
||||
cd_values,
|
||||
sizeof(f_name),
|
||||
f_name);
|
||||
|
||||
if (options->verbose)
|
||||
{
|
||||
f_name[sizeof(f_name)-1] = '\0';
|
||||
sprintf(s, "Filter-%d:", i);
|
||||
printf(" %-10s %s-%u %s {", s,
|
||||
f_name[0]?f_name:"method",
|
||||
(unsigned)filtn,
|
||||
filt_flags & H5Z_FLAG_OPTIONAL?"OPT":"");
|
||||
for (cd_num=0; cd_num<cd_nelmts; cd_num++) {
|
||||
printf("%s%u", cd_num?", ":"", cd_values[cd_num]);
|
||||
}
|
||||
printf("}\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
the type of filter and additional parameter
|
||||
|
@ -22,8 +22,8 @@ static void usage(void);
|
||||
|
||||
/*
|
||||
Examples of use:
|
||||
-v -i file1.h5 -o file2.h5 -t "dataset:GZIP 6" -c "dataset:2x2"
|
||||
-v -i file1.h5 -o file2.h5 -t "GZIP 6"
|
||||
-v -i file1.h5 -o file2.h5 -f "dataset:GZIP 6" -l "dataset:2x2"
|
||||
-v -i file1.h5 -o file2.h5 -f "GZIP 6"
|
||||
*/
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ int main(int argc, char **argv)
|
||||
else if (strcmp(argv[i], "-v") == 0) {
|
||||
options.verbose = 1;
|
||||
}
|
||||
else if (strcmp(argv[i], "-t") == 0) {
|
||||
else if (strcmp(argv[i], "-f") == 0) {
|
||||
|
||||
/* add the -t option */
|
||||
h5repack_addfilter(argv[i+1],&options);
|
||||
@ -56,7 +56,7 @@ int main(int argc, char **argv)
|
||||
/* jump to next */
|
||||
++i;
|
||||
}
|
||||
else if (strcmp(argv[i], "-c") == 0) {
|
||||
else if (strcmp(argv[i], "-l") == 0) {
|
||||
|
||||
/* parse the -c option */
|
||||
h5repack_addlayout(argv[i+1],&options);
|
||||
|
@ -17,6 +17,36 @@
|
||||
#include "h5repack.h"
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: init_packobject
|
||||
*
|
||||
* Purpose: initialize a pack_info_t structure
|
||||
*
|
||||
* Return: void
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void init_packobject(pack_info_t *obj)
|
||||
{
|
||||
int j, k;
|
||||
|
||||
strcpy(obj->path,"\0");
|
||||
for ( j=0; j<H5_REPACK_MAX_NFILTERS; j++)
|
||||
{
|
||||
obj->filter[j].filtn = -1;
|
||||
for ( k=0; k<CDVALUES; k++)
|
||||
obj->filter[j].cd_values[k] = -1;
|
||||
}
|
||||
obj->chunk.rank = -1;
|
||||
obj->refobj_id = -1;
|
||||
obj->layout = -1;
|
||||
obj->nfilters = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: aux_tblinsert_filter
|
||||
*
|
||||
|
@ -399,6 +399,14 @@ obj_list_t* parse_layout(const char *str,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
k=0;
|
||||
|
||||
if (j>(int)len)
|
||||
{
|
||||
if (obj_list) free(obj_list);
|
||||
printf("Parse layout error: <%s> Chunk dimensions missing\n",str);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for ( i=j, c_index=0; i<len; i++)
|
||||
{
|
||||
c = str[i];
|
||||
|
@ -259,6 +259,7 @@ int h5repack_verify(const char *fname,
|
||||
*/
|
||||
if (options->all_layout==1){
|
||||
pack_info_t pack;
|
||||
init_packobject(&pack);
|
||||
pack.layout=options->layout_g;
|
||||
pack.chunk=options->chunk_g;
|
||||
if (has_layout(dcpl_id,&pack)==0)
|
||||
|
Loading…
Reference in New Issue
Block a user