summaryrefslogtreecommitdiffstats
path: root/src/H5Z.c
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2020-08-16 20:34:18 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2020-08-16 20:34:18 (GMT)
commit24c23c79d85fd3df3cfbaad41af7d64bb14220ee (patch)
treec084db393afb98b17cac7670e63791135c79f052 /src/H5Z.c
parentf02e0163724d6e6f611a36addc1cae7ef3800e05 (diff)
parent16349c5fddce8a74644e18d01d7ea8186aaaa255 (diff)
downloadhdf5-24c23c79d85fd3df3cfbaad41af7d64bb14220ee.zip
hdf5-24c23c79d85fd3df3cfbaad41af7d64bb14220ee.tar.gz
hdf5-24c23c79d85fd3df3cfbaad41af7d64bb14220ee.tar.bz2
Merge pull request #2771 in HDFFV/hdf5 from ~BMRIBLER/hdf5_bmr:hdf5_bmr_HDFFV-10933 to develop
Fixed HDFFV-10933 * commit '16349c5fddce8a74644e18d01d7ea8186aaaa255': Fixed HDFFV-10933
Diffstat (limited to 'src/H5Z.c')
-rw-r--r--src/H5Z.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/H5Z.c b/src/H5Z.c
index 0b70731..5c1cfd6 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -1004,6 +1004,73 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Z_ignore_filters
+ *
+ * Purpose: Determine whether filters can be ignored.
+ *
+ * Description:
+ * When the filters are optional (i.e., H5Z_FLAG_OPTIONAL is provided,)
+ * if any of the following conditions is met, the filters will be ignored:
+ * - dataspace is either H5S_NULL or H5S_SCALAR
+ * - datatype is variable-length (string or non-string)
+ * However, if any of these conditions exists and a filter is not
+ * optional, the function will produce an error.
+ *
+ * Return: Non-negative(TRUE/FALSE) on success
+ * Negative on failure
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5Z_ignore_filters(hid_t dcpl_id, const H5T_t *type, const H5S_t *space)
+{
+ H5P_genplist_t *dc_plist; /* Dataset creation property list object */
+ H5O_pline_t pline; /* Object's I/O pipeline information */
+ H5S_class_t space_class; /* To check class of space */
+ H5T_class_t type_class; /* To check if type is VL */
+ bool bad_for_filters = FALSE;/* Suitable to have filters */
+ htri_t ret_value = FALSE; /* TRUE for ignoring filters */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list")
+
+ /* Get pipeline information */
+ if (H5P_peek(dc_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't retrieve pipeline filter")
+
+ /* Get datatype and dataspace classes for quick access */
+ space_class = H5S_GET_EXTENT_TYPE(space);
+ type_class = H5T_get_class(type, FALSE);
+
+ /* These conditions are not suitable for filters */
+ bad_for_filters = (H5S_NULL == space_class || H5S_SCALAR == space_class
+ || H5T_VLEN == type_class
+ || (H5T_STRING == type_class && TRUE == H5T_is_variable_str(type)));
+
+ /* When these conditions occur, if there are required filters in pline,
+ then report a failure, otherwise, set flag that they can be ignored */
+ if (bad_for_filters) {
+ size_t ii;
+ if (pline.nused > 0) {
+ for (ii = 0; ii < pline.nused; ii++)
+ {
+ if (!(pline.filter[ii].flags & H5Z_FLAG_OPTIONAL))
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "not suitable for filters")
+ }
+
+ /* All filters are optional, we can ignore them */
+ ret_value = TRUE;
+ }
+ } /* bad for filters */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5Z_ignore_filters() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Z_modify
*
* Purpose: Modify filter parameters for specified pipeline.