summaryrefslogtreecommitdiffstats
path: root/tools/src/h5repack/h5repack_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/h5repack/h5repack_main.c')
-rw-r--r--tools/src/h5repack/h5repack_main.c87
1 files changed, 80 insertions, 7 deletions
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;