summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c193
1 files changed, 7 insertions, 186 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 7173bbc..46954f0 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -450,7 +450,6 @@ hid_t
H5Dget_space(hid_t dset_id)
{
H5D_t *dset = NULL;
- H5S_t *space = NULL;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -460,22 +459,10 @@ H5Dget_space(hid_t dset_id)
if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
- /* Read the dataspace message and return a dataspace object */
- if(NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE)))
+ if((ret_value = H5D_get_space(dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace")
- /* Create an atom */
- if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace")
-
done:
- if(ret_value < 0) {
- if(space!=NULL) {
- if(H5S_close(space) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
- } /* end if */
- } /* end if */
-
FUNC_LEAVE_API(ret_value)
}
@@ -504,7 +491,7 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation)
H5TRACE2("e", "i*Ds", dset_id, allocation);
/* Check arguments */
- if(NULL==(dset=(H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
+ if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
/* Read dataspace address and return */
@@ -537,7 +524,6 @@ H5Dget_type(hid_t dset_id)
{
H5D_t *dset; /* Dataset */
- H5T_t *dt = NULL; /* Datatype to return */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -547,32 +533,10 @@ H5Dget_type(hid_t dset_id)
if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
- /* Patch the datatype's "top level" file pointer */
- if(H5T_patch_file(dset->shared->type, dset->oloc.file) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to patch datatype's file pointer")
-
- /* Copy the dataset's datatype */
- if(NULL == (dt = H5T_copy(dset->shared->type, H5T_COPY_REOPEN)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype")
-
- /* Mark any datatypes as being in memory now */
- if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
-
- /* Lock copied type */
- if(H5T_lock(dt, FALSE) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype")
-
- /* Create an atom */
- if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
+ if((ret_value = H5D_get_type(dset)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace")
done:
- if(ret_value < 0) {
- if(dt && H5T_close(dt) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
- } /* end if */
-
FUNC_LEAVE_API(ret_value)
} /* end H5Dget_type() */
@@ -607,7 +571,7 @@ H5Dget_create_plist(hid_t dset_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if((ret_value = H5D_get_create_plist(dataset)) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get creation plist")
done:
FUNC_LEAVE_API(ret_value)
@@ -615,123 +579,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5D_get_create_plist
- *
- * Purpose: Private function for H5Dget_create_plist
- *
- * Return: Success: ID for a copy of the dataset creation
- * property list. The template should be
- * released by calling H5P_close().
- *
- * Failure: FAIL
- *
- * Programmer: Robb Matzke
- * Tuesday, February 3, 1998
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5D_get_create_plist(H5D_t *dset)
-{
- H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */
- H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */
- H5O_fill_t copied_fill; /* Fill value to tweak */
- hid_t new_dcpl_id = FAIL;
- hid_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- if(NULL == (dcpl_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
-
- /* Copy the creation property list */
- if((new_dcpl_id = H5P_copy_plist(dcpl_plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list")
- if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
-
- /* Retrieve any object creation properties */
- if(H5O_get_create_plist(&dset->oloc, H5AC_ind_dxpl_id, new_plist) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object creation info")
-
- /* Get the fill value property */
- if(H5P_get(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value")
-
- /* Check if there is a fill value, but no type yet */
- if(copied_fill.buf != NULL && copied_fill.type == NULL) {
- H5T_path_t *tpath; /* Conversion information*/
-
- /* Copy the dataset type into the fill value message */
- if(NULL == (copied_fill.type = H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset datatype for fill value")
-
- /* Set up type conversion function */
- if(NULL == (tpath = H5T_path_find(dset->shared->type, copied_fill.type, NULL, NULL, H5AC_ind_dxpl_id, FALSE)))
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types")
-
- /* Convert disk form of fill value into memory form */
- if(!H5T_path_noop(tpath)) {
- hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */
- uint8_t *bkg_buf = NULL; /* Background conversion buffer */
- size_t bkg_size; /* Size of background buffer */
-
- /* Wrap copies of types to convert */
- dst_id = H5I_register(H5I_DATATYPE, H5T_copy(copied_fill.type, H5T_COPY_TRANSIENT), FALSE);
- if(dst_id < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
- src_id = H5I_register(H5I_DATATYPE, H5T_copy(dset->shared->type, H5T_COPY_ALL), FALSE);
- if(src_id < 0) {
- H5I_dec_ref(dst_id);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
- } /* end if */
-
- /* Allocate a background buffer */
- bkg_size = MAX(H5T_GET_SIZE(copied_fill.type), H5T_GET_SIZE(dset->shared->type));
- if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) {
- H5I_dec_ref(src_id);
- H5I_dec_ref(dst_id);
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- } /* end if */
-
- /* Convert fill value */
- if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, bkg_buf, H5AC_ind_dxpl_id) < 0) {
- H5I_dec_ref(src_id);
- H5I_dec_ref(dst_id);
- if(bkg_buf)
- bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
- } /* end if */
-
- /* Release local resources */
- if(H5I_dec_ref(src_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
- if(H5I_dec_ref(dst_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
- if(bkg_buf)
- bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
- } /* end if */
- } /* end if */
-
- /* Set back the fill value property to property list */
- if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property list fill value")
-
- /* Set the return value */
- ret_value = new_dcpl_id;
-
-done:
- if(ret_value < 0)
- if(new_dcpl_id > 0)
- if(H5I_dec_app_ref(new_dcpl_id) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_get_create_plist() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5Dget_access_plist
*
* Purpose: Returns a copy of the dataset creation property list.
@@ -768,9 +615,6 @@ hid_t
H5Dget_access_plist(hid_t dset_id)
{
H5D_t *dset; /* Dataset structure */
- H5P_genplist_t *old_plist; /* Default DAPL */
- H5P_genplist_t *new_plist; /* New DAPL */
- hid_t new_dapl_id = FAIL;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -780,33 +624,10 @@ H5Dget_access_plist(hid_t dset_id)
if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
- /* Make a copy of the default dataset access property list */
- if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_ID_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
- if ((new_dapl_id = H5P_copy_plist(old_plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy dataset access property list")
- if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
-
- /* If the dataset is chunked then copy the rdcc parameters */
- if (dset->shared->layout.type == H5D_CHUNKED) {
- if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(dset->shared->cache.chunk.nslots)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots")
- if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(dset->shared->cache.chunk.nbytes_max)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size")
- if (H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &(dset->shared->cache.chunk.w0)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks")
- } /* end if */
-
- /* Set the return value */
- ret_value = new_dapl_id;
+ if((ret_value = H5D_get_access_plist(dset)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get access plist")
done:
- if(ret_value < 0)
- if(new_dapl_id >= 0)
- if(H5I_dec_app_ref(new_dapl_id) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
-
FUNC_LEAVE_API(ret_value)
} /* end H5Dget_access_plist() */