summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2011-04-29 17:02:31 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2011-04-29 17:02:31 (GMT)
commit170e7e53a515be431a33c4e191b0be7c74e14ae5 (patch)
tree63b1f338145e779f7112d8da2812b4c3429c5f79 /tools/lib/h5diff.c
parentad35b2bdb2d50d8f73703742c66d5baab6481d18 (diff)
downloadhdf5-170e7e53a515be431a33c4e191b0be7c74e14ae5.zip
hdf5-170e7e53a515be431a33c4e191b0be7c74e14ae5.tar.gz
hdf5-170e7e53a515be431a33c4e191b0be7c74e14ae5.tar.bz2
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects Description: Fixed: 1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications. 2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file. Test update: Updat prvious test cases (171, 172, 530) affected by this fix, so they still perfrom originally intended testing without bypassing. Tested: jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
Diffstat (limited to 'tools/lib/h5diff.c')
-rw-r--r--tools/lib/h5diff.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index a4d8469..4f82906 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -932,6 +932,19 @@ hsize_t h5diff(const char *fname1,
/* if both obj1 and obj2 are group */
if (obj1type == H5TRAV_TYPE_GROUP && obj2type == H5TRAV_TYPE_GROUP)
{
+
+ /*
+ * Use h5tools_is_obj_same() to improve performance by skipping
+ * comparing details of same objects. If verbose options is used,
+ * need to traverse thorugh the list of objects in the group and
+ * print out object information. Details of same objects will be
+ * skipped at diff() function.
+ */
+ if(!(options->m_verbose || options->m_report)) {
+ if (h5tools_is_obj_same(file1_id,obj1fullname,file2_id,obj2fullname)!=0)
+ goto out;
+ }
+
/*
* traverse group1
*/
@@ -1773,6 +1786,7 @@ hsize_t diff(hid_t file1_id,
int ret;
int is_dangle_link1 = 0;
int is_dangle_link2 = 0;
+ int is_hard_link = 0;
hsize_t nfound = 0;
@@ -1834,6 +1848,58 @@ hsize_t diff(hid_t file1_id,
/* found dangling link */
if (is_dangle_link1 || is_dangle_link2)
goto out2;
+
+ /*
+ * Use h5tools_is_obj_same() to improve performance by skipping
+ * comparing details of same objects,
+ *
+ * check if two paths point to the same object for hard links or
+ * the option of follow link is used. h5tools_is_obj_same() is not
+ * needed for other cases.
+ */
+ is_hard_link = (type==H5TRAV_TYPE_DATASET ||
+ type==H5TRAV_TYPE_NAMED_DATATYPE ||
+ type==H5TRAV_TYPE_GROUP);
+ if (options->follow_links || is_hard_link)
+ {
+ if (h5tools_is_obj_same(file1_id, path1, file2_id, path2)!=0)
+ {
+ /* print information is only verbose option is used */
+ if(options->m_verbose || options->m_report)
+ {
+ switch(type)
+ {
+ case H5TRAV_TYPE_DATASET:
+ do_print_objname("dataset", path1, path2, options);
+ break;
+ case H5TRAV_TYPE_NAMED_DATATYPE:
+ do_print_objname("datatype", path1, path2, options);
+ break;
+ case H5TRAV_TYPE_GROUP:
+ do_print_objname("group", path1, path2, options);
+ break;
+ case H5TRAV_TYPE_LINK:
+ do_print_objname("link", path1, path2, options);
+ break;
+ case H5TRAV_TYPE_UDLINK:
+ if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
+ do_print_objname("external link", path1, path2, options);
+ else
+ do_print_objname ("user defined link", path1, path2, options);
+ break;
+ default:
+ parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
+ path1, path2, get_type(type) );
+ options->not_cmp = 1;
+ break;
+ } /* switch(type)*/
+
+ print_found(nfound);
+ } /* if(options->m_verbose || options->m_report) */
+
+ goto out2;
+ } /* h5tools_is_obj_same */
+ }
switch(type)
{