diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2002-02-07 20:20:40 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2002-02-07 20:20:40 (GMT) |
commit | 472c42233cbd207bb0c3f97b12ee57dd5cec030b (patch) | |
tree | c5dfea35d484215d7ad0811cd15184585400b183 /src | |
parent | d8626dd40f82baf616134cfd179b894429fce501 (diff) | |
download | hdf5-472c42233cbd207bb0c3f97b12ee57dd5cec030b.zip hdf5-472c42233cbd207bb0c3f97b12ee57dd5cec030b.tar.gz hdf5-472c42233cbd207bb0c3f97b12ee57dd5cec030b.tar.bz2 |
[svn-r4921]
Description:
modified the below files to inlude a new public function H5Dset_extend, similar
to H5Dextend, but it can lower the dimension
this function requires 2 more new private functions:
H5D_set_extend
H5S_set_extend
Platforms tested:
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 137 | ||||
-rw-r--r-- | src/H5Dprivate.h | 1 | ||||
-rw-r--r-- | src/H5Dpublic.h | 1 | ||||
-rw-r--r-- | src/H5S.c | 62 | ||||
-rw-r--r-- | src/H5Sprivate.h | 1 |
5 files changed, 202 insertions, 0 deletions
@@ -1275,6 +1275,139 @@ H5Dextend(hid_t dset_id, const hsize_t *size) FUNC_LEAVE (SUCCEED); } + + +/*------------------------------------------------------------------------- + * Function: H5Dset_extend + * + * Purpose: Modifies the dimensions of a dataset, based on H5Dextend + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 26, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ + + +herr_t +H5Dset_extend(hid_t dset_id, const hsize_t *size) +{ + H5D_t *dset = NULL; + + FUNC_ENTER (H5Dset_extend, FAIL); + H5TRACE2("e","i*h",dset_id,size); + + /* Check args */ + if (H5I_DATASET!=H5I_get_type(dset_id) || + NULL==(dset=H5I_object(dset_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + } + if (!size) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified"); + } + + /* Increase size */ + if (H5D_set_extend (dset, size)<0) { + HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to extend dataset"); + } + + FUNC_LEAVE (SUCCEED); +} + + + +/*------------------------------------------------------------------------- + * Function: H5D_set_extend + * + * Purpose: Same as H5D_extend, allows change to a lower dimension, calls H5S_modify + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 26, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ + +herr_t +H5D_set_extend (H5D_t *dataset, const hsize_t *size) +{ + herr_t changed, ret_value=FAIL; + H5S_t *space = NULL; + H5O_fill_t fill; + H5P_genplist_t *plist; /* Property list */ + + FUNC_ENTER (H5D_set_extend, FAIL); + + /* Check args */ + assert (dataset); + assert (size); + + /* + * NOTE: Restrictions on extensions were checked when the dataset was + * created. All extensions are allowed here since none should be + * able to muck things up. + */ + + /* Increase the size of the data space */ + if (NULL==(space=H5S_read (&(dataset->ent)))) + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data space info from dataset header"); + if ((changed = H5S_set_extend (space, size))<0) + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of data space"); + + if (changed>0){ + /* Save the new dataspace in the file if necessary */ + if (H5S_modify (&(dataset->ent), space)<0) + HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace"); + + /* Initialize the new parts of the dataset */ +#ifdef LATER + if (H5S_select_all(space)<0 || + H5S_select_hyperslab(space, H5S_SELECT_DIFF, zero, NULL, old_dims, NULL)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to select new extents for fill value"); +#else + /* + * We don't have the H5S_SELECT_DIFF operator yet. We really only + * need it for contiguous datasets because the chunked datasets will + * either fill on demand during I/O or attempt a fill of all chunks. + */ + if (NULL == (plist = H5I_object(dataset->dcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); + if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value"); + if(H5D_CONTIGUOUS == dataset->layout.type && fill.buf) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to select fill value region"); +#endif + if (H5D_init_storage(dataset, space)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value"); + } /* end if */ + + ret_value = SUCCEED; + +done: + H5S_close(space); + FUNC_LEAVE (ret_value); +} + + + + + /*------------------------------------------------------------------------- * Function: H5D_new @@ -2938,6 +3071,10 @@ done: H5S_close(space); FUNC_LEAVE (ret_value); } + + + + /*------------------------------------------------------------------------- diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index b2fb668..1c7d940 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -155,6 +155,7 @@ __DLL__ herr_t H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, const void *buf); __DLL__ herr_t H5D_extend(H5D_t *dataset, const hsize_t *size); +__DLL__ herr_t H5D_set_extend(H5D_t *dataset, const hsize_t *size); __DLL__ H5G_entry_t *H5D_entof(H5D_t *dataset); __DLL__ H5T_t *H5D_typeof(H5D_t *dset); __DLL__ H5S_t *H5D_get_space(H5D_t *dset); diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 056fb43..b889c35 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -52,6 +52,7 @@ __DLL__ herr_t H5Dread (hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, __DLL__ herr_t H5Dwrite (hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf); __DLL__ herr_t H5Dextend (hid_t dset_id, const hsize_t *size); +__DLL__ herr_t H5Dset_extend (hid_t dset_id, const hsize_t *size); __DLL__ herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data); __DLL__ herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf); @@ -1654,6 +1654,68 @@ H5S_extend (H5S_t *space, const hsize_t *size) FUNC_LEAVE (ret_value); } + + + + +/*------------------------------------------------------------------------- + * Function: H5S_set_extend + * + * Purpose: Modify the dimensions of a data space. Based on H5S_extend + * + * Return: Success: Number of dimensions whose size increased. + * + * Failure: Negative + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 26, 2001 + * + *------------------------------------------------------------------------- + */ + +int +H5S_set_extend (H5S_t *space, const hsize_t *size) +{ + int ret_value=0; + unsigned u; + + FUNC_ENTER (H5S_extend, FAIL); + + /* Check args */ + assert (space && H5S_SIMPLE==space->extent.type); + assert (size); + + for (u=0; u<space->extent.u.simple.rank; u++) + { + + if (space->extent.u.simple.max && + H5S_UNLIMITED!=space->extent.u.simple.max[u] && + space->extent.u.simple.max[u]<size[u]) + { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,"dimension cannot be increased"); + } + + ret_value++; + + } + + /* Update */ + if (ret_value) + { + for (u=0; u<space->extent.u.simple.rank; u++) + { + + space->extent.u.simple.size[u] = size[u]; + + } + } + + FUNC_LEAVE (ret_value); +} + + + /*------------------------------------------------------------------------- * Function: H5Screate_simple diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 0893d59..42986d7 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -209,6 +209,7 @@ __DLL__ herr_t H5S_extent_release(H5S_t *space); __DLL__ herr_t H5S_select_release(H5S_t *space); __DLL__ hssize_t H5S_get_select_npoints(const H5S_t *space); __DLL__ int H5S_extend(H5S_t *space, const hsize_t *size); +__DLL__ int H5S_set_extend(H5S_t *space, const hsize_t *size); __DLL__ htri_t H5S_select_valid(const H5S_t *space); __DLL__ herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); |