2
0
mirror of https://github.com/HDFGroup/hdf5.git synced 2025-03-01 16:28:09 +08:00

[svn-r12581] Description:

Bug fix and maintenance
  Checked in James fix and did more code refactoring.

Platforms tested: heping, copper and shanti (and X1 for the bug fix)
This commit is contained in:
Elena Pourmal 2006-08-16 17:45:56 -05:00
parent b018e9589e
commit a0591aaf96

View File

@ -341,12 +341,11 @@ fix_name(const char *path, const char *base)
s[len] = '\0';
return s;
}
/*-------------------------------------------------------------------------
* Function: walk
* Function: group_stats
*
* Purpose: Gather statistics about the file
* Purpose: Gather statistics about the group
*
* Return: Success: 0
*
@ -355,46 +354,24 @@ fix_name(const char *path, const char *base)
* Programmer: Quincey Koziol
* Tuesday, August 16, 2005
*
* Modifications:
* Modifications: Refactored code from the walk_function
* EIP, Wednesday, August 16, 2006
*
*-------------------------------------------------------------------------
*/
static herr_t
walk (hid_t group, const char *name, void *_iter)
group_stats (hid_t group, const char *name, const char * fullname, H5G_stat_t * _sb, H5G_iterate_t _walk, iter_t *_iter)
{
char *fullname = NULL;
char *s;
H5G_stat_t sb;
iter_t *iter = (iter_t*)_iter;
herr_t ret; /* Generic return value */
/* Get the full object name */
fullname = fix_name(iter->container, name);
/*
printf("walk: fullname = %s\n", fullname);
*/
/* Get object information */
ret = H5Gget_objinfo(group, name, FALSE, &sb);
assert(ret >= 0);
/* If the object has already been printed then just show the object ID
* and return. */
if ((s=sym_lookup(&sb))) {
printf("same as %s", s);
} else {
sym_insert(&sb, fullname);
/* Gather some statistics about the object */
if(sb.nlink > iter->max_links)
iter->max_links = sb.nlink;
switch(sb.type) {
case H5G_GROUP:
{
hid_t gid; /* Group ID */
const char *last_container;
hsize_t num_objs;
unsigned bin; /* "bin" the number of objects falls in */
iter_t *iter = (iter_t*)_iter;
H5G_stat_t *sb = _sb;
H5G_iterate_t walk = _walk;
herr_t ret;
/* Gather statistics about this type of object */
iter->uniq_groups++;
@ -402,8 +379,8 @@ printf("walk: fullname = %s\n", fullname);
iter->max_depth = iter->curr_depth;
/* Get object header information */
iter->group_ohdr_info.total_size += sb.ohdr.size;
iter->group_ohdr_info.free_size += sb.ohdr.free;
iter->group_ohdr_info.total_size += sb->ohdr.size;
iter->group_ohdr_info.free_size += sb->ohdr.free;
gid = H5Gopen(group, name);
assert(gid > 0);
@ -444,18 +421,45 @@ printf("walk: fullname = %s\n", fullname);
iter->container = last_container;
iter->curr_depth--;
} /* end case */
break;
case H5G_DATASET:
{
return 0;
}
/*-------------------------------------------------------------------------
* Function: dataset_stats
*
* Purpose: Gather statistics about the datset
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Quincey Koziol
* Tuesday, August 16, 2005
*
* Modifications: Refactored code from the walk_function
* EIP, Wednesday, August 16, 2006
*
*-------------------------------------------------------------------------
*/
static herr_t
dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter)
{
unsigned bin; /* "bin" the number of objects falls in */
iter_t *iter = (iter_t*)_iter;
H5G_stat_t *sb = _sb;
herr_t ret;
hid_t did; /* Dataset ID */
hid_t sid; /* Dataspace ID */
hid_t tid; /* Datatype ID */
hid_t dcpl; /* Dataset creation property list ID */
hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataset */
H5D_layout_t lout; /* Layout of dataset */
unsigned type_found; /* Whether the dataset's datatype was already found */
unsigned type_found; /* Whether the dataset's datatype was */
/* already found */
int ndims; /* Number of dimensions of dataset */
hsize_t storage; /* Size of dataset storage */
unsigned u; /* Local index variable */
@ -467,8 +471,8 @@ printf("walk: fullname = %s\n", fullname);
iter->uniq_dsets++;
/* Get object header information */
iter->dset_ohdr_info.total_size += sb.ohdr.size;
iter->dset_ohdr_info.free_size += sb.ohdr.free;
iter->dset_ohdr_info.total_size += sb->ohdr.size;
iter->dset_ohdr_info.free_size += sb->ohdr.free;
did = H5Dopen(group, name);
assert(did > 0);
@ -493,14 +497,13 @@ printf("walk: fullname = %s\n", fullname);
/* Only gather dim size statistics on 1-D datasets */
if(ndims == 1) {
unsigned bin; /* "bin" the number of objects falls in */
if(dims[0] > iter->max_dset_dims)
iter->max_dset_dims = dims[0];
if(dims[0] < SIZE_SMALL_DSETS)
(iter->small_dset_dims[dims[0]])++;
/* Add group count to proper bin */
/* Add dim count to proper bin */
bin = ceil_log10((unsigned long)dims[0]);
if((bin + 1) > iter->dset_dim_nbins) {
/* Allocate more storage for info about dataset's datatype */
@ -583,7 +586,7 @@ printf("walk: fullname = %s\n", fullname);
if ((nfltr=H5Pget_nfilters(dcpl)) >= 0) {
if (nfltr == 0) iter->dset_comptype[0]++;
for (u=0; u < nfltr; u++) {
for (u=0; u < (unsigned) nfltr; u++) {
fltr = H5Pget_filter(dcpl, u, 0, 0, 0, 0, 0, NULL);
if (fltr < (H5_NFILTERS_IMPL-1))
iter->dset_comptype[fltr]++;
@ -598,7 +601,63 @@ printf("walk: fullname = %s\n", fullname);
ret = H5Dclose(did);
assert(ret >= 0);
} /* end case */
return 0;
}
/*-------------------------------------------------------------------------
* Function: walk
*
* Purpose: Gather statistics about the file
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Quincey Koziol
* Tuesday, August 16, 2005
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
walk (hid_t group, const char *name, void *_iter)
{
char *fullname = NULL;
char *s;
H5G_stat_t sb;
iter_t *iter = (iter_t*)_iter;
herr_t ret; /* Generic return value */
/* Get the full object name */
fullname = fix_name(iter->container, name);
/*
printf("walk: fullname = %s\n", fullname);
*/
/* Get object information */
ret = H5Gget_objinfo(group, name, FALSE, &sb);
assert(ret >= 0);
/* If the object has already been printed then just show the object ID
* and return. */
if ((s=sym_lookup(&sb))) {
printf("same as %s", s);
} else {
sym_insert(&sb, fullname);
/* Gather some statistics about the object */
if(sb.nlink > iter->max_links)
iter->max_links = sb.nlink;
switch(sb.type) {
case H5G_GROUP:
group_stats(group, name, fullname, &sb, walk, iter);
break;
case H5G_DATASET:
dataset_stats(group, name, &sb, iter);
break;
case H5G_TYPE:
@ -607,7 +666,6 @@ printf("walk: fullname = %s\n", fullname);
break;
case H5G_LINK:
case H5G_UDLINK:
/* Gather statistics about links and UD links */
iter->uniq_links++;
break;
@ -650,7 +708,6 @@ parse_command_line(int argc, const char *argv[])
/* parse command line options */
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
parse_start:
switch ((char)opt) {
case 'F':
display_all = FALSE;
@ -694,13 +751,13 @@ parse_start:
}
}
parse_end:
/* check for file name to be processed */
if (argc <= opt_ind) {
error_msg(progname, "missing file name\n");
usage(progname);
leave(EXIT_FAILURE);
}
return 0;
}
@ -1023,9 +1080,9 @@ print_dataset_info(iter_t * _iter)
*-------------------------------------------------------------------------
*/
static herr_t
print_statistics(iter_t ** _iter)
print_statistics(iter_t * _iter)
{
iter_t *iter = (iter_t**)_iter;
iter_t *iter = (iter_t*)_iter;
herr_t ret =0; /* Generic return value */
if(display_all) {
@ -1059,6 +1116,11 @@ main(int argc, const char *argv[])
/* Initialize h5tools lib */
h5tools_init();
status = parse_command_line (argc, argv);
if (status < 0) {
error_msg(progname, "unable to parse command line arguments \n");
leave(EXIT_FAILURE);
}
fname = argv[opt_ind];
printf("Filename: %s\n", fname);