2003-10-23 05:55:07 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-10-23 05:55:07 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-10-23 05:55:07 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef H5REPACK_H__
|
|
|
|
#define H5REPACK_H__
|
|
|
|
|
2011-02-15 06:20:32 +08:00
|
|
|
#include "H5private.h"
|
2003-10-23 05:55:07 +08:00
|
|
|
#include "hdf5.h"
|
2003-12-05 03:35:33 +08:00
|
|
|
#include "h5trav.h"
|
2004-03-03 02:12:25 +08:00
|
|
|
|
2004-01-16 00:48:48 +08:00
|
|
|
#define H5FOPENERROR "unable to open file"
|
2008-05-01 03:51:13 +08:00
|
|
|
#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/
|
|
|
|
#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/
|
|
|
|
#define MAX_NC_NAME 256 /* max length of a name */
|
|
|
|
#define MAX_VAR_DIMS 32 /* max per variable dimensions */
|
2008-08-29 03:47:26 +08:00
|
|
|
#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */
|
|
|
|
#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
|
2012-04-12 04:57:10 +08:00
|
|
|
#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */
|
2003-10-23 05:55:07 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* data structures for command line options
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* a list of names */
|
|
|
|
typedef struct {
|
2005-08-14 04:53:35 +08:00
|
|
|
char obj[MAX_NC_NAME];
|
2003-10-23 05:55:07 +08:00
|
|
|
} obj_list_t;
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
|
|
|
the type of filter and additional parameter
|
2003-10-23 05:55:07 +08:00
|
|
|
type can be one of the filters
|
2005-09-20 05:12:35 +08:00
|
|
|
H5Z_FILTER_NONE 0, uncompress if compressed
|
2006-01-24 04:46:34 +08:00
|
|
|
H5Z_FILTER_DEFLATE 1 , deflation like gzip
|
2005-09-20 05:12:35 +08:00
|
|
|
H5Z_FILTER_SHUFFLE 2 , shuffle the data
|
|
|
|
H5Z_FILTER_FLETCHER32 3 , letcher32 checksum of EDC
|
|
|
|
H5Z_FILTER_SZIP 4 , szip compression
|
2006-06-27 22:45:06 +08:00
|
|
|
H5Z_FILTER_NBIT 5 , nbit compression
|
|
|
|
H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression
|
2003-10-23 05:55:07 +08:00
|
|
|
*/
|
2003-12-30 04:26:21 +08:00
|
|
|
|
2007-12-15 05:38:23 +08:00
|
|
|
#define CD_VALUES 20
|
2003-12-30 04:26:21 +08:00
|
|
|
|
2003-10-23 05:55:07 +08:00
|
|
|
typedef struct {
|
2007-12-15 03:16:01 +08:00
|
|
|
H5Z_filter_t filtn; /* filter identification number */
|
2008-01-03 03:40:20 +08:00
|
|
|
unsigned cd_values[CD_VALUES]; /* filter client data values */
|
2007-12-15 03:16:01 +08:00
|
|
|
size_t cd_nelmts; /* filter client number of values */
|
2003-12-30 04:26:21 +08:00
|
|
|
} filter_info_t;
|
2003-10-23 05:55:07 +08:00
|
|
|
|
|
|
|
/* chunk lengths along each dimension and rank */
|
|
|
|
typedef struct {
|
2005-08-14 04:53:35 +08:00
|
|
|
hsize_t chunk_lengths[MAX_VAR_DIMS];
|
2003-10-23 05:55:07 +08:00
|
|
|
int rank;
|
|
|
|
} chunk_info_t;
|
|
|
|
|
2004-01-07 01:49:00 +08:00
|
|
|
/* we currently define a maximum value for the filters array,
|
|
|
|
that corresponds to the current library filters */
|
2005-09-20 05:12:35 +08:00
|
|
|
#define H5_REPACK_MAX_NFILTERS 6
|
2004-01-07 01:49:00 +08:00
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
/* information for one object, contains PATH, CHUNK info and FILTER info */
|
2003-10-23 05:55:07 +08:00
|
|
|
typedef struct {
|
2004-01-07 01:49:00 +08:00
|
|
|
char path[MAX_NC_NAME]; /* name of object */
|
|
|
|
filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */
|
|
|
|
int nfilters; /* current number of filters */
|
|
|
|
H5D_layout_t layout; /* layout information */
|
|
|
|
chunk_info_t chunk; /* chunk information */
|
|
|
|
hid_t refobj_id; /* object ID, references */
|
2003-10-23 05:55:07 +08:00
|
|
|
} pack_info_t;
|
|
|
|
|
2003-10-29 01:40:05 +08:00
|
|
|
/* store a table of all objects */
|
2003-10-23 05:55:07 +08:00
|
|
|
typedef struct {
|
2006-11-17 04:38:05 +08:00
|
|
|
unsigned int size;
|
|
|
|
unsigned int nelems;
|
|
|
|
pack_info_t *objs;
|
2003-10-29 01:40:05 +08:00
|
|
|
} pack_opttbl_t;
|
2003-10-23 05:55:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* command line options
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* all the above, ready to go to the hrepack call */
|
|
|
|
typedef struct {
|
2003-12-30 04:26:21 +08:00
|
|
|
pack_opttbl_t *op_tbl; /*table with all -c and -f options */
|
2003-12-31 06:59:33 +08:00
|
|
|
int all_layout; /*apply the layout to all objects */
|
|
|
|
int all_filter; /*apply the filter to all objects */
|
2007-12-05 03:59:54 +08:00
|
|
|
filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */
|
|
|
|
int n_filter_g; /*number of global filters */
|
2003-10-23 05:55:07 +08:00
|
|
|
chunk_info_t chunk_g; /*global chunk INFO for the ALL case */
|
2003-12-31 06:59:33 +08:00
|
|
|
H5D_layout_t layout_g; /*global layout information for the ALL case */
|
2006-10-20 01:07:26 +08:00
|
|
|
int verbose; /*verbose mode */
|
2008-08-29 03:47:26 +08:00
|
|
|
hsize_t min_comp; /*minimum size to compress, in bytes */
|
2010-01-30 12:29:13 +08:00
|
|
|
int use_native; /*use a native type in write */
|
2007-07-14 02:18:48 +08:00
|
|
|
int latest; /*pack file with the latest file format */
|
|
|
|
int grp_compact; /* Set the maximum number of links to store as header messages in the group */
|
|
|
|
int grp_indexed; /* Set the minimum number of links to store in the indexed format */
|
2010-01-30 12:29:13 +08:00
|
|
|
int msg_size[8]; /* Minimum size of shared messages: dataspace,
|
2007-07-14 02:18:48 +08:00
|
|
|
datatype, fill value, filter pipleline, attribute */
|
2008-08-22 23:53:07 +08:00
|
|
|
const char *ublock_filename; /* user block file name */
|
2008-09-18 22:44:21 +08:00
|
|
|
hsize_t ublock_size; /* user block size */
|
2012-03-29 18:49:38 +08:00
|
|
|
hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */
|
2008-08-29 03:47:26 +08:00
|
|
|
hsize_t threshold; /* alignment threshold for H5Pset_alignment */
|
|
|
|
hsize_t alignment ; /* alignment for H5Pset_alignment */
|
[svn-r17582] Description:
Bring changes from file free space branch back to the trunk. *yay!*
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-02 10:08:59 +08:00
|
|
|
H5F_file_space_type_t fs_strategy; /* File space handling strategy */
|
|
|
|
hsize_t fs_threshold; /* Free space section threshold */
|
2003-10-29 01:40:05 +08:00
|
|
|
} pack_opt_t;
|
2003-10-23 05:55:07 +08:00
|
|
|
|
|
|
|
|
2010-03-26 01:29:51 +08:00
|
|
|
typedef struct named_dt_t {
|
|
|
|
haddr_t addr_in; /* Address of the named dtype in the in file */
|
|
|
|
hid_t id_out; /* Open identifier for the dtype in the out file */
|
|
|
|
struct named_dt_t *next; /* Next dtype */
|
|
|
|
} named_dt_t;
|
2003-10-23 05:55:07 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* public functions
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
[svn-r17582] Description:
Bring changes from file free space branch back to the trunk. *yay!*
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-02 10:08:59 +08:00
|
|
|
int h5repack(const char* infile, const char* outfile, pack_opt_t *options);
|
|
|
|
int h5repack_addfilter(const char* str, pack_opt_t *options);
|
|
|
|
int h5repack_addlayout(const char* str, pack_opt_t *options);
|
|
|
|
int h5repack_init(pack_opt_t *options, int verbose, H5F_file_space_type_t strategy, hsize_t threshold);
|
|
|
|
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);
|
2004-01-07 01:49:00 +08:00
|
|
|
|
2010-03-26 01:29:51 +08:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options);
|
|
|
|
int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err);
|
|
|
|
int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p,
|
|
|
|
trav_table_t *travt, pack_opt_t *options);
|
2003-10-23 05:55:07 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
|
|
|
|
|
2003-10-24 03:51:51 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* private functions
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-01-04 04:45:18 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* copy module
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
int copy_objects (const char* fnamein,
|
|
|
|
const char* fnameout,
|
|
|
|
pack_opt_t *options);
|
2003-12-05 03:35:33 +08:00
|
|
|
|
2007-03-02 05:36:43 +08:00
|
|
|
int do_copy_refobjs(hid_t fidin,
|
2005-08-14 04:53:35 +08:00
|
|
|
hid_t fidout,
|
2004-01-15 01:45:20 +08:00
|
|
|
trav_table_t *travt,
|
2010-01-30 12:29:13 +08:00
|
|
|
pack_opt_t *options);
|
2003-12-05 03:35:33 +08:00
|
|
|
|
2008-01-04 04:45:18 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* filters and verify module
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2004-01-08 23:53:32 +08:00
|
|
|
void init_packobject(pack_info_t *obj);
|
|
|
|
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2008-01-04 04:45:18 +08:00
|
|
|
* filters and copy module
|
2003-12-30 04:26:21 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2004-02-11 02:33:20 +08:00
|
|
|
int apply_filters(const char* name, /* object name from traverse list */
|
|
|
|
int rank, /* rank of dataset */
|
|
|
|
hsize_t *dims, /* dimensions of dataset */
|
2008-11-21 23:39:06 +08:00
|
|
|
size_t msize, /* size of type */
|
2008-01-04 04:45:18 +08:00
|
|
|
hid_t dcpl_id, /* dataset creation property list */
|
2007-05-25 03:09:36 +08:00
|
|
|
pack_opt_t *options, /* repack options */
|
2008-01-04 04:45:18 +08:00
|
|
|
int *has_filter); /* (OUT) object NAME has a filter */
|
2003-12-30 04:26:21 +08:00
|
|
|
|
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* options table
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int options_table_init( pack_opttbl_t **tbl );
|
|
|
|
int options_table_free( pack_opttbl_t *table );
|
2003-12-31 06:59:33 +08:00
|
|
|
int options_add_layout( obj_list_t *obj_list,
|
2003-12-05 03:35:33 +08:00
|
|
|
int n_objs,
|
2003-12-31 06:59:33 +08:00
|
|
|
pack_info_t *pack,
|
2003-12-05 03:35:33 +08:00
|
|
|
pack_opttbl_t *table );
|
2003-12-30 04:26:21 +08:00
|
|
|
int options_add_filter ( obj_list_t *obj_list,
|
2003-12-05 03:35:33 +08:00
|
|
|
int n_objs,
|
2003-12-30 04:26:21 +08:00
|
|
|
filter_info_t filt,
|
2003-12-05 03:35:33 +08:00
|
|
|
pack_opttbl_t *table );
|
|
|
|
pack_info_t* options_get_object( const char *path,
|
|
|
|
pack_opttbl_t *table);
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* parse functions
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
obj_list_t* parse_filter(const char *str,
|
|
|
|
int *n_objs,
|
2003-12-30 04:26:21 +08:00
|
|
|
filter_info_t *filt,
|
2007-11-29 04:30:43 +08:00
|
|
|
pack_opt_t *options,
|
|
|
|
int *is_glb);
|
2003-12-31 06:59:33 +08:00
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
obj_list_t* parse_layout(const char *str,
|
|
|
|
int *n_objs,
|
2003-12-31 06:59:33 +08:00
|
|
|
pack_info_t *pack, /* info about object */
|
2003-12-30 04:26:21 +08:00
|
|
|
pack_opt_t *options);
|
2003-12-31 06:59:33 +08:00
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
|
2003-10-23 05:55:07 +08:00
|
|
|
#endif /* H5REPACK_H__ */
|
2006-01-24 04:46:34 +08:00
|
|
|
|