summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-05-22 18:10:40 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-05-22 18:10:40 (GMT)
commitcdcef539a3d359c8a7082923b947d920d738cd56 (patch)
tree2a4b151f61674b4cd368922ced09999bfab274c0 /tools/src
parent8861b5a4945b1a35103357b2d4097e1faef6b167 (diff)
downloadhdf5-cdcef539a3d359c8a7082923b947d920d738cd56.zip
hdf5-cdcef539a3d359c8a7082923b947d920d738cd56.tar.gz
hdf5-cdcef539a3d359c8a7082923b947d920d738cd56.tar.bz2
HDFFV-8611 change h5repack to save the root group creation order
Added test and new arguments to control the the input file parsing.
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/h5dump/h5dump.h4
-rw-r--r--tools/src/h5dump/h5dump_extern.h4
-rw-r--r--tools/src/h5repack/h5repack.c2
-rw-r--r--tools/src/h5repack/h5repack.h24
-rw-r--r--tools/src/h5repack/h5repack_copy.c39
-rw-r--r--tools/src/h5repack/h5repack_main.c87
-rw-r--r--tools/src/h5repack/h5repack_verify.c17
7 files changed, 134 insertions, 43 deletions
diff --git a/tools/src/h5dump/h5dump.h b/tools/src/h5dump/h5dump.h
index 211fd14..801f60d 100644
--- a/tools/src/h5dump/h5dump.h
+++ b/tools/src/h5dump/h5dump.h
@@ -78,10 +78,6 @@ int include_attrs = TRUE; /* Display attributes */
int display_vds_first = FALSE; /* vds display to all by default*/
int vds_gap_size = 0; /* vds skip missing files default is none */
-/* sort parameters */
-H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */
-H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */
-
#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
#define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */
/* mask list for packed bits */
diff --git a/tools/src/h5dump/h5dump_extern.h b/tools/src/h5dump/h5dump_extern.h
index 22aca73..00d3bd2 100644
--- a/tools/src/h5dump/h5dump_extern.h
+++ b/tools/src/h5dump/h5dump_extern.h
@@ -77,10 +77,6 @@ extern int include_attrs; /* Display attributes */
extern int display_vds_first; /* vds display to first missing */
extern int vds_gap_size; /* vds skip missing files */
-/* sort parameters */
-extern H5_index_t sort_by; /*sort_by [creation_order | name] */
-extern H5_iter_order_t sort_order; /*sort_order [ascending | descending] */
-
#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */
/* mask list for packed bits */
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index 3c9ce90..bc8527b 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -784,6 +784,8 @@ static int check_objects(const char* fname, pack_opt_t *options) {
*-------------------------------------------------------------------------
*/
+ /* Initialize indexing options */
+ h5trav_set_index(sort_by, sort_order);
/* init table */
trav_table_init(&travt);
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index e36f0ef..e5ae03f 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -29,10 +29,10 @@
#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */
/* File space default information */
-#define FS_PAGESIZE_DEF 4096
-#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
-#define FS_PERSIST_DEF FALSE
-#define FS_THRESHOLD_DEF 1
+#define FS_PAGESIZE_DEF 4096
+#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
+#define FS_PERSIST_DEF FALSE
+#define FS_THRESHOLD_DEF 1
/*-------------------------------------------------------------------------
@@ -120,10 +120,10 @@ typedef struct {
hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */
hsize_t threshold; /* alignment threshold for H5Pset_alignment */
hsize_t alignment; /* alignment for H5Pset_alignment */
- H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
- int fs_persist; /* Free space section threshold */
- long fs_threshold; /* Free space section threshold */
- long long fs_pagesize; /* File space page size */
+ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
+ int fs_persist; /* Free space section threshold */
+ long fs_threshold; /* Free space section threshold */
+ long long fs_pagesize; /* File space page size */
} pack_opt_t;
@@ -150,10 +150,10 @@ int h5repack_end(pack_opt_t *options);
int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options);
int h5repack_cmp_pl(const char *fname1, const char *fname2);
-/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr()
- * and struct named_dt_t were located in h5repack_copy.c as static prior to
- * bugfix1726.
- * Made shared functions as copy_attr() was needed in h5repack_refs.c.
+/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr()
+ * and struct named_dt_t were located in h5repack_copy.c as static prior to
+ * bugfix1726.
+ * Made shared functions as copy_attr() was needed in h5repack_refs.c.
* However copy_attr() may be obsoleted when H5Acopy is available and put back
* others to static in h5repack_copy.c.
*/
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index ec3e287..42fedbc 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -103,6 +103,7 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
hbool_t in_persist; /* Persist free-space status from input file */
hsize_t in_threshold; /* Free-space section threshold from input file */
hsize_t in_pagesize; /* File space page size from input file */
+ unsigned crt_order_flags; /* group creation order flag */
/*-------------------------------------------------------------------------
* open input file
@@ -116,6 +117,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
/* get user block size and file space strategy/persist/threshold */
{
hid_t fcpl_in; /* file creation property list ID for input file */
+ hid_t grp_in = -1; /* group ID */
+ hid_t gcpl_in = -1; /* group creation property list */
if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
error_msg("failed to retrieve file creation property list\n");
@@ -127,17 +130,28 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- /* If the -S option is not set, get "strategy" from the input file */
- if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) {
- error_msg("failed to retrieve file space strategy\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- }
+ /* If the -S option is not set, get "strategy" from the input file */
+ if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) {
+ error_msg("failed to retrieve file space strategy\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ }
- /* If the -G option is not set, get "pagesize" from the input file */
- if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) {
- error_msg("failed to retrieve file space threshold\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- }
+ /* If the -G option is not set, get "pagesize" from the input file */
+ if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) {
+ error_msg("failed to retrieve file space threshold\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ }
+ /* open root group */
+ if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+
+ /* get root group creation property list */
+ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+
+ /* query and set the group creation properties */
+ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
if (H5Pclose(fcpl_in) < 0) {
error_msg("failed to close property list\n");
@@ -309,6 +323,9 @@ print_user_block(fnamein, fidin);
}
}
+ if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed");
+
/* Set file space info to those from input file */
set_strategy = in_strategy;
set_persist = in_persist;
@@ -375,6 +392,8 @@ print_user_block(fnamein, fidin);
*-------------------------------------------------------------------------
*/
+ /* Initialize indexing options */
+ h5trav_set_index(sort_by, sort_order);
/* init table */
trav_table_init(&travt);
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index 339dc83..31b1e14 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -31,7 +31,7 @@ const char *outfile = NULL;
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:P:T:G:E";
+static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:P:T:G:q:z:E";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "version", no_arg, 'V' },
@@ -56,6 +56,8 @@ static struct long_options l_opts[] = {
{ "fs_persist", require_arg, 'P' },
{ "fs_threshold", require_arg, 'T' },
{ "fs_pagesize", require_arg, 'G' },
+ { "sort_by", require_arg, 'q' },
+ { "sort_order", require_arg, 'z' },
{ "enable-error-stack", no_arg, 'E' },
{ NULL, 0, '\0' }
};
@@ -90,6 +92,8 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n");
PRINTVALSTREAM(rawoutstream, " -t T, --threshold=T Threshold value for H5Pset_alignment\n");
PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n");
+ PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n");
+ PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n");
PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n");
PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n");
PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy\n");
@@ -103,6 +107,8 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " U - is a filename.\n");
PRINTVALSTREAM(rawoutstream, " T - is an integer\n");
PRINTVALSTREAM(rawoutstream, " A - is an integer greater than zero\n");
+ PRINTVALSTREAM(rawoutstream, " Q - is the sort index type for the input file. It can be \"name\" or \"creation_order\" (default)\n");
+ PRINTVALSTREAM(rawoutstream, " Z - is the sort order type for the input file. It can be \"descending\" or \"ascending\" (default)\n");
PRINTVALSTREAM(rawoutstream, " B - is the user block size, any value that is 512 or greater and is\n");
PRINTVALSTREAM(rawoutstream, " a power of 2 (1024 default)\n");
PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of <dspace|dtype|fill|\n");
@@ -370,6 +376,52 @@ done:
}
/*-------------------------------------------------------------------------
+ * Function: set_sort_by
+ *
+ * Purpose: set the "by" form of sorting by translating from a string input
+ * parameter to a H5_index_t return value
+ * current sort values are [creation_order | name]
+ *
+ * Return: H5_index_t form of sort or H5_INDEX_UNKNOWN if none found
+ *-------------------------------------------------------------------------
+ */
+static H5_index_t
+set_sort_by(const char *form)
+{
+ H5_index_t idx_type = H5_INDEX_UNKNOWN;
+
+ if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */
+ idx_type = H5_INDEX_NAME;
+ else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */
+ idx_type = H5_INDEX_CRT_ORDER;
+
+ return idx_type;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: set_sort_order
+ *
+ * Purpose: set the order of sorting by translating from a string input
+ * parameter to a H5_iter_order_t return value
+ * current order values are [ascending | descending ]
+ *
+ * Return: H5_iter_order_t form of order or H5_ITER_UNKNOWN if none found
+ *-------------------------------------------------------------------------
+ */
+static H5_iter_order_t
+set_sort_order(const char *form)
+{
+ H5_iter_order_t iter_order = H5_ITER_UNKNOWN;
+
+ if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */
+ iter_order = H5_ITER_INC;
+ else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */
+ iter_order = H5_ITER_DEC;
+
+ return iter_order;
+}
+
+/*-------------------------------------------------------------------------
* Function: parse_command_line
*
* Purpose: parse command line input
@@ -553,14 +605,14 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'P':
- options->fs_persist = HDatoi( opt_arg );
+ options->fs_persist = HDatoi(opt_arg);
if(options->fs_persist == 0)
/* To distinguish the "specified" zero value */
options->fs_persist = -1;
break;
case 'T':
- options->fs_threshold = HDatol( opt_arg );
+ options->fs_threshold = HDatol(opt_arg);
if(options->fs_threshold == 0)
/* To distinguish the "specified" zero value */
options->fs_threshold = -1;
@@ -570,12 +622,30 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
options->fs_pagesize = HDstrtoll(opt_arg, NULL, 0);
if(options->fs_pagesize == 0)
/* To distinguish the "specified" zero value */
- options->fs_pagesize = -1;
+ options->fs_pagesize = -1;
break;
- case 'E':
- enable_error_stack = TRUE;
- break;
+ case 'q':
+ if((sort_by = set_sort_by(opt_arg)) < 0) {
+ error_msg(" failed to set sort by form <%s>\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+ break;
+
+ case 'z':
+ if((sort_order = set_sort_order(opt_arg)) < 0) {
+ error_msg(" failed to set sort order form <%s>\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+ break;
+
+ case 'E':
+ enable_error_stack = TRUE;
+ break;
default:
break;
@@ -644,6 +714,9 @@ int main(int argc, const char **argv)
/* initialize options */
h5repack_init(&options, 0, FALSE);
+ /* Initialize default indexing options */
+ sort_by = H5_INDEX_CRT_ORDER;
+
if (parse_command_line(argc, argv, &options) < 0)
goto done;
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index 7e79aa7..4ff4875 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -55,11 +55,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
trav_table_t *travt = NULL;
int ok = 1;
hid_t fcpl_in = -1; /* file creation property for input file */
- hid_t fcpl_out = -1; /* file creation property for output file */
- H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */
- hbool_t in_persist, out_persist; /* free-space persist status for in/output file */
- hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */
- hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */
+ hid_t fcpl_out = -1; /* file creation property for output file */
+ H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */
+ hbool_t in_persist, out_persist; /* free-space persist status for in/output file */
+ hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */
+ hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */
/* open the output file */
if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
@@ -122,6 +122,8 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
if(options->all_filter == 1 || options->all_layout == 1)
{
+ /* Initialize indexing options */
+ h5trav_set_index(sort_by, sort_order);
/* init table */
trav_table_init(&travt);
@@ -455,6 +457,9 @@ int h5repack_cmp_pl(const char *fname1,
* get file table list of objects
*-------------------------------------------------------------------------
*/
+ /* Initialize indexing options */
+ h5trav_set_index(sort_by, sort_order);
+ /* init table */
trav_table_init(&trav);
if(h5trav_gettable(fid1, trav) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
@@ -643,7 +648,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
{
case H5Z_FILTER_NONE:
- break;
+ break;
case H5Z_FILTER_SHUFFLE:
/* 1 private client value is returned by DCPL */