diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2002-03-13 16:35:31 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2002-03-13 16:35:31 (GMT) |
commit | 64658d1f9ffe5fc83b549b80396b39263ba3e0ad (patch) | |
tree | 80c04c793e887014e105fedbb958e367907966f4 /src/H5D.c | |
parent | bbc50c3a1f3096959f09bce67e993267bda9df24 (diff) | |
download | hdf5-64658d1f9ffe5fc83b549b80396b39263ba3e0ad.zip hdf5-64658d1f9ffe5fc83b549b80396b39263ba3e0ad.tar.gz hdf5-64658d1f9ffe5fc83b549b80396b39263ba3e0ad.tar.bz2 |
[svn-r5062]
Purpose:
code clean up
Description:
just some clean up of the functions H5D_set_extend and H5S_set_extend before the big change
(changing chunk info in the b-tree struct of the dataset)
Platforms tested:
w2000, eirene
Diffstat (limited to 'src/H5D.c')
-rw-r--r-- | src/H5D.c | 279 |
1 files changed, 151 insertions, 128 deletions
@@ -1277,134 +1277,6 @@ H5Dextend(hid_t dset_id, const hsize_t *size) -/*------------------------------------------------------------------------- - * 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); -} - - @@ -3743,3 +3615,154 @@ H5Ddebug(hid_t dset_id, unsigned UNUSED flags) 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 + * Robb Matzke + * + * Date: March 13, 2002 + * + * Comments: Public function, calls private H5D_set_extend + * + * 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" ); + } + + /* Modify size */ + if ( H5D_set_extend (dset, size) < 0 ) + { + HRETURN_ERROR( H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set 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 + * Robb Matzke + * + * Date: March 13, 2002 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ + +herr_t H5D_set_extend( H5D_t *dataset, const hsize_t *size ) +{ + herr_t changed; + herr_t ret_value = FAIL; + H5S_t *space = NULL; + H5O_fill_t fill; + H5P_genplist_t *plist; + + 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 modify 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"); + + + /* Remove the chunk from the raw data cache */ + + if ( H5D_CHUNKED == dataset->layout.type ) + { + + + + } + + + + } /* end if changed */ + + + ret_value = SUCCEED; + +done: + H5S_close(space); + FUNC_LEAVE (ret_value); +} + + |