summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c66
-rw-r--r--tools/lib/h5tools.c56
-rw-r--r--tools/lib/h5tools.h1
3 files changed, 116 insertions, 7 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)
{
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 3d29d39..a712794 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -631,11 +631,11 @@ h5tools_ncols(const char *s)
*
* Purpose: Recursive check for any variable length data in given type.
*
- * Return:
+ * Return:
* TRUE : type conatains any variable length data
* FALSE : type doesn't contain any variable length data
* Negative value: error occur
- *
+ *
* Programmer: Jonathan Kim March 18, 2011
*-------------------------------------------------------------------------
*/
@@ -663,7 +663,7 @@ done:
*
* Purpose: Recursive check for variable length string of a datatype.
*
- * Return:
+ * Return:
* TRUE : type conatains any variable length string
* FALSE : type doesn't contain any variable length string
* Negative value: error occur
@@ -853,7 +853,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/* Calculate new prefix */
- h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims,
+ h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims,
ctx->p_max_idx, ctx);
/* Write new prefix to output */
@@ -2424,7 +2424,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
/* Terminate the output */
if (ctx.cur_column) {
fputs(OPT(info->line_suf, ""), stdout);
- putc('\n', stdout);
+ putc('\n', stdout);
fputs(OPT(info->line_sep, ""), stdout);
}
@@ -2532,7 +2532,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info,
vl_data = TRUE;
if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
vl_data = TRUE;
-
+
/*
* Determine the strip mine size and allocate a buffer. The strip mine is
* a hyperslab whose size is manageable.
@@ -2550,7 +2550,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info,
}
}
- if(!sm_nbytes)
+ if(!sm_nbytes)
goto done;
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
@@ -4328,3 +4328,45 @@ hbool_t h5tools_is_zero(const void *_mem, size_t size)
return TRUE;
}
+/*-------------------------------------------------------------------------
+ * Function: h5tools_is_obj_same
+ *
+ * Purpose: Check if two given object IDs or link names point to the same object.
+ *
+ * Parameters:
+ * hid_t loc_id1: location of the first object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id1 is the object to be compared.
+ * hid_t loc_id2: location of the second object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id2 is the object to be compared.
+ *
+ * Return: TRUE if it is the same object; FALSE otherwise.
+ *
+ * Programmer: Peter Cao
+ * 4/27/2011
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1,
+ hid_t loc_id2, const char *name2)
+{
+ H5O_info_t oinfo1, oinfo2;
+ hbool_t ret_val = 0;
+
+ if ( name1 && strcmp(name1, "."))
+ H5Oget_info_by_name(loc_id1, name1, &oinfo1, H5P_DEFAULT);
+ else
+ H5Oget_info(loc_id1, &oinfo1);
+
+ if ( name2 && strcmp(name2, "."))
+ H5Oget_info_by_name(loc_id2, name2, &oinfo2, H5P_DEFAULT);
+ else
+ H5Oget_info(loc_id2, &oinfo2);
+
+ if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr)
+ ret_val = 1;
+
+ return ret_val;
+}
+
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index fcfebc0..88847d1 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -561,6 +561,7 @@ H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type);
H5TOOLS_DLL htri_t h5tools_detect_vlen(hid_t tid);
H5TOOLS_DLL htri_t h5tools_detect_vlen_str(hid_t tid);
+H5TOOLS_DLL hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2);
H5TOOLS_DLL void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
h5tools_context_t *ctx/*in,out*/, unsigned flags,