mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-19 16:50:46 +08:00
[svn-r14136] Description:
Move H5Gget_num_objs() and several minor macros, etc. to deprecated symbols section, replacing it with H5Gget_info(). Tested on: FreeBSD/32 6.2 (duty) FreeBSD/64 6.2 (liberty) Linux/32 2.6 (kagiso) Linux/64 2.6 (smirom) AIX/32 5.3 (copper) Solaris/32 5.10 (linew) Mac OS X/32 10.4.10 (amazon)
This commit is contained in:
parent
3eb8c81b80
commit
3bed870363
@ -142,7 +142,7 @@ int main(void)
|
||||
/*
|
||||
* Create hard link to the Data group.
|
||||
*/
|
||||
file->link( H5G_LINK_HARD, "Data", "Data_new" );
|
||||
file->link( H5L_TYPE_HARD, "Data", "Data_new" );
|
||||
|
||||
/*
|
||||
* We can access "Compressed_Data" dataset using created
|
||||
|
@ -981,13 +981,14 @@ int CommonFG::iterateElems( const H5std_string& name, int *idx, H5G_iterate_t op
|
||||
//--------------------------------------------------------------------------
|
||||
hsize_t CommonFG::getNumObjs() const
|
||||
{
|
||||
hsize_t num_objs;
|
||||
herr_t ret_value = H5Gget_num_objs(getLocId(), &num_objs);
|
||||
H5G_info_t ginfo; /* Group information */
|
||||
|
||||
herr_t ret_value = H5Gget_info(getLocId(), ".", &ginfo, H5P_DEFAULT);
|
||||
if(ret_value < 0)
|
||||
{
|
||||
throwException("getNumObjs", "H5Gget_num_objs failed");
|
||||
throwException("getNumObjs", "H5Gget_info failed");
|
||||
}
|
||||
return (num_objs);
|
||||
return (ginfo.nlinks);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1118,3 +1119,4 @@ CommonFG::~CommonFG() {}
|
||||
#ifndef H5_NO_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -197,7 +197,7 @@ DONE:
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Name: h5gn_members_c
|
||||
* Purpose: Call H5Gn_members to find number of objects in the group
|
||||
* Purpose: Call H5Gget_num_objs to find number of objects in the group
|
||||
* Inputs: loc_id - file or group identifier
|
||||
* name - name of the group
|
||||
* namelen - name length
|
||||
@ -211,8 +211,7 @@ int_f
|
||||
nh5gn_members_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *nmembers)
|
||||
{
|
||||
char *c_name = NULL;
|
||||
hsize_t c_nmembers;
|
||||
hid_t gid = (-1);
|
||||
H5G_info_t ginfo;
|
||||
int ret_value = -1;
|
||||
|
||||
/*
|
||||
@ -221,22 +220,14 @@ nh5gn_members_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *nmembers)
|
||||
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
|
||||
goto DONE;
|
||||
|
||||
/* Get a temporary group ID for the group to query */
|
||||
if((gid = H5Gopen2((hid_t)*loc_id, c_name, H5P_DEFAULT)) < 0)
|
||||
/* Call H5Gget_info() for the number of objects in the group */
|
||||
if(H5Gget_info((hid_t)*loc_id, c_name, &ginfo, H5P_DEFAULT) < 0)
|
||||
goto DONE;
|
||||
|
||||
/* Call H5Gget_num_objs() for the number of objects in the group */
|
||||
if(H5Gget_num_objs(gid, &c_nmembers) < 0)
|
||||
goto DONE;
|
||||
|
||||
*nmembers = (int_f)c_nmembers;
|
||||
*nmembers = (int_f)ginfo.nlinks;
|
||||
ret_value = 0;
|
||||
|
||||
DONE:
|
||||
/* Close the temporary group, if it was opened */
|
||||
if(gid > 0)
|
||||
H5Gclose(gid);
|
||||
|
||||
if(c_name)
|
||||
HDfree(c_name);
|
||||
return ret_value;
|
||||
|
@ -787,6 +787,56 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Giterate() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Gget_num_objs
|
||||
*
|
||||
* Purpose: Returns the number of objects in the group. It iterates
|
||||
* all B-tree leaves and sum up total number of group members.
|
||||
*
|
||||
* Note: Deprecated in favor of H5Gget_info
|
||||
*
|
||||
* Return: Success: Non-negative
|
||||
* Failure: Negative
|
||||
*
|
||||
* Programmer: Raymond Lu
|
||||
* Nov 20, 2002
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs)
|
||||
{
|
||||
H5G_loc_t loc; /* Location of object */
|
||||
H5G_info_t grp_info; /* Group information */
|
||||
H5O_type_t obj_type; /* Type of object at location */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_API(H5Gget_num_objs, FAIL)
|
||||
H5TRACE2("e", "i*h", loc_id, num_objs);
|
||||
|
||||
/* Check args */
|
||||
if(H5G_loc(loc_id, &loc) < 0)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
|
||||
if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
|
||||
if(obj_type != H5O_TYPE_GROUP)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
|
||||
if(!num_objs)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects")
|
||||
|
||||
/* Retrieve information about the group */
|
||||
if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine")
|
||||
|
||||
/* Set the number of objects [sic: links] in the group */
|
||||
*num_objs = grp_info.nlinks;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Gget_num_objs() */
|
||||
|
||||
#endif /* H5_NO_DEPRECATED_SYMBOLS */
|
||||
|
||||
|
||||
@ -1022,52 +1072,3 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5G_get_objinfo() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Gget_num_objs
|
||||
*
|
||||
* Purpose: Returns the number of objects in the group. It iterates
|
||||
* all B-tree leaves and sum up total number of group members.
|
||||
*
|
||||
* Note: Deprecated in favor of H5Gget_info
|
||||
*
|
||||
* Return: Success: Non-negative
|
||||
* Failure: Negative
|
||||
*
|
||||
* Programmer: Raymond Lu
|
||||
* Nov 20, 2002
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs)
|
||||
{
|
||||
H5G_loc_t loc; /* Location of object */
|
||||
H5G_info_t grp_info; /* Group information */
|
||||
H5O_type_t obj_type; /* Type of object at location */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_API(H5Gget_num_objs, FAIL)
|
||||
H5TRACE2("e", "i*h", loc_id, num_objs);
|
||||
|
||||
/* Check args */
|
||||
if(H5G_loc(loc_id, &loc) < 0)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
|
||||
if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
|
||||
if(obj_type != H5O_TYPE_GROUP)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
|
||||
if(!num_objs)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects")
|
||||
|
||||
/* Retrieve information about the group */
|
||||
if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine")
|
||||
|
||||
/* Set the number of objects [sic: links] in the group */
|
||||
*num_objs = grp_info.nlinks;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Gget_num_objs() */
|
||||
|
||||
|
@ -133,7 +133,6 @@ H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name,
|
||||
H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx);
|
||||
H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name,
|
||||
hbool_t follow_link, H5G_stat_t *statbuf/*out*/);
|
||||
H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs);
|
||||
/* Symbols defined for compatibility with previous versions of the HDF5 API.
|
||||
*
|
||||
* Use of these symbols is deprecated.
|
||||
@ -175,6 +174,7 @@ H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize,
|
||||
char *buf);
|
||||
H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx,
|
||||
H5G_iterate_t op, void *op_data);
|
||||
H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs);
|
||||
|
||||
#endif /* H5_NO_DEPRECATED_SYMBOLS */
|
||||
|
||||
|
@ -4947,7 +4947,7 @@ run_int_fp_conv(const char *name)
|
||||
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_LDOUBLE);
|
||||
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_LDOUBLE);
|
||||
#endif
|
||||
#ifdef H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
|
||||
#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
|
||||
#if H5_LLONG_TO_LDOUBLE_CORRECT
|
||||
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_LDOUBLE);
|
||||
#else /* H5_LLONG_TO_LDOUBLE_CORRECT */
|
||||
@ -5071,7 +5071,7 @@ run_fp_int_conv(const char *name)
|
||||
nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG);
|
||||
#endif
|
||||
|
||||
#ifdef H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
|
||||
#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
|
||||
if(!strcmp(name, "hw")) { /* Hardware conversion */
|
||||
/* Windows .NET 2003 doesn't work for hardware conversion of this case.
|
||||
* .NET should define this macro H5_HW_FP_TO_LLONG_NOT_WORKS. */
|
||||
|
@ -1476,6 +1476,7 @@ test_compat(hid_t fapl, hbool_t new_format)
|
||||
hid_t group1_id = -1;
|
||||
hid_t group2_id = -1;
|
||||
H5G_stat_t sb_hard1, sb_hard2, sb_soft1;
|
||||
hsize_t num_objs; /* Number of objects in a group */
|
||||
char filename[1024];
|
||||
char linkval[1024];
|
||||
|
||||
@ -1503,6 +1504,12 @@ test_compat(hid_t fapl, hbool_t new_format)
|
||||
if(H5Glink2(file_id, "group1", H5G_LINK_HARD, group2_id, "link_to_group1") < 0) FAIL_STACK_ERROR
|
||||
if(H5Glink2(file_id, "link_to_group1", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/soft_link_to_group1") < 0) FAIL_STACK_ERROR
|
||||
|
||||
/* Test getting the number of objects in a group */
|
||||
if(H5Gget_num_objs(file_id, &num_objs) < 0) FAIL_STACK_ERROR
|
||||
if(num_objs != 2) TEST_ERROR
|
||||
if(H5Gget_num_objs(group1_id, &num_objs) < 0) FAIL_STACK_ERROR
|
||||
if(num_objs != 1) TEST_ERROR
|
||||
|
||||
/* Test that H5Glink created hard links properly */
|
||||
if(H5Gget_objinfo(file_id, "/group2", TRUE, &sb_hard1) < 0) FAIL_STACK_ERROR
|
||||
if(H5Gget_objinfo(file_id, "/group1/link_to_group2", TRUE, &sb_hard2) < 0) FAIL_STACK_ERROR
|
||||
@ -1556,7 +1563,7 @@ test_compat(hid_t fapl, hbool_t new_format)
|
||||
if(H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT) >=0) TEST_ERROR
|
||||
} H5E_END_TRY;
|
||||
|
||||
if(H5Fclose(file_id) < 0) TEST_ERROR
|
||||
if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
@ -1242,8 +1242,8 @@ error:
|
||||
static int
|
||||
compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
|
||||
{
|
||||
hsize_t num_objs; /* Number of objects in group */
|
||||
hsize_t num_objs2; /* Number of objects in group */
|
||||
H5G_info_t ginfo; /* Group info struct */
|
||||
H5G_info_t ginfo2; /* Group info struct */
|
||||
hsize_t idx; /* Index over the objects in group */
|
||||
unsigned cpy_flags; /* Object copy flags */
|
||||
|
||||
@ -1255,17 +1255,17 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
|
||||
cpy_flags = 0;
|
||||
|
||||
/* Check if both groups have the same # of objects */
|
||||
if(H5Gget_num_objs(gid, &num_objs) < 0) TEST_ERROR
|
||||
if(H5Gget_num_objs(gid2, &num_objs2) < 0) TEST_ERROR
|
||||
if(H5Gget_info(gid, ".", &ginfo, H5P_DEFAULT) < 0) TEST_ERROR
|
||||
if(H5Gget_info(gid2, ".", &ginfo2, H5P_DEFAULT) < 0) TEST_ERROR
|
||||
if((cpy_flags & H5O_COPY_SHALLOW_HIERARCHY_FLAG) && depth == 0) {
|
||||
if(num_objs2 != 0) TEST_ERROR
|
||||
if(ginfo2.nlinks != 0) TEST_ERROR
|
||||
} /* end if */
|
||||
else {
|
||||
if(num_objs != num_objs2) TEST_ERROR
|
||||
if(ginfo.nlinks != ginfo2.nlinks) TEST_ERROR
|
||||
} /* end if */
|
||||
|
||||
/* Check contents of groups */
|
||||
if(num_objs2 > 0) {
|
||||
if(ginfo2.nlinks > 0) {
|
||||
char objname[NAME_BUF_SIZE]; /* Name of object in group */
|
||||
char objname2[NAME_BUF_SIZE]; /* Name of object in group */
|
||||
H5G_obj_t objtype; /* Type of object in group */
|
||||
@ -1277,7 +1277,7 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
|
||||
hid_t oid, oid2; /* IDs of objects within group */
|
||||
|
||||
/* Loop over contents of groups */
|
||||
for(idx = 0; idx < num_objs; idx++) {
|
||||
for(idx = 0; idx < ginfo.nlinks; idx++) {
|
||||
/* Check name of objects */
|
||||
if(H5Gget_objname_by_idx(gid, idx, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
|
||||
if(H5Gget_objname_by_idx(gid2, idx, objname2, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
|
||||
|
16
test/th5o.c
16
test/th5o.c
@ -47,7 +47,7 @@ test_h5o_open(void)
|
||||
hid_t grp, dset, dtype, dspace; /* Object identifiers */
|
||||
hsize_t dims[RANK];
|
||||
H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
|
||||
hsize_t num_objs = 0; /* Number of objects in the group */
|
||||
H5G_info_t ginfo; /* Group info struct */
|
||||
H5T_class_t type_class; /* Class of the datatype */
|
||||
herr_t ret; /* Value returned from API calls */
|
||||
|
||||
@ -102,9 +102,9 @@ test_h5o_open(void)
|
||||
VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID");
|
||||
|
||||
/* Do something more complex with each of the IDs to make sure they "work" */
|
||||
ret = H5Gget_num_objs(grp, &num_objs);
|
||||
CHECK(ret, FAIL, "H5Gget_num_objs");
|
||||
VERIFY(num_objs, 1, "H5Gget_num_objs"); /* There should be one object, the datatype */
|
||||
ret = H5Gget_info(grp, ".", &ginfo, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Gget_info");
|
||||
VERIFY(ginfo.nlinks, 1, "H5Gget_info"); /* There should be one object, the datatype */
|
||||
|
||||
type_class = H5Tget_class(dtype);
|
||||
VERIFY(type_class, H5T_INTEGER, "H5Tget_class");
|
||||
@ -249,7 +249,7 @@ test_h5o_open_by_addr(void)
|
||||
haddr_t dtype_addr;
|
||||
hsize_t dims[RANK];
|
||||
H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
|
||||
hsize_t num_objs = 0; /* Number of objects in the group */
|
||||
H5G_info_t ginfo; /* Group info struct */
|
||||
H5T_class_t type_class; /* Class of the datatype */
|
||||
herr_t ret; /* Value returned from API calls */
|
||||
|
||||
@ -315,9 +315,9 @@ test_h5o_open_by_addr(void)
|
||||
VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID");
|
||||
|
||||
/* Do something more complex with each of the IDs to make sure they "work" */
|
||||
ret = H5Gget_num_objs(grp, &num_objs);
|
||||
CHECK(ret, FAIL, "H5Gget_num_objs");
|
||||
VERIFY(num_objs, 1, "H5Gget_num_objs"); /* There should be one object, the datatype */
|
||||
ret = H5Gget_info(grp, ".", &ginfo, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Gget_info");
|
||||
VERIFY(ginfo.nlinks, 1, "H5Gget_info"); /* There should be one object, the datatype */
|
||||
|
||||
type_class = H5Tget_class(dtype);
|
||||
VERIFY(type_class, H5T_INTEGER, "H5Tget_class");
|
||||
|
@ -132,7 +132,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
|
||||
char *lnames[NDATASETS + 2];/* Names of the links created */
|
||||
char dataset_name[NAMELEN]; /* dataset name */
|
||||
iter_info info; /* Custom iteration information */
|
||||
hsize_t num_membs; /* Number of group members */
|
||||
H5G_info_t ginfo; /* Buffer for querying object's info */
|
||||
herr_t ret; /* Generic return value */
|
||||
|
||||
/* Output message about test being performed */
|
||||
@ -203,18 +203,18 @@ test_iter_group(hid_t fapl, hbool_t new_format)
|
||||
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
|
||||
CHECK(file, FAIL, "H5Fopen");
|
||||
|
||||
/* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
|
||||
/* These two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx, actually
|
||||
* iterate through B-tree for group members in internal library design.
|
||||
*/
|
||||
{
|
||||
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
|
||||
CHECK(root_group, FAIL, "H5Gopen2");
|
||||
|
||||
ret = H5Gget_num_objs(root_group, &num_membs);
|
||||
CHECK(ret, FAIL, "H5Gget_num_objs");
|
||||
VERIFY(num_membs, (NDATASETS + 2), "H5Gget_num_objs");
|
||||
ret = H5Gget_info(root_group, ".", &ginfo, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Gget_info");
|
||||
VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info");
|
||||
|
||||
for(i = 0; i< (int)num_membs; i++) {
|
||||
for(i = 0; i< (int)ginfo.nlinks; i++) {
|
||||
H5G_obj_t obj_type; /* Type of object in file */
|
||||
|
||||
ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)NAMELEN);
|
||||
@ -233,16 +233,16 @@ test_iter_group(hid_t fapl, hbool_t new_format)
|
||||
CHECK(ret, FAIL, "H5Gclose");
|
||||
}
|
||||
|
||||
/* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
|
||||
/* These two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx, actually
|
||||
* iterate through B-tree for group members in internal library design.
|
||||
* (Same as test above, but with the file ID instead of opening the root group)
|
||||
*/
|
||||
{
|
||||
ret = H5Gget_num_objs(file, &num_membs);
|
||||
CHECK(ret, FAIL, "H5Gget_num_objs");
|
||||
VERIFY(num_membs, NDATASETS + 2, "H5Gget_num_objs");
|
||||
ret = H5Gget_info(file, ".", &ginfo, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Gget_info");
|
||||
VERIFY(ginfo.nlinks, NDATASETS + 2, "H5Gget_info");
|
||||
|
||||
for(i = 0; i< (int)num_membs; i++) {
|
||||
for(i = 0; i< (int)ginfo.nlinks; i++) {
|
||||
H5G_obj_t obj_type; /* Type of object in file */
|
||||
|
||||
ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)i, dataset_name, (size_t)NAMELEN);
|
||||
@ -708,7 +708,7 @@ static void test_grp_memb_funcs(hid_t fapl)
|
||||
char *obj_names[NDATASETS+2];/* Names of the objects in group */
|
||||
char dataset_name[NAMELEN]; /* dataset name */
|
||||
ssize_t name_len; /* Length of object's name */
|
||||
hsize_t num_membs; /* Number of group members */
|
||||
H5G_info_t ginfo; /* Buffer for querying object's info */
|
||||
herr_t ret; /* Generic return value */
|
||||
|
||||
/* Output message about test being performed */
|
||||
@ -772,17 +772,17 @@ static void test_grp_memb_funcs(hid_t fapl)
|
||||
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
|
||||
CHECK(file, FAIL, "H5Fopen");
|
||||
|
||||
/* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
|
||||
/* These two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx, actually
|
||||
* iterate through B-tree for group members in internal library design.
|
||||
*/
|
||||
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
|
||||
CHECK(root_group, FAIL, "H5Gopen2");
|
||||
|
||||
ret = H5Gget_num_objs(root_group, &num_membs);
|
||||
CHECK(ret, FAIL, "H5Gget_num_objs");
|
||||
VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs");
|
||||
ret = H5Gget_info(root_group, ".", &ginfo, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Gget_info");
|
||||
VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info");
|
||||
|
||||
for(i=0; i< (int)num_membs; i++) {
|
||||
for(i=0; i< (int)ginfo.nlinks; i++) {
|
||||
H5G_obj_t obj_type; /* Type of object in file */
|
||||
|
||||
/* Test with NULL for name, to query length */
|
||||
@ -819,7 +819,7 @@ static void test_grp_memb_funcs(hid_t fapl)
|
||||
HDqsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
|
||||
|
||||
/* Compare object names */
|
||||
for(i = 0; i< (int)num_membs; i++) {
|
||||
for(i = 0; i< (int)ginfo.nlinks; i++) {
|
||||
ret = HDstrcmp(dnames[i], obj_names[i]);
|
||||
VERIFY(ret, 0, "HDstrcmp");
|
||||
} /* end for */
|
||||
@ -848,11 +848,11 @@ static void test_links(hid_t fapl)
|
||||
hid_t file; /* File ID */
|
||||
char obj_name[NAMELEN]; /* Names of the object in group */
|
||||
ssize_t name_len; /* Length of object's name */
|
||||
herr_t ret; /* Generic return value */
|
||||
hid_t gid, gid1;
|
||||
hsize_t i;
|
||||
H5G_obj_t obj_type; /* Type of object */
|
||||
hsize_t nobjs; /* Number of objects */
|
||||
H5G_info_t ginfo; /* Buffer for querying object's info */
|
||||
hsize_t i;
|
||||
herr_t ret; /* Generic return value */
|
||||
|
||||
/* Output message about test being performed */
|
||||
MESSAGE(5, ("Testing Soft and Hard Link Iteration Functionality\n"));
|
||||
@ -875,12 +875,12 @@ static void test_links(hid_t fapl)
|
||||
ret = H5Lcreate_hard(gid, "/g1", H5L_SAME_LOC, "hardlink", H5P_DEFAULT, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Lcreate_hard");
|
||||
|
||||
ret = H5Gget_num_objs(gid, &nobjs);
|
||||
CHECK(ret, FAIL, "H5Gget_num_objs");
|
||||
VERIFY(nobjs,3,"H5Gget_num_objs");
|
||||
ret = H5Gget_info(gid, ".", &ginfo, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Gget_info");
|
||||
VERIFY(ginfo.nlinks, 3, "H5Gget_info");
|
||||
|
||||
/* Test these two functions, H5Gget_num_objs and H5Gget_objname_by_idx */
|
||||
for(i = 0; i < nobjs; i++) {
|
||||
/* Test these two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx */
|
||||
for(i = 0; i < ginfo.nlinks; i++) {
|
||||
/* Get object name */
|
||||
name_len = H5Gget_objname_by_idx(gid, i, obj_name, (size_t)NAMELEN);
|
||||
CHECK(name_len, FAIL, "H5Gget_objname_by_idx");
|
||||
|
@ -985,7 +985,7 @@ test_reference_group(void)
|
||||
hid_t sid; /* Dataspace ID */
|
||||
hobj_ref_t wref; /* Reference to write */
|
||||
hobj_ref_t rref; /* Reference to read */
|
||||
hsize_t nobjs;
|
||||
H5G_info_t ginfo; /* Group info struct */
|
||||
char objname[NAME_SIZE]; /* Buffer to store name */
|
||||
H5G_obj_t objtype; /* Object type */
|
||||
int count = 0; /* Count within iterated group */
|
||||
@ -1065,14 +1065,12 @@ test_reference_group(void)
|
||||
CHECK(ret, FAIL, "H5Literate");
|
||||
|
||||
/* Various queries on the group opened */
|
||||
ret = H5Gget_num_objs(gid, &nobjs);
|
||||
CHECK(ret, FAIL, "H5Gget_num_objs");
|
||||
|
||||
VERIFY(nobjs, 3, "H5Gget_num_objs");
|
||||
ret = H5Gget_info(gid, ".", &ginfo, H5P_DEFAULT);
|
||||
CHECK(ret, FAIL, "H5Gget_info");
|
||||
VERIFY(ginfo.nlinks, 3, "H5Gget_info");
|
||||
|
||||
ret = H5Gget_objname_by_idx(gid, (hsize_t)0, objname, (size_t)NAME_SIZE);
|
||||
CHECK(ret, FAIL, "H5Gget_objname_by_idx");
|
||||
|
||||
VERIFY_STR(objname, DSETNAME2, "H5Gget_objname_by_idx");
|
||||
|
||||
objtype = H5Gget_objtype_by_idx(gid, (hsize_t)0);
|
||||
|
@ -2792,7 +2792,7 @@ static void dump_fcontents(hid_t fid)
|
||||
}
|
||||
|
||||
/* print objects in the files */
|
||||
h5trav_getinfo(fid, NULL, 1);
|
||||
h5trav_print(fid);
|
||||
|
||||
printf(" %s\n",END);
|
||||
}
|
||||
|
@ -329,9 +329,18 @@ int do_copy_objects(hid_t fidin,
|
||||
*/
|
||||
case H5G_GROUP:
|
||||
if (options->verbose)
|
||||
printf(FORMAT_OBJ,"group",travt->objs[i].name );
|
||||
printf(FORMAT_OBJ,"group",travt->objs[i].name );
|
||||
|
||||
if (options->grp_compact>0 || options->grp_indexed>0) {
|
||||
/*-------------------------------------------------------------------------
|
||||
* the root is a special case, we get an ID for the root group
|
||||
* and copy its attributes using that ID
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(HDstrcmp(travt->objs[i].name, "/") == 0) {
|
||||
if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
}
|
||||
else if (options->grp_compact>0 || options->grp_indexed>0) {
|
||||
/* Set up group creation property list */
|
||||
if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
|
||||
goto error;
|
||||
@ -780,26 +789,6 @@ int do_copy_objects(hid_t fidin,
|
||||
|
||||
} /* i */
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* the root is a special case, we get an ID for the root group
|
||||
* and copy its attributes using that ID
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
|
||||
if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
|
||||
if (copy_attr(grp_in,grp_out,options)<0)
|
||||
goto error;
|
||||
|
||||
if (H5Gclose(grp_out)<0)
|
||||
goto error;
|
||||
if (H5Gclose(grp_in)<0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
@ -397,30 +397,6 @@ int do_copy_refobjs(hid_t fidin,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* the root is a special case, we get an ID for the root group
|
||||
* and copy its attributes using that ID
|
||||
* it must be done last, because the attributes might contain references to
|
||||
* objects in the object list
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
|
||||
if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
|
||||
if (copy_refs_attr(grp_in, grp_out, options, travt, fidout) < 0)
|
||||
goto error;
|
||||
|
||||
if (H5Gclose(grp_out) < 0)
|
||||
goto error;
|
||||
if (H5Gclose(grp_in) < 0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
@ -461,9 +461,8 @@ static herr_t
|
||||
group_stats(hid_t group, const char *name, const char *fullname,
|
||||
const H5O_info_t *oi, H5L_iterate_t walk, iter_t *iter)
|
||||
{
|
||||
hid_t gid; /* Group ID */
|
||||
const char *last_container;
|
||||
hsize_t num_objs;
|
||||
H5G_info_t ginfo; /* Group information */
|
||||
unsigned bin; /* "bin" the number of objects falls in */
|
||||
herr_t ret;
|
||||
|
||||
@ -476,21 +475,18 @@ group_stats(hid_t group, const char *name, const char *fullname,
|
||||
iter->group_ohdr_info.total_size += oi->hdr.space.total;
|
||||
iter->group_ohdr_info.free_size += oi->hdr.space.free;
|
||||
|
||||
gid = H5Gopen2(group, name, H5P_DEFAULT);
|
||||
assert(gid > 0);
|
||||
|
||||
/* Get number of links in this group */
|
||||
ret = H5Gget_num_objs(gid, &num_objs);
|
||||
/* Get group information */
|
||||
ret = H5Gget_info(group, name, &ginfo, H5P_DEFAULT);
|
||||
assert(ret >= 0);
|
||||
|
||||
/* Update link stats */
|
||||
if(num_objs < SIZE_SMALL_GROUPS)
|
||||
(iter->num_small_groups[(size_t)num_objs])++;
|
||||
if(num_objs > iter->max_fanout)
|
||||
iter->max_fanout = num_objs;
|
||||
if(ginfo.nlinks < SIZE_SMALL_GROUPS)
|
||||
(iter->num_small_groups[(size_t)ginfo.nlinks])++;
|
||||
if(ginfo.nlinks > iter->max_fanout)
|
||||
iter->max_fanout = ginfo.nlinks;
|
||||
|
||||
/* Add group count to proper bin */
|
||||
bin = ceil_log10((unsigned long)num_objs);
|
||||
bin = ceil_log10((unsigned long)ginfo.nlinks);
|
||||
if((bin + 1) > iter->group_nbins) {
|
||||
/* Allocate more storage for info about dataset's datatype */
|
||||
iter->group_bins = realloc(iter->group_bins, (bin + 1) * sizeof(unsigned long));
|
||||
@ -515,10 +511,6 @@ group_stats(hid_t group, const char *name, const char *fullname,
|
||||
ret = attribute_stats(iter, oi);
|
||||
assert(ret >= 0);
|
||||
|
||||
/* Close current group */
|
||||
ret = H5Gclose(gid);
|
||||
assert(ret >= 0);
|
||||
|
||||
/* Update current container info */
|
||||
last_container = iter->container;
|
||||
iter->container = fullname;
|
||||
@ -742,7 +734,7 @@ dataset_stats(hid_t group, const char *name, const H5O_info_t *oi, iter_t *iter)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
walk(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter)
|
||||
walk(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *_iter)
|
||||
{
|
||||
iter_t *iter = (iter_t *)_iter;
|
||||
H5O_info_t oi;
|
||||
|
@ -186,180 +186,156 @@ hsize_t h5diff(const char *fname1,
|
||||
const char *objname2,
|
||||
diff_opt_t *options)
|
||||
{
|
||||
int nobjects1, nobjects2;
|
||||
trav_info_t *info1 = NULL;
|
||||
trav_info_t *info2 = NULL;
|
||||
hid_t file1_id=(-1), file2_id=(-1);
|
||||
char filenames[2][1024];
|
||||
hsize_t nfound = 0;
|
||||
trav_info_t *info1;
|
||||
trav_info_t *info2;
|
||||
hid_t file1_id = (-1), file2_id = (-1);
|
||||
char filenames[2][1024];
|
||||
hsize_t nfound = 0;
|
||||
|
||||
memset(filenames, 0, 1024*2);
|
||||
memset(filenames, 0, 1024*2);
|
||||
|
||||
if (options->m_quiet &&
|
||||
(options->m_verbose || options->m_report))
|
||||
{
|
||||
printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
|
||||
options->err_stat=1;
|
||||
return 0;
|
||||
}
|
||||
if(options->m_quiet &&
|
||||
(options->m_verbose || options->m_report))
|
||||
{
|
||||
printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
|
||||
options->err_stat=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open the files first; if they are not valid, no point in continuing
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
/*-------------------------------------------------------------------------
|
||||
* open the files first; if they are not valid, no point in continuing
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* disable error reporting */
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
/* Open the files */
|
||||
if ((file1_id = H5Fopen (fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
|
||||
{
|
||||
printf ("h5diff: <%s>: unable to open file\n", fname1);
|
||||
options->err_stat = 1;
|
||||
/* disable error reporting */
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
/* Open the files */
|
||||
if ((file1_id = H5Fopen (fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
|
||||
{
|
||||
printf ("h5diff: <%s>: unable to open file\n", fname1);
|
||||
options->err_stat = 1;
|
||||
|
||||
#ifdef H5_HAVE_PARALLEL
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
#endif
|
||||
|
||||
goto out;
|
||||
}
|
||||
if ((file2_id = H5Fopen (fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
|
||||
{
|
||||
printf ("h5diff: <%s>: unable to open file\n", fname2);
|
||||
options->err_stat = 1;
|
||||
goto out;
|
||||
}
|
||||
if ((file2_id = H5Fopen (fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
|
||||
{
|
||||
printf ("h5diff: <%s>: unable to open file\n", fname2);
|
||||
options->err_stat = 1;
|
||||
|
||||
#ifdef H5_HAVE_PARALLEL
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
#endif
|
||||
|
||||
goto out;
|
||||
}
|
||||
/* enable error reporting */
|
||||
}
|
||||
H5E_END_TRY;
|
||||
goto out;
|
||||
}
|
||||
/* enable error reporting */
|
||||
}
|
||||
H5E_END_TRY;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* get the number of objects in the files
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
nobjects1 = h5trav_getinfo (file1_id, NULL, 0);
|
||||
nobjects2 = h5trav_getinfo (file2_id, NULL, 0);
|
||||
/*-------------------------------------------------------------------------
|
||||
* Initialize the info structs
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
trav_info_init(&info1);
|
||||
trav_info_init(&info2);
|
||||
|
||||
if (nobjects1 < 0 || nobjects2 < 0)
|
||||
{
|
||||
printf ("Error: Could not get file contents\n");
|
||||
options->err_stat = 1;
|
||||
/*-------------------------------------------------------------------------
|
||||
* get the list of objects in the files
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(h5trav_getinfo(file1_id, info1) < 0 || h5trav_getinfo(file2_id, info2) < 0)
|
||||
{
|
||||
printf("Error: Could not get file contents\n");
|
||||
options->err_stat = 1;
|
||||
#ifdef H5_HAVE_PARALLEL
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
#endif
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* get the list of objects in the files
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
/*-------------------------------------------------------------------------
|
||||
* object name was supplied
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
info1 = (trav_info_t *) malloc (nobjects1 * sizeof (trav_info_t));
|
||||
info2 = (trav_info_t *) malloc (nobjects2 * sizeof (trav_info_t));
|
||||
if (info1 == NULL || info2 == NULL)
|
||||
{
|
||||
printf ("Error: Not enough memory for object list\n");
|
||||
options->err_stat = 1;
|
||||
if (info1) h5trav_freeinfo (info1, nobjects1);
|
||||
if (info2) h5trav_freeinfo (info2, nobjects1);
|
||||
#ifdef H5_HAVE_PARALLEL
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
#endif
|
||||
goto out;
|
||||
}
|
||||
|
||||
h5trav_getinfo (file1_id, info1, 0);
|
||||
h5trav_getinfo (file2_id, info2, 0);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* object name was supplied
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if (objname1)
|
||||
{
|
||||
if (objname1)
|
||||
{
|
||||
|
||||
#ifdef H5_HAVE_PARALLEL
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
if(g_Parallel)
|
||||
{
|
||||
/* Let tasks know that they won't be needed */
|
||||
phdiff_dismiss_workers();
|
||||
}
|
||||
#endif
|
||||
assert (objname2);
|
||||
options->cmn_objs = 1; /* eliminate warning */
|
||||
nfound = diff_compare (file1_id, fname1, objname1, nobjects1, info1,
|
||||
file2_id, fname2, objname2, nobjects2, info2,
|
||||
options);
|
||||
}
|
||||
assert (objname2);
|
||||
options->cmn_objs = 1; /* eliminate warning */
|
||||
nfound = diff_compare (file1_id, fname1, objname1, info1,
|
||||
file2_id, fname2, objname2, info2,
|
||||
options);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* compare all
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
/*-------------------------------------------------------------------------
|
||||
* compare all
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef H5_HAVE_PARALLEL
|
||||
if(g_Parallel)
|
||||
{
|
||||
int i;
|
||||
if(g_Parallel)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( (strlen(fname1) > 1024) || (strlen(fname2) > 1024))
|
||||
{
|
||||
fprintf(stderr, "The parallel diff only supports path names up to 1024 characters\n");
|
||||
MPI_Abort(MPI_COMM_WORLD, 0);
|
||||
}
|
||||
if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024))
|
||||
{
|
||||
fprintf(stderr, "The parallel diff only supports path names up to 1024 characters\n");
|
||||
MPI_Abort(MPI_COMM_WORLD, 0);
|
||||
}
|
||||
|
||||
strcpy(filenames[0], fname1);
|
||||
strcpy(filenames[1], fname2);
|
||||
HDstrcpy(filenames[0], fname1);
|
||||
HDstrcpy(filenames[1], fname2);
|
||||
|
||||
/* Alert the worker tasks that there's going to be work. */
|
||||
/* Alert the worker tasks that there's going to be work. */
|
||||
|
||||
for(i=1; i<g_nTasks; i++)
|
||||
MPI_Send(filenames, 1024*2, MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD);
|
||||
}
|
||||
for(i = 1; i < g_nTasks; i++)
|
||||
MPI_Send(filenames, 1024 * 2, MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD);
|
||||
}
|
||||
#endif
|
||||
nfound = diff_match (file1_id, nobjects1, info1,
|
||||
file2_id, nobjects2, info2, options);
|
||||
}
|
||||
nfound = diff_match(file1_id, info1, file2_id, info2, options);
|
||||
}
|
||||
|
||||
h5trav_freeinfo (info1, nobjects1);
|
||||
h5trav_freeinfo (info2, nobjects2);
|
||||
trav_info_free(info1);
|
||||
trav_info_free(info2);
|
||||
|
||||
out:
|
||||
/* close */
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
H5Fclose (file1_id);
|
||||
H5Fclose (file2_id);
|
||||
}
|
||||
H5E_END_TRY;
|
||||
/* close */
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
H5Fclose(file1_id);
|
||||
H5Fclose(file2_id);
|
||||
}
|
||||
H5E_END_TRY;
|
||||
|
||||
return nfound;
|
||||
return nfound;
|
||||
}
|
||||
|
||||
|
||||
@ -383,18 +359,16 @@ out:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hsize_t diff_match (hid_t file1_id,
|
||||
int nobjects1,
|
||||
trav_info_t * info1,
|
||||
hid_t file2_id,
|
||||
int nobjects2,
|
||||
trav_info_t * info2,
|
||||
diff_opt_t * options)
|
||||
{
|
||||
int more_names_exist = (nobjects1 > 0 && nobjects2 > 0) ? 1 : 0;
|
||||
int more_names_exist = (info1->nused > 0 && info2->nused > 0) ? 1 : 0;
|
||||
trav_table_t *table = NULL;
|
||||
int cmp;
|
||||
int curr1 = 0;
|
||||
int curr2 = 0;
|
||||
size_t curr1 = 0;
|
||||
size_t curr2 = 0;
|
||||
unsigned infile[2];
|
||||
char c1, c2;
|
||||
hsize_t nfound = 0;
|
||||
@ -409,12 +383,12 @@ hsize_t diff_match (hid_t file1_id,
|
||||
while (more_names_exist)
|
||||
{
|
||||
/* criteria is string compare */
|
||||
cmp = strcmp (info1[curr1].name, info2[curr2].name);
|
||||
cmp = HDstrcmp(info1->paths[curr1].path, info2->paths[curr2].path);
|
||||
if (cmp == 0)
|
||||
{
|
||||
infile[0] = 1;
|
||||
infile[1] = 1;
|
||||
trav_table_addflags (infile, info1[curr1].name, info1[curr1].type,
|
||||
trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type,
|
||||
table);
|
||||
|
||||
curr1++;
|
||||
@ -424,7 +398,7 @@ hsize_t diff_match (hid_t file1_id,
|
||||
{
|
||||
infile[0] = 1;
|
||||
infile[1] = 0;
|
||||
trav_table_addflags (infile, info1[curr1].name, info1[curr1].type,
|
||||
trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type,
|
||||
table);
|
||||
curr1++;
|
||||
}
|
||||
@ -432,37 +406,36 @@ hsize_t diff_match (hid_t file1_id,
|
||||
{
|
||||
infile[0] = 0;
|
||||
infile[1] = 1;
|
||||
trav_table_addflags (infile, info2[curr2].name, info2[curr2].type,
|
||||
trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type,
|
||||
table);
|
||||
curr2++;
|
||||
}
|
||||
|
||||
more_names_exist = (curr1 < nobjects1 && curr2 < nobjects2) ? 1 : 0;
|
||||
|
||||
more_names_exist = (curr1 < info1->nused && curr2 < info2->nused) ? 1 : 0;
|
||||
|
||||
} /* end while */
|
||||
|
||||
/* list1 did not end */
|
||||
if (curr1 < nobjects1)
|
||||
if (curr1 < info1->nused)
|
||||
{
|
||||
while (curr1 < nobjects1)
|
||||
while (curr1 < info1->nused)
|
||||
{
|
||||
infile[0] = 1;
|
||||
infile[1] = 0;
|
||||
trav_table_addflags (infile, info1[curr1].name, info1[curr1].type,
|
||||
trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type,
|
||||
table);
|
||||
curr1++;
|
||||
}
|
||||
}
|
||||
|
||||
/* list2 did not end */
|
||||
if (curr2 < nobjects2)
|
||||
if (curr2 < info2->nused)
|
||||
{
|
||||
while (curr2 < nobjects2)
|
||||
while (curr2 < info2->nused)
|
||||
{
|
||||
infile[0] = 0;
|
||||
infile[1] = 1;
|
||||
trav_table_addflags (infile, info2[curr2].name, info2[curr2].type,
|
||||
trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type,
|
||||
table);
|
||||
curr2++;
|
||||
}
|
||||
@ -789,17 +762,6 @@ hsize_t diff_match (hid_t file1_id,
|
||||
/* free table */
|
||||
trav_table_free (table);
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* do the diff for the root.
|
||||
* this is a special case, we get an ID for the root group and call diff()
|
||||
* with this ID; it compares only the root group attributes
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* the manager can do this. */
|
||||
nfound += diff (file1_id, "/", file2_id, "/", options, H5G_GROUP);
|
||||
|
||||
return nfound;
|
||||
}
|
||||
|
||||
@ -821,20 +783,18 @@ hsize_t diff_match (hid_t file1_id,
|
||||
hsize_t diff_compare (hid_t file1_id,
|
||||
const char *file1_name,
|
||||
const char *obj1_name,
|
||||
int nobjects1,
|
||||
trav_info_t * info1,
|
||||
hid_t file2_id,
|
||||
const char *file2_name,
|
||||
const char *obj2_name,
|
||||
int nobjects2,
|
||||
trav_info_t * info2,
|
||||
diff_opt_t * options)
|
||||
{
|
||||
int f1 = 0, f2 = 0;
|
||||
hsize_t nfound = 0;
|
||||
|
||||
int i = h5trav_getindex (obj1_name, nobjects1, info1);
|
||||
int j = h5trav_getindex (obj2_name, nobjects2, info2);
|
||||
ssize_t i = h5trav_getindex (info1, obj1_name);
|
||||
ssize_t j = h5trav_getindex (info2, obj2_name);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
@ -855,23 +815,23 @@ hsize_t diff_compare (hid_t file1_id,
|
||||
}
|
||||
|
||||
/* use the name with "/" first, as obtained by iterator function */
|
||||
obj1_name = info1[i].name;
|
||||
obj2_name = info2[j].name;
|
||||
obj1_name = info1->paths[i].path;
|
||||
obj2_name = info2->paths[j].path;
|
||||
|
||||
/* objects are not the same type */
|
||||
if (info1[i].type != info2[j].type)
|
||||
if (info1->paths[i].type != info2->paths[j].type)
|
||||
{
|
||||
if (options->m_verbose)
|
||||
parallel_print
|
||||
("Comparison not possible: <%s> is of type %s and <%s> is of type %s\n",
|
||||
obj1_name, get_type (info1[i].type), obj2_name,
|
||||
get_type (info2[j].type));
|
||||
obj1_name, get_type (info1->paths[i].type), obj2_name,
|
||||
get_type (info2->paths[j].type));
|
||||
options->not_cmp=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
nfound =
|
||||
diff (file1_id, obj1_name, file2_id, obj2_name, options, info1[i].type);
|
||||
diff (file1_id, obj1_name, file2_id, obj2_name, options, info1->paths[i].type);
|
||||
|
||||
return nfound;
|
||||
}
|
||||
|
@ -94,20 +94,16 @@ hsize_t diff( hid_t file1_id,
|
||||
hsize_t diff_compare( hid_t file1_id,
|
||||
const char *file1_name,
|
||||
const char *obj1_name,
|
||||
int nobjects1,
|
||||
trav_info_t *info1,
|
||||
hid_t file2_id,
|
||||
const char *file2_name,
|
||||
const char *obj2_name,
|
||||
int nobjects2,
|
||||
trav_info_t *info2,
|
||||
diff_opt_t *options );
|
||||
|
||||
hsize_t diff_match( hid_t file1_id,
|
||||
int nobjects1,
|
||||
trav_info_t *info1,
|
||||
hid_t file2_id,
|
||||
int nobjects2,
|
||||
trav_info_t *info2,
|
||||
diff_opt_t *options );
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#if defined (H5DIFF_DEBUG)
|
||||
static void
|
||||
print_size (int rank, hsize_t *dims)
|
||||
{
|
||||
@ -40,6 +41,7 @@ print_size (int rank, hsize_t *dims)
|
||||
parallel_print("]\n" );
|
||||
|
||||
}
|
||||
#endif /* H5DIFF_DEBUG */
|
||||
|
||||
|
||||
|
||||
@ -279,8 +281,6 @@ hsize_t diff_datasetid( hid_t did1,
|
||||
|
||||
storage_size1=H5Dget_storage_size(did1);
|
||||
storage_size2=H5Dget_storage_size(did2);
|
||||
if (storage_size1<0 || storage_size2<0)
|
||||
goto error;
|
||||
|
||||
if (storage_size1==0 || storage_size2==0)
|
||||
{
|
||||
|
1417
tools/lib/h5trav.c
1417
tools/lib/h5trav.c
File diff suppressed because it is too large
Load Diff
@ -32,9 +32,15 @@
|
||||
typedef H5G_obj_t H5G_obj_t1;
|
||||
|
||||
|
||||
typedef struct trav_info_t {
|
||||
char *name;
|
||||
typedef struct trav_path_t {
|
||||
char *path;
|
||||
H5G_obj_t type;
|
||||
} trav_path_t;
|
||||
|
||||
typedef struct trav_info_t {
|
||||
size_t nalloc;
|
||||
size_t nused;
|
||||
trav_path_t *paths;
|
||||
} trav_info_t;
|
||||
|
||||
|
||||
@ -56,11 +62,10 @@ typedef struct trav_obj_t {
|
||||
haddr_t objno; /* object number from H5Gget_objinfo */
|
||||
unsigned flags[2]; /* h5diff.object is present or not in both files*/
|
||||
char *name; /* name */
|
||||
int displayed; /* hard link already traversed once */
|
||||
H5G_obj_t type; /* type of object */
|
||||
trav_link_t *links; /* array of possible link names */
|
||||
int sizelinks; /* size of links array */
|
||||
unsigned nlinks; /* number of links */
|
||||
size_t sizelinks; /* size of links array */
|
||||
size_t nlinks; /* number of links */
|
||||
} trav_obj_t;
|
||||
|
||||
|
||||
@ -70,8 +75,8 @@ typedef struct trav_obj_t {
|
||||
*/
|
||||
|
||||
typedef struct trav_table_t {
|
||||
unsigned size;
|
||||
unsigned nobjs;
|
||||
size_t size;
|
||||
size_t nobjs;
|
||||
trav_obj_t *objs;
|
||||
} trav_table_t;
|
||||
|
||||
@ -89,24 +94,36 @@ extern "C" {
|
||||
* "h5trav info" public functions
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int h5trav_getinfo( hid_t fid, trav_info_t *info, int print );
|
||||
int h5trav_getindex( const char *obj, int nobjs, trav_info_t *info );
|
||||
void h5trav_freeinfo( trav_info_t *info, int nobjs );
|
||||
void h5trav_printinfo(int nobjs, trav_info_t *info);
|
||||
int h5trav_getinfo(hid_t file_id, trav_info_t *info);
|
||||
ssize_t h5trav_getindex(const trav_info_t *info, const char *obj);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* "h5trav table" public functions
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int h5trav_getindext(const char *obj,trav_table_t *travt);
|
||||
int h5trav_gettable(hid_t fid, trav_table_t *travt);
|
||||
void h5trav_printtable(trav_table_t *table);
|
||||
int h5trav_getindext(const char *obj, const trav_table_t *travt);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* "h5trav print" public functions
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int h5trav_print(hid_t fid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* info private functions
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void trav_info_init(trav_info_t **info);
|
||||
|
||||
void trav_info_free(trav_info_t *info);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* table private functions
|
||||
*-------------------------------------------------------------------------
|
||||
@ -116,25 +133,11 @@ void trav_table_init(trav_table_t **table);
|
||||
|
||||
void trav_table_free(trav_table_t *table);
|
||||
|
||||
int trav_table_search(haddr_t objno,
|
||||
trav_table_t *table );
|
||||
|
||||
void trav_table_add(haddr_t objno,
|
||||
char *objname,
|
||||
H5G_obj_t type,
|
||||
trav_table_t *table);
|
||||
|
||||
void trav_table_addflags(unsigned *flags,
|
||||
char *objname,
|
||||
H5G_obj_t type,
|
||||
trav_table_t *table);
|
||||
|
||||
|
||||
void trav_table_addlink(trav_table_t *table,
|
||||
int j /* the object index */,
|
||||
char *path );
|
||||
|
||||
|
||||
#endif /* H5TRAV_H__ */
|
||||
|
||||
|
||||
|
@ -4,8 +4,11 @@ Expected output for 'h5diff h5diff_hyper1.h5 h5diff_hyper2.h5 -v'
|
||||
|
||||
file1 file2
|
||||
---------------------------------------
|
||||
x x /
|
||||
x x /big
|
||||
|
||||
group : </> and </>
|
||||
0 differences found
|
||||
dataset: </big> and </big>
|
||||
size: [1073741824] [1073741824]
|
||||
position big big difference
|
||||
@ -1035,5 +1038,3 @@ position big big difference
|
||||
[ 268436478 ] 31 0 31
|
||||
[ 268436479 ] 31 0 31
|
||||
1024 differences found
|
||||
group : </> and </>
|
||||
0 differences found
|
||||
|
@ -4,6 +4,7 @@ Expected output for 'h5diff h5diff_basic1.h5 h5diff_basic2.h5 -v'
|
||||
|
||||
file1 file2
|
||||
---------------------------------------
|
||||
x x /
|
||||
x x /g1
|
||||
x /g1/d1
|
||||
x /g1/d2
|
||||
@ -23,6 +24,8 @@ file1 file2
|
||||
x /g1/fp2
|
||||
x /g2
|
||||
|
||||
group : </> and </>
|
||||
0 differences found
|
||||
group : </g1> and </g1>
|
||||
0 differences found
|
||||
dataset: </g1/dset1> and </g1/dset1>
|
||||
@ -35,5 +38,3 @@ position dset1 dset1 difference
|
||||
[ 1 1 ] 1 1.001 0.001
|
||||
[ 2 1 ] 0 1 1
|
||||
5 differences found
|
||||
group : </> and </>
|
||||
0 differences found
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@ Expected output for 'h5diff h5diff_dset1.h5 h5diff_dset2.h5 -v'
|
||||
|
||||
file1 file2
|
||||
---------------------------------------
|
||||
x x /
|
||||
x x /dset
|
||||
x x /dsetref
|
||||
x x /g1
|
||||
@ -39,6 +40,8 @@ file1 file2
|
||||
x x /g1/vlen3D
|
||||
x x /refreg
|
||||
|
||||
group : </> and </>
|
||||
0 differences found
|
||||
dataset: </dset> and </dset>
|
||||
size: [2] [2]
|
||||
position dset dset difference
|
||||
@ -782,8 +785,6 @@ point #1 (2,2) (3,3)
|
||||
point #3 (1,6) (2,5)
|
||||
point #4 (2,8) (1,7)
|
||||
4 differences found
|
||||
group : </> and </>
|
||||
0 differences found
|
||||
--------------------------------
|
||||
Some objects are not comparable
|
||||
--------------------------------
|
||||
|
@ -4,6 +4,7 @@ Expected output for 'h5dump -n tfcontents1.h5'
|
||||
HDF5 "tfcontents1.h5" {
|
||||
FILE_CONTENTS {
|
||||
datatype /#5616
|
||||
group /
|
||||
dataset /dset
|
||||
dataset /dset3 -> /dset
|
||||
dataset /dset4 -> /dset
|
||||
@ -17,6 +18,6 @@ FILE_CONTENTS {
|
||||
link /mylink -> mylink
|
||||
datatype /mytype
|
||||
link /softlink -> /dset
|
||||
UD link type /udlink ->
|
||||
unknown type of UD link /udlink -> ???
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user