diff options
author | Nat Furrer <nfurrer@ncsa.uiuc.edu> | 2004-06-28 19:46:03 (GMT) |
---|---|---|
committer | Nat Furrer <nfurrer@ncsa.uiuc.edu> | 2004-06-28 19:46:03 (GMT) |
commit | 6d682a5a28f1ad599db5ad77e135b25a2efe7ae7 (patch) | |
tree | 678b86bf8d678460c0db11fa9cb9e09f40206775 /src | |
parent | 903580837a2e43d2b72c39206746a20d840c54e8 (diff) | |
download | hdf5-6d682a5a28f1ad599db5ad77e135b25a2efe7ae7.zip hdf5-6d682a5a28f1ad599db5ad77e135b25a2efe7ae7.tar.gz hdf5-6d682a5a28f1ad599db5ad77e135b25a2efe7ae7.tar.bz2 |
[svn-r8753]
Purpose:
Handled SZIP without the encoder present.
Description:
It is now an error for a user to try to create, extend, or write to a
dataset without the encoder present in their SZIP library.
Added H5Zget_filter_info to provide users with a way to query HDF5
about the presence (or lack thereof) of the SZIP encoder.
Platforms tested:
Windows
Verbena
Arabica
Copper
Misc. update:
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 53 | ||||
-rw-r--r-- | src/H5Dio.c | 24 | ||||
-rw-r--r-- | src/H5Dpkg.h | 1 | ||||
-rw-r--r-- | src/H5E.c | 3 | ||||
-rw-r--r-- | src/H5Epublic.h | 4 | ||||
-rw-r--r-- | src/H5MPprivate.h | 1 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 8 | ||||
-rw-r--r-- | src/H5Z.c | 53 | ||||
-rw-r--r-- | src/H5Zpublic.h | 6 | ||||
-rw-r--r-- | src/H5Zszip.c | 1 | ||||
-rw-r--r-- | src/H5config.h.in | 3 |
11 files changed, 152 insertions, 5 deletions
@@ -1962,6 +1962,12 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space if(NULL == (new_dset = H5D_new(dcpl_id,TRUE,has_vl_type))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + /* + * Set the dataset's checked_filters flag to enable writing. + * Make sure that H5Z_can_apply is called at the beginning of this function! + */ + new_dset->checked_filters = TRUE; + /* Make the "set local" filter callbacks for this dataset */ if(H5Z_set_local(new_dset->dcpl_id,type_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") @@ -2718,6 +2724,9 @@ done: * Changed the way to retrieve property for generic property * list. * + * Nat Furrer and James Laird + * June 17, 2004 + * Added check for filter encode capability *------------------------------------------------------------------------- */ static herr_t @@ -2725,6 +2734,8 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) { int changed; /* Flag to indicate that the dataspace was successfully extended */ H5S_t *space = NULL; /* Dataset's dataspace */ + H5D_fill_value_t fill_status; + H5D_fill_time_t fill_time; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_extend, FAIL) @@ -2739,6 +2750,48 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) * able to muck things up. */ + if(! dataset->checked_filters) + { + /* Check if the filters in the DCPL will need to encode, and if so, can they? + * Filters need encoding if fill value is defined and a fill policy is set that requires + * writing on an extend. + */ + if(H5P_is_fill_value_defined(&(dataset->fill), &fill_status) < 0) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset."); + } + + if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) + { + if( H5Pget_fill_time(dataset->dcpl_id, &fill_time) < 0) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset."); + } + + if(fill_time == H5D_FILL_TIME_ALLOC || + (fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED) ) + { + /* Filters must have encoding enabled. Ensure that all filters can be applied */ + hid_t type_id; + + type_id = H5I_register(H5I_DATATYPE, dataset->type); + if(type_id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type") + + if(H5Z_can_apply(dataset->dcpl_id, type_id) <0) + { + H5I_remove(type_id); + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") + } + + if(H5I_remove(type_id) == NULL) + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id") + + dataset->checked_filters = TRUE; + } + } + } + /* Increase the size of the data space */ space=dataset->space; if ((changed=H5S_extend (space, size))<0) diff --git a/src/H5Dio.c b/src/H5Dio.c index 5220884..1e6edf7 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -837,6 +837,9 @@ done: * Removed the must_convert parameter and move preconditions to * H5S_<foo>_opt_possible() routine * + * Nat Furrer and James Laird + * June 17, 2004 + * Added check for filter encode capability *------------------------------------------------------------------------- */ static herr_t @@ -864,6 +867,27 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, assert(mem_type); assert(buf); + /* All filters in the DCPL must have encoding enabled. */ + if(! dataset->checked_filters) + { + hid_t type_id; + + type_id = H5I_register(H5I_DATATYPE, dataset->type); + if(type_id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type") + + if(H5Z_can_apply(dataset->dcpl_id, type_id) <0) + { + H5I_remove(type_id); + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") + } + + if(H5I_remove(type_id) == NULL) + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id") + + dataset->checked_filters = TRUE; + } + /* If MPI based VFD is used, no VL datatype support yet. */ /* This is because they use the global heap in the file and we don't */ /* support parallel access of that yet */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index b72a13d..18af011 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -83,6 +83,7 @@ struct H5D_t { hid_t dcpl_id; /* dataset creation property id */ H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */ H5O_layout_t layout; /* data layout */ + hbool_t checked_filters;/* TRUE if dataset passes can_apply check */ /* Cache some frequently accessed values from the DCPL */ H5O_efl_t efl; /* External file list information */ @@ -187,7 +187,8 @@ static const H5E_minor_mesg_t H5E_minor_mesg_g[] = { {H5E_NOFILTER, "Requested filter is not available"}, {H5E_CALLBACK, "Callback failed"}, {H5E_CANAPPLY, "Error from filter \"can apply\" callback"}, - {H5E_SETLOCAL, "Error from filter \"set local\" callback"} + {H5E_SETLOCAL, "Error from filter \"set local\" callback"}, + {H5E_NOENCODER, "Filter present, but encoder not enabled"} }; diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 6840dd5..3ac6fd0 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -218,8 +218,8 @@ typedef enum H5E_minor_t { H5E_NOFILTER, /*requested filter is not available */ H5E_CALLBACK, /*callback failed */ H5E_CANAPPLY, /*error from filter "can apply" callback */ - H5E_SETLOCAL /*error from filter "set local" callback */ - + H5E_SETLOCAL, /*error from filter "set local" callback */ + H5E_NOENCODER /* Filter present, but encoding disabled */ } H5E_minor_t; /* Information about an error */ diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h index 2eeffe4..634d408 100644 --- a/src/H5MPprivate.h +++ b/src/H5MPprivate.h @@ -390,6 +390,7 @@ #define color_H5Zregister "red" #define color_H5Zfilter_avail "red" #define color_H5Zunregister "red" +#define color_H5Zget_filter_info "red" #else #define MPE_LOG_VARS(func_name) /* void */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 6466c3e..95bc649 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1003,6 +1003,10 @@ done: * * Modifications: * + * Nat Furrer and James Laird + * June 17, 2004 + * Now ensures that SZIP encoding is enabled + * *------------------------------------------------------------------------- */ herr_t @@ -1017,6 +1021,9 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) H5TRACE3("e","iIuIu",plist_id,options_mask,pixels_per_block); /* Check arguments */ +#if !defined( H5_SZIP_CAN_ENCODE) && defined(H5_HAVE_FILTER_SZIP) + HGOTO_ERROR (H5E_PLINE, H5E_NOENCODER, FAIL, "Szip filter present but encoding disabled"); +#endif if ((pixels_per_block%2)==1) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even"); if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK) @@ -1642,3 +1649,4 @@ H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) done: FUNC_LEAVE_API(ret_value); } + @@ -574,8 +574,15 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty case H5Z_PRELUDE_CAN_APPLY: /* Check if there is a "can apply" callback */ if(fclass->can_apply) { + herr_t status; +#ifndef H5_SZIP_CAN_ENCODE + /* If this is the Szip filter, make sure it can encode */ + if (dcpl_pline.filter[u].id == H5Z_FILTER_SZIP) + HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled"); +#endif + /* Make callback to filter's "can apply" function */ - herr_t status=(fclass->can_apply)(dcpl_id, type_id, space_id); + status=(fclass->can_apply)(dcpl_id, type_id, space_id); /* Check return value */ if(status<=0) { @@ -1210,3 +1217,47 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) done: FUNC_LEAVE_NOAPI(ret_value) } + +/*------------------------------------------------------------------------- + * Function: H5Zget_filter_info + * + * Purpose: Gets information about a pipeline data filter and stores it + * in filter_config_flags. + * + * Return: zero on success / negative on failure + * + * Programmer: James Laird and Nat Furrer + * Monday, June 7, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(H5Zget_filter_info, FAIL) + + if (filter_config_flags != NULL) + { + if (filter == H5Z_FILTER_SZIP) + { + *filter_config_flags = 0; +#ifdef H5_SZIP_CAN_ENCODE + *filter_config_flags |= H5Z_FILTER_CONFIG_ENCODE_ENABLED; +#endif + *filter_config_flags |= H5Z_FILTER_CONFIG_DECODE_ENABLED; + } + else + *filter_config_flags = H5Z_FILTER_CONFIG_DECODE_ENABLED | H5Z_FILTER_CONFIG_ENCODE_ENABLED; + + /* Make sure the filter exists */ + if (H5Z_find(filter) == NULL) + *filter_config_flags = 0; + } + +done: + FUNC_LEAVE_API(ret_value) +} + diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index 8fd775d..e4db1b0 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -66,6 +66,10 @@ typedef enum H5Z_EDC_t { H5Z_NO_EDC = 2 /* must be the last */ } H5Z_EDC_t; +/* Bit flags for H5Zget_filter_info */ +#define H5Z_FILTER_CONFIG_ENCODE_ENABLED (0x0001) +#define H5Z_FILTER_CONFIG_DECODE_ENABLED (0x0002) + /* Return values for filter callback function */ typedef enum H5Z_cb_return_t { H5Z_CB_ERROR = -1, @@ -172,7 +176,7 @@ H5_DLL herr_t H5Zregister(const H5Z_class_t *cls); #endif /* H5_WANT_H5_V1_4_COMPAT */ H5_DLL herr_t H5Zunregister(H5Z_filter_t id); H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); - +H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); #ifdef __cplusplus } diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 76cf017..7df0be2 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -327,5 +327,6 @@ done: H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value); } + #endif /* H5_HAVE_FILTER_SZIP */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 6a0c8dd..e6c92d7 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -496,6 +496,9 @@ PTHREAD_SCOPE_SYSTEM) call. */ #undef SYSTEM_SCOPE_THREADS +/* Define if szip encoder is present */ +#undef SZIP_CAN_ENCODE + /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #undef TIME_WITH_SYS_TIME |