summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2004-07-01 17:38:04 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2004-07-01 17:38:04 (GMT)
commiteab58732d86e9219fa9f41f9ab2e30fae94e4a7d (patch)
tree333b5f2c50c267c14611e042724a7f28d5156ab7 /src/H5D.c
parent3f500747fa0f4379e8e03b82f6d679628d55a8c3 (diff)
downloadhdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.zip
hdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.tar.gz
hdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.tar.bz2
[svn-r8781]
Purpose: HDF5 now supports SZIP with no encoder. Description: SZIP can be configured to have both encoder and decoder or just to have the decoder. HDF5 can now query the configuration of any filter, and will throw errors if users try to write using a filter with encoding disabled. Solution: Added H5Zget_filter_info function, changed API for H5Pget_filter and H5P_get_filter_by_id. See SZIP RFC. Platforms tested: Copper (fortran, C++, parallel), Sleipnir (C++), Arabica (fortran, C++), Verbena (fortran, C++) Misc. update:
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 7d1652d..5aa1076 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -2017,6 +2017,10 @@ done:
* whether we're working with an external file or not. Between the
* two, there is a conditional call to allocate space which isn't
* part of updating the cache.
+ *
+ * Nat Furrer and James Laird
+ * June 7, 2004
+ * Added checked_filters flag
*
*-------------------------------------------------------------------------
*/
@@ -2065,6 +2069,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")
@@ -2209,7 +2219,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
assert((unsigned)(new_dset->layout.u.chunk.ndims) <= NELMTS(new_dset->layout.u.chunk.dim));
new_dset->layout.u.chunk.addr = HADDR_UNDEF; /* Initialize to no address */
-
+
/*
* Chunked storage allows any type of data space extension, so we
* don't even bother checking.
@@ -2267,7 +2277,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size")
} /* end case */
break;
-
+
default:
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet")
} /* end switch */
@@ -2288,6 +2298,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
if (H5G_insert(loc, name, &new_dset->ent, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset")
+
/* Success */
ret_value = new_dset;
@@ -2810,10 +2821,14 @@ done:
*
* Modifications:
*
- * Raymond Lu
- * Tuesday, October 2, 2001
- * Changed the way to retrieve property for generic property
- * list.
+ * Raymond Lu
+ * Tuesday, October 2, 2001
+ * Changed the way to retrieve property for generic property
+ * list.
+ *
+ * Nat Furrer and James Laird
+ * June 7, 2004
+ * Added check for filter encode capability
*
*-------------------------------------------------------------------------
*/
@@ -2822,6 +2837,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)
@@ -2830,6 +2847,44 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
assert (dataset);
assert (size);
+ /* 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(! dataset->checked_filters)
+ {
+
+ 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;
+ }
+ }
+ }
+
/*
* NOTE: Restrictions on extensions were checked when the dataset was
* created. All extensions are allowed here since none should be