summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-26 23:20:20 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-26 23:20:20 (GMT)
commitafc3563b76badc2345ca955d7d48fe16cceaf0c8 (patch)
treea691cf56cc1246acb05f7fc23a050c93f0d7bf6d /src
parent2a4253ceb8757c935304be24db989bd0f72effe8 (diff)
downloadhdf5-afc3563b76badc2345ca955d7d48fe16cceaf0c8.zip
hdf5-afc3563b76badc2345ca955d7d48fe16cceaf0c8.tar.gz
hdf5-afc3563b76badc2345ca955d7d48fe16cceaf0c8.tar.bz2
[svn-r8113] Purpose:
new library function H5Pdelete_filter deletes one or all filters from a dataset creation property list this was done for the NONE option of h5repack, added tests for this feature added a test for the new function in /test/dsets.c Description: Solution: Platforms tested: linux solaris AIX Misc. update:
Diffstat (limited to 'src')
-rw-r--r--src/H5Pdcpl.c49
-rw-r--r--src/H5Ppublic.h2
-rw-r--r--src/H5Z.c80
-rw-r--r--src/H5Zprivate.h2
4 files changed, 133 insertions, 0 deletions
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index f61ebf0..5ee9c17 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -1621,3 +1621,52 @@ done:
FUNC_LEAVE_API(ret_value);
}
+/*-------------------------------------------------------------------------
+ * Function: H5Pdelete_filter
+ *
+ * Purpose: Deletes a filter from the dataset creation property list;
+ * deletes all filters if FILTER is H5Z_FILTER_NONE
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Pedro Vicente
+ * January 26, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5Pdelete_filter(hid_t plist_id, H5Z_filter_t filter)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ H5O_pline_t pline; /* Filter pipeline */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(H5Pdelete_filter, FAIL);
+ H5TRACE2("e","iZf",plist_id,filter);
+
+ /* Get the property list structure */
+ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
+
+ /* Get pipeline info */
+ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline");
+
+ if (pline.filter)
+ {
+ /* Delete filter */
+ if(H5Z_delete(&pline, filter) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter");
+
+ /* Put the I/O pipeline information back into the property list */
+ if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline");
+ }
+
+done:
+ FUNC_LEAVE_API(ret_value);
+}
+
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index cada129..3a7f754 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -299,6 +299,8 @@ H5_DLL herr_t H5Pset_hyper_vector_size(hid_t fapl_id, size_t size);
H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size/*out*/);
H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size);
H5_DLL herr_t H5Pget_small_data_block_size(hid_t fapl_id, hsize_t *size/*out*/);
+H5_DLL herr_t H5Pdelete_filter(hid_t plist_id, H5Z_filter_t filter);
+
#ifdef __cplusplus
}
diff --git a/src/H5Z.c b/src/H5Z.c
index 3a1b7a2..6aa984f 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -1084,3 +1084,83 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z_all_filters_avail() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Z_delete
+ *
+ * Purpose: Delete filter FILTER from pipeline PLINE;
+ * deletes all filters if FILTER is H5Z_FILTER_NONE
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Pedro Vicente
+ * Monday, January 26, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
+{
+ size_t idx; /* Index of filter in pipeline */
+ herr_t ret_value=SUCCEED; /* Return value */
+ size_t i, found=0;
+
+ FUNC_ENTER_NOAPI(H5Z_delete, FAIL)
+
+ /* Check args */
+ assert(pline);
+ assert(filter>=0 && filter<=H5Z_FILTER_MAX);
+
+ /* if the pipeline has no filters, just return */
+ if(pline->nused==0)
+ HGOTO_DONE(FALSE)
+
+ /* Delete all filters */
+ if (H5Z_FILTER_NONE==filter)
+ {
+ if(H5O_reset(H5O_PLINE_ID, pline)<0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info")
+ }
+ /* Delete filter */
+ else
+ {
+ /* Locate the filter in the pipeline */
+ for(idx=0; idx<pline->nused; idx++)
+ {
+ if(pline->filter[idx].id==filter)
+ {
+ found=1;
+ break;
+ }
+ }
+ /* filter was not found in the pipeline */
+ if (!found)
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline")
+
+ /* Free, reset */
+ H5MM_xfree(pline->filter[idx].name);
+ H5MM_xfree(pline->filter[idx].cd_values);
+ HDmemset(&pline->filter[idx], 0, sizeof (H5Z_filter_info_t));
+
+ /* Reorder array */
+ if (idx+1<pline->nused)
+ {
+ for(i=idx; i<pline->nused; i++)
+ {
+ pline->filter[i] = pline->filter[i+1];
+ }
+ }
+ /* Decrement number of used filters */
+ pline->nused--;
+
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}
+
+
+
diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h
index 08c0d93..d87f735 100644
--- a/src/H5Zprivate.h
+++ b/src/H5Zprivate.h
@@ -58,5 +58,7 @@ H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id);
H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline,
H5Z_filter_t filter);
H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline);
+H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter);
+
#endif