summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2012-03-29 17:37:33 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2012-03-29 17:37:33 (GMT)
commitc05a5a49c8d37ac216c1d1c7c4c98ea04a60f8a5 (patch)
tree59f3fa780b87367b6c75d58944d2a839f51d3cac
parent772133345d8d685e236b803f57189be0e042ca03 (diff)
downloadhdf5-c05a5a49c8d37ac216c1d1c7c4c98ea04a60f8a5.zip
hdf5-c05a5a49c8d37ac216c1d1c7c4c98ea04a60f8a5.tar.gz
hdf5-c05a5a49c8d37ac216c1d1c7c4c98ea04a60f8a5.tar.bz2
[svn-r22189] move the big chunks of code in the VOL get routines to separate utility routines
-rw-r--r--src/H5Dint.c270
-rw-r--r--src/H5Dprivate.h4
-rw-r--r--src/H5Gint.c95
-rw-r--r--src/H5Gprivate.h1
-rw-r--r--src/H5VLnative.c353
5 files changed, 436 insertions, 287 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 9a80bfc..043909c 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -104,6 +104,9 @@ H5FL_BLK_EXTERN(sieve_buf);
/* Declare the external free list to manage the H5D_chunk_info_t struct */
H5FL_EXTERN(H5D_chunk_info_t);
+/* Declare extern the free list to manage blocks of type conversion data */
+H5FL_BLK_EXTERN(type_conv);
+
/* Define a static "default" dataset structure to use to initialize new datasets */
static H5D_shared_t H5D_def_dset;
@@ -2443,3 +2446,270 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_flush() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_get_create_plist
+ *
+ * Purpose: Returns a copy of the dataset creation property list.
+ *
+ * Return: Success: ID for a copy of the dataset creation
+ * property list.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+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_id = FAIL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* 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_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_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_id;
+
+done:
+ if(ret_value < 0) {
+ if(new_id > 0)
+ if(H5I_dec_app_ref(new_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_get_create_plist() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_get_access_plist
+ *
+ * Purpose: Returns a copy of the dataset access property list.
+ *
+ * Return: Success: ID for a copy of the dataset access
+ * property list.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5D_get_access_plist(H5D_t *dset)
+{
+ H5P_genplist_t *old_plist; /* Default DAPL */
+ H5P_genplist_t *new_plist; /* New DAPL */
+ hid_t new_id = FAIL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Make a copy of the default dataset access property list */
+ if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ if ((new_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_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_id;
+
+done:
+ if(ret_value < 0) {
+ if(new_id > 0)
+ if(H5I_dec_app_ref(new_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_get_access_plist() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_get_space
+ *
+ * Purpose: Returns and ID for the dataspace of the dataset.
+ *
+ * Return: Success: ID for dataspace
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5D_get_space(H5D_t *dset)
+{
+ H5S_t *space = NULL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Read the data space message and return a data space object */
+ if(NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space")
+
+ /* Create an atom */
+ if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space")
+
+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_NOAPI(ret_value)
+} /* end H5D_get_space() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_get_type
+ *
+ * Purpose: Returns and ID for the datatype of the dataset.
+ *
+ * Return: Success: ID for datatype
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5D_get_type(H5D_t *dset)
+{
+ H5T_t *dt = NULL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* 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")
+
+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_NOAPI(ret_value)
+} /* end H5D_get_type() */
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 01071e6..6c9c21d 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -171,6 +171,10 @@ H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset);
H5_DLL H5G_name_t *H5D_nameof(H5D_t *dataset);
H5_DLL H5T_t *H5D_typeof(const H5D_t *dset);
H5_DLL herr_t H5D_flush(const H5F_t *f, hid_t dxpl_id);
+H5_DLL hid_t H5D_get_access_plist(H5D_t *dset);
+H5_DLL hid_t H5D_get_create_plist(H5D_t *dset);
+H5_DLL hid_t H5D_get_space(H5D_t *dset);
+H5_DLL hid_t H5D_get_type(H5D_t *dset);
/* Functions that operate on vlen data */
H5_DLL herr_t H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id,
diff --git a/src/H5Gint.c b/src/H5Gint.c
index ad2e57e..497babc 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -44,7 +44,7 @@
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
#include "H5MMprivate.h" /* Memory management */
-
+#include "H5Pprivate.h" /* Property lists */
/****************/
/* Local Macros */
@@ -1191,3 +1191,96 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_visit() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_get_create_plist
+ *
+ * Purpose: Returns a copy of the group creation property list.
+ *
+ * Return: Success: ID for a copy of the group creation
+ * property list.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5G_get_create_plist(H5G_t *grp)
+{
+ H5O_linfo_t linfo; /* Link info message */
+ htri_t ginfo_exists;
+ htri_t linfo_exists;
+ htri_t pline_exists;
+ H5P_genplist_t *gcpl_plist;
+ H5P_genplist_t *new_plist;
+ hid_t new_id = FAIL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Copy the default group creation property list */
+ if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list")
+ if((new_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list")
+ if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
+
+ /* Retrieve any object creation properties */
+ if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info")
+
+ /* Check for the group having a group info message */
+ if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
+ if(ginfo_exists) {
+ H5O_ginfo_t ginfo; /* Group info message */
+
+ /* Read the group info */
+ if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info")
+
+ /* Set the group info for the property list */
+ if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
+ } /* end if */
+
+ /* Check for the group having a link info message */
+ if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
+ if(linfo_exists) {
+ /* Set the link info for the property list */
+ if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info")
+ } /* end if */
+
+ /* Check for the group having a pipeline message */
+ if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header")
+ if(pline_exists) {
+ H5O_pline_t pline; /* Pipeline message */
+
+ /* Read the pipeline */
+ if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline")
+
+ /* Set the pipeline for the property list */
+ if(H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline")
+ } /* end if */
+
+ /* Set the return value */
+ ret_value = new_id;
+
+done:
+ if(ret_value < 0) {
+ if(new_id > 0)
+ if(H5I_dec_app_ref(new_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_get_create_plist() */
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index f765b52..cacd947 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -202,6 +202,7 @@ H5_DLL herr_t H5G_get_shared_count(H5G_t *grp);
H5_DLL herr_t H5G_mount(H5G_t *grp);
H5_DLL hbool_t H5G_mounted(H5G_t *grp);
H5_DLL herr_t H5G_unmount(H5G_t *grp);
+H5_DLL hid_t H5G_get_create_plist(H5G_t *grp);
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 9b78449..e717205 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -50,9 +50,6 @@
#include "H5VLprivate.h" /* VOL plugins */
#include "H5VLnative.h" /* Native VOL plugin */
-/* Declare extern the free list to manage blocks of type conversion data */
-H5FL_BLK_EXTERN(type_conv);
-
/* The driver identification number, initialized at runtime */
static hid_t H5VL_NATIVE_g = 0;
@@ -910,9 +907,6 @@ done:
static herr_t
H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, int num_args, va_list arguments)
{
- H5G_loc_t grp_loc; /* Location used to open group */
- hbool_t loc_found = FALSE; /* Location at 'name' found */
- hid_t *new_gcpl_id, new_id = FAIL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -921,72 +915,17 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, int num_args, va_
/* H5Gget_create_plist */
case H5VL_GROUP_GET_GCPL:
{
- H5O_linfo_t linfo; /* Link info message */
- htri_t ginfo_exists;
- htri_t linfo_exists;
- htri_t pline_exists;
- H5G_t *grp = NULL;
- H5P_genplist_t *gcpl_plist;
- H5P_genplist_t *new_plist;
-
- new_gcpl_id = va_arg (arguments, hid_t *);
+ hid_t *new_gcpl_id;
+ H5G_t *grp = NULL;
+
/* Check args */
if(NULL == (grp = (H5G_t *)H5I_object_verify(obj_id, H5I_GROUP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
- /* Copy the default group creation property list */
- if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list")
- if((new_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list")
- if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
-
- /* Retrieve any object creation properties */
- if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info")
-
- /* Check for the group having a group info message */
- if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
- if(ginfo_exists) {
- H5O_ginfo_t ginfo; /* Group info message */
-
- /* Read the group info */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id))
- HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info")
-
- /* Set the group info for the property list */
- if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
- } /* end if */
-
- /* Check for the group having a link info message */
- if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
- if(linfo_exists) {
- /* Set the link info for the property list */
- if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info")
- } /* end if */
-
- /* Check for the group having a pipeline message */
- if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header")
- if(pline_exists) {
- H5O_pline_t pline; /* Pipeline message */
-
- /* Read the pipeline */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id))
- HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline")
-
- /* Set the pipeline for the property list */
- if(H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline")
- } /* end if */
-
- /* Set the return value */
- *new_gcpl_id = new_id;
+ new_gcpl_id = va_arg (arguments, hid_t *);
+
+ if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group")
break;
}
/* H5Fget_info2 */
@@ -1016,13 +955,6 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, int num_args, va_
}
done:
- if (H5VL_GROUP_GET_GCPL == get_type) {
- if(*new_gcpl_id < 0) {
- if(new_id > 0)
- if(H5I_dec_app_ref(new_id) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
- } /* end if */
- }
FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1746,10 +1678,6 @@ static herr_t
H5VL_native_dataset_get(hid_t id, H5VL_dataset_get_t get_type, int num_args, va_list arguments)
{
H5D_t *dset = NULL;
- H5S_t *space = NULL;
- H5T_t *dt = NULL;
- hid_t *ret_id;
- hid_t new_id = FAIL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1759,226 +1687,79 @@ H5VL_native_dataset_get(hid_t id, H5VL_dataset_get_t get_type, int num_args, va_
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
switch (get_type) {
- /* H5Dget_space */
- case H5VL_DATASET_GET_SPACE:
- {
- ret_id = va_arg (arguments, hid_t *);
-
- /* Read the data space message and return a data space object */
- if(NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space")
-
- /* Create an atom */
- if((new_id = H5I_register (H5I_DATASPACE, space, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space")
-
- /* Set the return value */
- *ret_id = new_id;
- break;
- }
- /* H5Dget_space_statuc */
- case H5VL_DATASET_GET_SPACE_STATUS:
- {
- H5D_space_status_t *allocation = va_arg (arguments, H5D_space_status_t *);
-
- /* Read data space address and return */
- if(FAIL==(ret_value=H5D_get_space_status(dset, allocation, H5AC_ind_dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status")
-
- break;
- }
- /* H5Dget_type */
- case H5VL_DATASET_GET_TYPE:
- {
- ret_id = va_arg (arguments, hid_t *);
-
- /* 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")
+ /* H5Dget_space */
+ case H5VL_DATASET_GET_SPACE:
+ {
+ hid_t *ret_id = va_arg (arguments, hid_t *);
- /* 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")
+ if((*ret_id = H5D_get_space(dset)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset")
- /* 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")
+ break;
+ }
+ /* H5Dget_space_statuc */
+ case H5VL_DATASET_GET_SPACE_STATUS:
+ {
+ H5D_space_status_t *allocation = va_arg (arguments, H5D_space_status_t *);
- /* Lock copied type */
- if(H5T_lock(dt, FALSE) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype")
+ /* Read data space address and return */
+ if(FAIL==(ret_value=H5D_get_space_status(dset, allocation, H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status")
- /* Create an atom */
- if((new_id = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
+ break;
+ }
+ /* H5Dget_type */
+ case H5VL_DATASET_GET_TYPE:
+ {
+ hid_t *ret_id = va_arg (arguments, hid_t *);
- /* Set the return value */
- *ret_id = new_id;
+ if((*ret_id = H5D_get_type(dset)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset")
- break;
- }
- /* H5Dget_create_plist */
- case H5VL_DATASET_GET_DCPL:
- {
- 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 */
+ break;
+ }
+ /* H5Dget_create_plist */
+ case H5VL_DATASET_GET_DCPL:
+ {
+ hid_t *ret_id = va_arg (arguments, hid_t *);
- ret_id = va_arg (arguments, hid_t *);
+ if((*ret_id = H5D_get_create_plist(dset)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset")
- /* 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_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_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 */
+ break;
+ }
+ /* H5Dget_type */
+ case H5VL_DATASET_GET_DAPL:
+ {
+ hid_t *ret_id = va_arg (arguments, hid_t *);
- /* 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")
+ if((*ret_id = H5D_get_access_plist(dset)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset")
- /* Set the return value */
- *ret_id = new_id;
- break;
- }
- /* H5Dget_type */
- case H5VL_DATASET_GET_DAPL:
- {
- H5P_genplist_t *old_plist; /* Default DAPL */
- H5P_genplist_t *new_plist; /* New DAPL */
-
- ret_id = va_arg (arguments, hid_t *);
-
- /* Make a copy of the default dataset access property list */
- if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
- if ((new_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_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_id = new_id;
- break;
- }
- /* H5Dget_type */
- case H5VL_DATASET_GET_STORAGE_SIZE:
- {
- hsize_t *ret = va_arg (arguments, hsize_t *);
+ break;
+ }
+ /* H5Dget_type */
+ case H5VL_DATASET_GET_STORAGE_SIZE:
+ {
+ hsize_t *ret = va_arg (arguments, hsize_t *);
- /* Set return value */
- *ret = H5D_get_storage_size(dset, H5AC_ind_dxpl_id);
- break;
- }
- /* H5Dget_type */
- case H5VL_DATASET_GET_OFFSET:
- {
- haddr_t *ret = va_arg (arguments, haddr_t *);
+ /* Set return value */
+ *ret = H5D_get_storage_size(dset, H5AC_ind_dxpl_id);
+ break;
+ }
+ /* H5Dget_type */
+ case H5VL_DATASET_GET_OFFSET:
+ {
+ haddr_t *ret = va_arg (arguments, haddr_t *);
- /* Set return value */
- *ret = H5D_get_offset(dset);
- break;
- }
- default:
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset")
+ /* Set return value */
+ *ret = H5D_get_offset(dset);
+ break;
+ }
+ default:
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset")
}
+
done:
- if (H5VL_DATASET_GET_DCPL == get_type || H5VL_DATASET_GET_DAPL == get_type) {
- if(*ret_id < 0) {
- if(new_id > 0)
- if(H5I_dec_app_ref(new_id) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
- } /* end if */
- }
- if (H5VL_DATASET_GET_SPACE == get_type) {
- if(*ret_id < 0) {
- if(space!=NULL) {
- if(H5S_close(space) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
- } /* end if */
- } /* end if */
- }
- if (H5VL_DATASET_GET_TYPE == get_type) {
- if(*ret_id < 0) {
- if(dt && H5T_close(dt) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
- } /* end if */
- }
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_get() */