summaryrefslogtreecommitdiffstats
path: root/src/H5Tcommit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Tcommit.c')
-rw-r--r--src/H5Tcommit.c901
1 files changed, 666 insertions, 235 deletions
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index c28b508..bb660c2 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -26,14 +26,19 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FOprivate.h" /* File objects */
-#include "H5Iprivate.h" /* IDs */
-#include "H5Lprivate.h" /* Links */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5Tpkg.h" /* Datatypes */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5FOprivate.h" /* File objects */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
+#include "H5MMprivate.h" /* Memory Management */
+#include "H5Oprivate.h" /* Object headers */
+#include "H5Pprivate.h" /* Property lists */
+#include "H5Tpkg.h" /* Datatypes */
+#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
@@ -54,7 +59,7 @@
/********************/
/* Local Prototypes */
/********************/
-static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id);
+static H5T_t *H5T__open_oid(const H5G_loc_t *loc);
/*********************/
@@ -76,18 +81,21 @@ static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id);
/* Local Variables */
/*******************/
+/* Declare a free list to manage the H5VL_t struct */
+H5FL_EXTERN(H5VL_t);
+
+/* Declare a free list to manage the H5VL_object_t struct */
+H5FL_EXTERN(H5VL_object_t);
+
/*-------------------------------------------------------------------------
- * Function: H5Tcommit2
- *
- * Purpose: Save a transient datatype to a file and turn the type handle
- * into a "named", immutable type.
+ * Function: H5Tcommit2
*
- * Return: Non-negative on success/Negative on failure
+ * Purpose: Save a transient datatype to a file and turn the type handle
+ * into a "named", immutable type.
*
- * Programmer: Quincey Koziol
- * April 5, 2007
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -95,21 +103,25 @@ herr_t
H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
hid_t tcpl_id, hid_t tapl_id)
{
- H5G_loc_t loc; /* Location to create datatype */
- H5T_t *type; /* Datatype for ID */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ void *data = NULL; /* VOL-managed datatype data */
+ H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */
+ H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */
+ H5VL_object_t *vol_obj = NULL; /* object of loc_id */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id);
/* Check arguments */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL")
+ if(!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string")
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(H5T_is_named(dt))
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed")
/* Get correct property list */
if(H5P_DEFAULT == lcpl_id)
@@ -119,19 +131,40 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
/* Get correct property list */
- if(H5P_DEFAULT == tcpl_id)
+ if (H5P_DEFAULT == tcpl_id)
tcpl_id = H5P_DATATYPE_CREATE_DEFAULT;
else
if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list")
- /* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, TRUE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+ /* Set the LCPL for the API context */
+ H5CX_set_lcpl(lcpl_id);
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the object from the loc_id */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
/* Commit the type */
- if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ if(NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+
+ /* Set up VOL object */
+ if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate top object structure")
+ new_obj->connector = vol_obj->connector;
+ new_obj->connector->nrefs ++;
+ new_obj->data = data;
+
+ /* Set the committed type object to the VOL connector pointer in the H5T_t struct */
+ dt->vol_obj = new_obj;
done:
FUNC_LEAVE_API(ret_value)
@@ -153,7 +186,7 @@ done:
*/
herr_t
H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt,
- hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id)
+ hid_t lcpl_id, hid_t tcpl_id)
{
H5O_obj_create_t ocrt_info; /* Information for object creation */
H5T_obj_create_t tcrt_info; /* Information for named datatype creation */
@@ -168,8 +201,6 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt,
HDassert(dt);
HDassert(lcpl_id != H5P_DEFAULT);
HDassert(tcpl_id != H5P_DEFAULT);
- HDassert(tapl_id != H5P_DEFAULT);
- HDassert(dxpl_id != H5P_DEFAULT);
/* Record the type's state so that we can revert to it if linking fails */
old_state = dt->shared->state;
@@ -184,7 +215,7 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt,
ocrt_info.new_obj = NULL;
/* Create the new named datatype and link it to its parent group */
- if(H5L_link_object(loc, name, &ocrt_info, lcpl_id, tapl_id, dxpl_id) < 0)
+ if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create and link to named datatype")
HDassert(ocrt_info.new_obj);
@@ -193,27 +224,27 @@ done:
* to return it to the state it was in before it was committed.
*/
if(ret_value < 0 && (NULL != ocrt_info.new_obj)) {
- if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) {
+ if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) {
/* Remove the datatype from the list of opened objects in the file */
if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
- if(H5FO_delete(dt->sh_loc.file, dxpl_id, dt->sh_loc.u.loc.oh_addr) < 0)
+ if(H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects")
/* Close the datatype object */
- if(H5O_close(&(dt->oloc), NULL) < 0)
+ if(H5O_close(&(dt->oloc), NULL) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
/* Remove the datatype's object header from the file */
- if(H5O_delete(dt->sh_loc.file, dxpl_id, dt->sh_loc.u.loc.oh_addr) < 0)
+ if(H5O_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header")
/* Mark datatype as being back in memory */
- if(H5T_set_loc(dt, dt->sh_loc.file, H5T_LOC_MEMORY))
+ if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY))
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to return datatype to memory")
- dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED;
+ dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED;
dt->shared->state = old_state;
- } /* end if */
+ } /* end if */
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -221,40 +252,39 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Tcommit_anon
+ * Function: H5Tcommit_anon
*
- * Purpose: Save a transient datatype to a file and turn the type handle
- * into a "named", immutable type.
+ * Purpose: Save a transient datatype to a file and turn the type handle
+ * into a "named", immutable type.
*
* The resulting ID should be linked into the file with
* H5Olink or it will be deleted when closed.
*
- * Note: Datatype access property list is unused currently, but is
- * checked for sanity anyway.
- *
- * Return: Non-negative on success/Negative on failure
+ * Note: The datatype access property list is unused currently, but
+ * is checked for sanity anyway.
*
- * Programmer: Peter Cao
- * May 17, 2005
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
{
- H5G_loc_t loc; /* Group location for location */
- H5T_t *type = NULL; /* Datatype created */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ void *dt = NULL; /* datatype object created by VOL connector */
+ H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */
+ H5T_t *type = NULL; /* Datatype created */
+ H5VL_object_t *vol_obj = NULL; /* object of loc_id */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id);
/* Check arguments */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(H5T_is_named(type))
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed")
/* Get correct property list */
if(H5P_DEFAULT == tcpl_id)
@@ -263,26 +293,32 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list")
- /* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, TRUE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
- /* Commit the type */
- if(H5T__commit(loc.oloc->file, type, tcpl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
- /* Release the datatype's object header */
- {
- H5O_loc_t *oloc; /* Object location for datatype */
+ /* Get the file object */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
- /* Get the new committed datatype's object location */
- if(NULL == (oloc = H5T_oloc(type)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype")
+ /* Commit the datatype */
+ if(NULL == (dt = H5VL_datatype_commit(vol_obj, &loc_params, NULL, type_id, H5P_LINK_CREATE_DEFAULT,
+ tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
- /* Decrement refcount on committed datatype's object header in memory */
- if(H5O_dec_rc_by_loc(oloc, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
- } /* end if */
+ /* Setup VOL object */
+ if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate top object structure")
+ new_obj->connector = vol_obj->connector;
+ new_obj->connector->nrefs ++;
+ new_obj->data = dt;
+
+ /* Set the committed type object to the VOL connector pointer in the H5T_t struct */
+ type->vol_obj = new_obj;
done:
FUNC_LEAVE_API(ret_value)
@@ -290,6 +326,50 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5T__commit_anon
+ *
+ * Purpose: Create an anonymous committed datatype.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, December 12, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id)
+{
+ H5O_loc_t *oloc; /* Object location for datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(type);
+ HDassert(tcpl_id != H5P_DEFAULT);
+
+ /* Commit the type */
+ if(H5T__commit(file, type, tcpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+
+ /* Release the datatype's object header */
+
+ /* Get the new committed datatype's object location */
+ if(NULL == (oloc = H5T_oloc(type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype")
+
+ /* Decrement refcount on committed datatype's object header in memory */
+ if(H5O_dec_rc_by_loc(oloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5T__commit_anon() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5T__commit
*
* Purpose: Commit a type, giving it a name and causing it to become
@@ -303,7 +383,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id)
+H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id)
{
H5O_loc_t temp_oloc; /* Temporary object header location */
H5G_name_t temp_path; /* Temporary path */
@@ -327,9 +407,9 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id)
* a named type should always succeed.
*/
if(H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed")
if(H5T_STATE_IMMUTABLE == type->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable")
/* Check for a "sensible" datatype to store on disk */
if(H5T_is_sensible(type) <= 0)
@@ -338,22 +418,21 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id)
/* Mark datatype as being on disk now. This step changes the size of
* datatype as stored on disk.
*/
- if(H5T_set_loc(type, file, H5T_LOC_DISK) < 0)
+ if(H5T_set_loc(type, H5F_VOL_OBJ(file), H5T_LOC_DISK) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
/* Reset datatype location and path */
if(H5O_loc_reset(&temp_oloc) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize location")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize location")
if(H5G_name_reset(&temp_path) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize path")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize path")
loc_init = TRUE;
- /* Set the latest format, if requested */
- if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_DATATYPE))
- if(H5T_set_latest_version(type) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype")
+ /* Set the version for datatype */
+ if(H5T_set_version(file, type) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype")
- /* Calculate message size infomation, for creating object header */
+ /* Calculate message size information, for creating object header */
dtype_size = H5O_msg_size_f(file, tcpl_id, H5O_DTYPE_ID, type, (size_t)0);
HDassert(dtype_size);
@@ -361,16 +440,16 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id)
* Create the object header and open it for write access. Insert the data
* type message and then give the object header a name.
*/
- if(H5O_create(file, dxpl_id, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header")
- if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message")
+ if(H5O_create(file, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header")
+ if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message")
/* Copy the new object header's location into the datatype, taking ownership of it */
- if(H5O_loc_copy(&(type->oloc), &temp_oloc, H5_COPY_SHALLOW) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location")
+ if(H5O_loc_copy_shallow(&(type->oloc), &temp_oloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location")
if(H5G_name_copy(&(type->path), &temp_path, H5_COPY_SHALLOW) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location")
loc_init = FALSE;
/* Set the shared info fields */
@@ -397,14 +476,14 @@ done:
H5G_name_free(&temp_path);
} /* end if */
if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) {
- if(H5O_dec_rc_by_loc(&(type->oloc), dxpl_id) < 0)
+ if(H5O_dec_rc_by_loc(&(type->oloc)) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
- if(H5O_close(&(type->oloc), NULL) < 0)
+ if(H5O_close(&(type->oloc), NULL) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
- if(H5O_delete(file, dxpl_id, type->sh_loc.u.loc.oh_addr) < 0)
+ if(H5O_delete(file, type->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header")
- type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED;
- } /* end if */
+ type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED;
+ } /* end if */
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -412,23 +491,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Tcommitted
+ * Function: H5Tcommitted
*
- * Purpose: Determines if a datatype is committed or not.
+ * Purpose: Determines if a datatype is committed or not.
*
- * Return: Success: TRUE if committed, FALSE otherwise.
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Thursday, June 4, 1998
+ * Return: TRUE/FALSE/FAIL
*
*-------------------------------------------------------------------------
*/
htri_t
H5Tcommitted(hid_t type_id)
{
- H5T_t *type; /* Datatype to query */
+ H5T_t *type; /* Datatype to query */
htri_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -436,10 +510,10 @@ H5Tcommitted(hid_t type_id)
/* Check arguments */
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Set return value */
- ret_value = H5T_committed(type);
+ ret_value = H5T_is_named(type);
done:
FUNC_LEAVE_API(ret_value)
@@ -447,30 +521,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5T_committed
- *
- * Purpose: Determines if a datatype is committed or not.
- *
- * Return: Success: TRUE if committed, FALSE otherwise.
- *
- * Programmer: Quincey Koziol
- * Wednesday, September 24, 2003
- *
- *-------------------------------------------------------------------------
- */
-htri_t
-H5T_committed(const H5T_t *type)
-{
- /* Use no-init for efficiency */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- HDassert(type);
-
- FUNC_LEAVE_NOAPI(H5T_STATE_OPEN == type->shared->state || H5T_STATE_NAMED == type->shared->state)
-} /* end H5T_committed() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5T_link
*
* Purpose: Adjust the link count for an object header by adding
@@ -485,18 +535,18 @@ H5T_committed(const H5T_t *type)
*-------------------------------------------------------------------------
*/
int
-H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id)
+H5T_link(const H5T_t *type, int adjust)
{
int ret_value = -1; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI((-1))
HDassert(type);
HDassert(type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED);
/* Adjust the link count on the named datatype */
- if((ret_value = H5O_link(&type->oloc, adjust, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_LINKCOUNT, FAIL, "unable to adjust named datatype link count")
+ if((ret_value = H5O_link(&type->oloc, adjust)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_LINKCOUNT, (-1), "unable to adjust named datatype link count")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -504,140 +554,251 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Topen2
+ * Function: H5Topen2
*
- * Purpose: Opens a named datatype using a Datatype Access Property
+ * Purpose: Opens a named datatype using a Datatype Access Property
* List.
*
- * Return: Success: Object ID of the named datatype.
- * Failure: Negative
+ * Return: Success: Object ID of the named datatype
*
- * Programmer: James Laird
- * Thursday July 27, 2006
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id)
{
- H5T_t *type = NULL; /* Datatype opened in file */
- H5G_loc_t loc; /* Group location of object to open */
- H5G_name_t path; /* Datatype group hier. path */
- H5O_loc_t oloc; /* Datatype object location */
- H5O_type_t obj_type; /* Type of object at location */
- H5G_loc_t type_loc; /* Group object for datatype */
- hbool_t obj_found = FALSE; /* Object at 'name' found */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl to use to open datatype */
- hid_t ret_value = FAIL; /* Return value */
+ void *dt = NULL; /* datatype object created by VOL connector */
+ H5VL_object_t *vol_obj = NULL; /* object of loc_id */
+ H5VL_loc_params_t loc_params;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "i*si", loc_id, name, tapl_id);
/* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL")
+ if(!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string")
- /* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, FALSE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
- /* Set up datatype location to fill in */
- type_loc.oloc = &oloc;
- type_loc.path = &path;
- H5G_loc_reset(&type_loc);
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
- /*
- * Find the named datatype object header and read the datatype message
- * from it.
- */
- if(H5G_loc_find(&loc, name, &type_loc/*out*/, tapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found")
- obj_found = TRUE;
+ /* get the location object */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier")
- /* Check that the object found is the correct type */
- if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_NAMED_DATATYPE)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype")
-
- /* Open it */
- if(NULL == (type = H5T_open(&type_loc, dxpl_id)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype")
+ /* Open the datatype */
+ if(NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype")
/* Register the type and return the ID */
- if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype")
+ if((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype")
done:
- if(ret_value < 0) {
- if(type != NULL)
- H5T_close(type);
- else {
- if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
- H5G_loc_free(&type_loc);
- } /* end else */
- } /* end if */
+ /* Cleanup on error */
+ if(H5I_INVALID_HID == ret_value)
+ if(dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype")
FUNC_LEAVE_API(ret_value)
} /* end H5Topen2() */
/*-------------------------------------------------------------------------
- * Function: H5Tget_create_plist
+ * Function: H5Tget_create_plist
*
- * Purpose: Returns a copy of the datatype creation property list.
+ * Purpose: Returns a copy of the datatype creation property list.
*
- * Return: Success: ID for a copy of the datatype creation
- * property list. The property list ID should be
- * released by calling H5Pclose().
+ * Note: There are no datatype creation properties currently, just
+ * object creation ones.
*
- * Failure: FAIL
+ * Return: Success: ID for a copy of the datatype creation
+ * property list. The property list ID should be
+ * released by calling H5Pclose().
*
- * Programmer: Quincey Koziol
- * Tuesday, November 28, 2006
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5Tget_create_plist(hid_t dtype_id)
{
- H5T_t *type; /* Datatype object for ID */
- H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */
- hid_t new_tcpl_id = FAIL; /* New datatype creation property list */
- herr_t status; /* Generic status value */
- hid_t ret_value; /* Return value */
+ H5T_t *type = NULL; /* Datatype object for ID */
+ htri_t is_named = FAIL; /* Is the datatype named? */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE1("i", "i", dtype_id);
/* Check arguments */
if(NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype")
+
+ /* Check if the datatype is committed */
+ if(FAIL == (is_named = H5T_is_named(type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't check whether datatype is committed")
+
+ /* If the datatype is not committed/named, just copy the default
+ * creation property list and return that.
+ */
+ if(FALSE == is_named) {
+ H5P_genplist_t *tcpl_plist = NULL;
+
+ /* Copy the default datatype creation property list */
+ if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list")
+ if((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list")
+ } /* end if */
+ /* If the datatype is committed, retrieve further information */
+ else {
+ H5VL_object_t *vol_obj = type->vol_obj;
+
+ /* Get the property list through the VOL */
+ if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_TCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Tget_create_plist() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tflush
+ *
+ * Purpose: Flushes all buffers associated with a named datatype to disk.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Mike McGreevy
+ * May 19, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tflush(hid_t type_id)
+{
+ H5T_t *dt; /* Datatype for this operation */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", type_id);
+
+ /* Check args */
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(!H5T_is_named(dt))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
+
+ /* Set up collective metadata if appropriate */
+ if(H5CX_set_loc(type_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Flush metadata for named datatype */
+ if(dt->vol_obj)
+ if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Tflush */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Trefresh
+ *
+ * Purpose: Refreshes all buffers associated with a named datatype.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Mike McGreevy
+ * July 21, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Trefresh(hid_t type_id)
+{
+ H5T_t *dt; /* Datatype for this operation */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", type_id);
+
+ /* Check args */
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(!H5T_is_named(dt))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
+
+ /* Set up collective metadata if appropriate */
+ if(H5CX_set_loc(type_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Refresh the datatype's metadata */
+ if(dt->vol_obj)
+ if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Trefresh */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__get_create_plist
+ *
+ * Purpose: Returns a copy of the datatype creation property list.
+ *
+ * Note: There are no datatype creation properties currently, just
+ * object creation ones.
+ *
+ * Return: Success: ID for a copy of the datatype creation
+ * property list. The property list ID should be
+ * released by calling H5Pclose().
+ *
+ * Failure: H5I_INVALID_HID
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, December 13, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5T__get_create_plist(const H5T_t *type)
+{
+ H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */
+ H5P_genplist_t *new_plist; /* New datatype creation property list */
+ hid_t new_tcpl_id = FAIL; /* New datatype creation property list */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(type);
/* Copy the default datatype creation property list */
if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list")
if((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list")
-
- /* Check if the datatype is committed */
- if((status = H5T_committed(type)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check whether datatype is committed")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list")
- /* Retrieve further information, if the datatype is committed */
- if(status > 0) {
- H5P_genplist_t *new_plist; /* New datatype creation property list */
+ /* Get property list object for new TCPL */
+ if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get property list")
- /* Get property list object for new TCPL */
- if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
-
- /* Retrieve any object creation properties */
- if(H5O_get_create_plist(&type->oloc, H5AC_ind_read_dxpl_id, new_plist) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info")
- } /* end if */
+ /* Retrieve any object creation properties */
+ if(H5O_get_create_plist(&type->oloc, new_plist) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info")
/* Set the return value */
ret_value = new_tcpl_id;
@@ -646,10 +807,76 @@ done:
if(ret_value < 0)
if(new_tcpl_id > 0)
if(H5I_dec_app_ref(new_tcpl_id) < 0)
- HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to close temporary object")
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, H5I_INVALID_HID, "unable to close temporary object")
- FUNC_LEAVE_API(ret_value)
-} /* end H5Tget_create_plist() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__get_create_plist() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__open_name
+ *
+ * Purpose: Open a named datatype.
+ *
+ * Return: Success: Ptr to a new datatype.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, December 13, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T__open_name(const H5G_loc_t *loc, const char *name)
+{
+ H5T_t *dt = NULL; /* Datatype opened in file */
+ H5G_name_t path; /* Datatype group hier. path */
+ H5O_loc_t oloc; /* Datatype object location */
+ H5G_loc_t type_loc; /* Group object for datatype */
+ H5O_type_t obj_type; /* Type of object at location */
+ hbool_t obj_found = FALSE; /* Object at 'name' found */
+ H5T_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(loc);
+ HDassert(name);
+
+ /* Set up datatype location to fill in */
+ type_loc.oloc = &oloc;
+ type_loc.path = &path;
+ H5G_loc_reset(&type_loc);
+
+ /*
+ * Find the named datatype object header and read the datatype message
+ * from it.
+ */
+ if(H5G_loc_find(loc, name, &type_loc/*out*/) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found")
+ obj_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(&oloc, &obj_type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't get object type")
+ if(obj_type != H5O_TYPE_NAMED_DATATYPE)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "not a named datatype")
+
+ /* Open it */
+ if(NULL == (dt = H5T_open(&type_loc)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype")
+
+ ret_value = dt;
+
+done:
+ /* Error cleanup */
+ if(NULL == ret_value)
+ if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
+ if(H5G_loc_free(&type_loc) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't free location")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__open_name() */
/*-------------------------------------------------------------------------
@@ -667,7 +894,7 @@ done:
*-------------------------------------------------------------------------
*/
H5T_t *
-H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
+H5T_open(const H5G_loc_t *loc)
{
H5T_shared_t *shared_fo = NULL;
H5T_t *dt = NULL;
@@ -683,7 +910,7 @@ H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
H5E_clear_stack(NULL);
/* Open the datatype object */
- if(NULL == (dt = H5T_open_oid(loc, dxpl_id)))
+ if(NULL == (dt = H5T__open_oid(loc)))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found")
/* Add the datatype to the list of opened objects in the file */
@@ -703,6 +930,7 @@ H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
else {
if(NULL == (dt = H5FL_MALLOC(H5T_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype")
+ dt->vol_obj = NULL;
#if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG)
/* Clear object location */
@@ -715,7 +943,7 @@ H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
#endif /* H5_USING_MEMCHECKER */
/* Shallow copy (take ownership) of the object location object */
- if(H5O_loc_copy(&dt->oloc, loc->oloc, H5_COPY_SHALLOW) < 0)
+ if(H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy object location")
/* Shallow copy (take ownership) of the group hier. path */
@@ -770,7 +998,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5T_open_oid
+ * Function: H5T__open_oid
*
* Purpose: Open a named datatype.
*
@@ -784,28 +1012,28 @@ done:
*-------------------------------------------------------------------------
*/
static H5T_t *
-H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id)
+H5T__open_oid(const H5G_loc_t *loc)
{
H5T_t *dt = NULL; /* Datatype from the file */
H5T_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC_TAG(loc->oloc->addr)
HDassert(loc);
/* Open named datatype object in file */
if(H5O_open(loc->oloc) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype")
/* Deserialize the datatype message into a datatype in memory */
- if(NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL, dxpl_id)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header")
+ if(NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header")
/* Mark the type as named and open */
dt->shared->state = H5T_STATE_OPEN;
/* Shallow copy (take ownership) of the object location object */
- if(H5O_loc_copy(&dt->oloc, loc->oloc, H5_COPY_SHALLOW) < 0)
+ if(H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy object location")
/* Shallow copy (take ownership) of the group hier. path */
@@ -823,8 +1051,8 @@ done:
if(dt == NULL)
H5O_close(loc->oloc, NULL);
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_open_oid() */
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
+} /* end H5T__open_oid() */
/*-------------------------------------------------------------------------
@@ -852,3 +1080,206 @@ H5T_update_shared(H5T_t *dt)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5T_update_shared() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_construct_datatype
+ *
+ * Purpose: Create a Library datatype with a connector specific datatype object
+ *
+ * Return: Success: A type structure
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_construct_datatype(H5VL_object_t *vol_obj)
+{
+ ssize_t nalloc;
+ void *buf = NULL;
+ H5T_t *dt = NULL; /* datatype object from VOL connector */
+ H5T_t *ret_value = NULL;
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* get required buf size for encoding the datatype */
+ if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, NULL, 0) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get datatype serialized size")
+
+ /* allocate buffer to store binary description of the datatype */
+ if(NULL == (buf = (void *)H5MM_calloc((size_t)nalloc)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype")
+
+ /* get binary description of the datatype */
+ if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, buf, (size_t)nalloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get serialized datatype")
+
+ if(NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't decode datatype")
+
+ dt->vol_obj = vol_obj;
+
+ ret_value = dt;
+
+done:
+ if(buf)
+ buf = H5MM_xfree(buf);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_construct_datatype() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_get_named_type
+ *
+ * Purpose: Returns the VOL object for the named datatype if it exists
+ *
+ * Return: Success: Pointer to the VOL object for the datatype
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+H5VL_object_t *
+H5T_get_named_type(const H5T_t *dt)
+{
+ H5VL_object_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ if(NULL != dt->vol_obj)
+ ret_value = dt->vol_obj;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_get_named_type() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_get_actual_type
+ *
+ * Purpose: Returns underlying native datatype created by native connector
+ * if datatype is committed, otherwise return the datatype
+ * object associate with the ID.
+ *
+ * Return: Success: Pointer to the VOL-managed data for this datatype
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_get_actual_type(H5T_t *dt)
+{
+ H5T_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check if the datatype is committed */
+ if(NULL == dt->vol_obj)
+ ret_value = dt;
+ else
+ ret_value = (H5T_t *)H5VL_object_data(dt->vol_obj);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_get_actual_type() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_save_refresh_state
+ *
+ * Purpose: Save state for datatype reconstuction after a refresh.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_save_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared)
+{
+ H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */
+ H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(cached_H5O_shared);
+
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not a datatype ID")
+ vol_dt = (H5T_t *)(dt->vol_obj->data);
+ if(NULL == vol_dt)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID")
+
+ /* Increase the count on the file object */
+ vol_dt->shared->fo_count += 1;
+
+ /* Increment object count for the object in the top file */
+ if(H5FO_top_incr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't increment object count")
+
+ /* Cache the H5O_shared_t data */
+ H5MM_memcpy(cached_H5O_shared, &(vol_dt->sh_loc), sizeof(H5O_shared_t));
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_save_refresh_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_restore_refresh_state
+ *
+ * Purpose: Restore state for datatype reconstuction after a refresh.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_restore_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared)
+{
+ H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */
+ H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(cached_H5O_shared);
+
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid not a datatype ID")
+ vol_dt = (H5T_t *)(dt->vol_obj->data);
+ if(NULL == vol_dt)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID")
+
+ /* Restore the H5O_shared_t data */
+ H5MM_memcpy(&(vol_dt->sh_loc), cached_H5O_shared, sizeof(H5O_shared_t));
+
+ /* Decrement the ref. count for this object in the top file */
+ if(H5FO_top_decr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "can't decrement object count")
+
+ /* Decrease the count on the file object */
+ vol_dt->shared->fo_count -= 1;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_restore_refresh_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_already_vol_managed
+ *
+ * Purpose: Check if the committed datatype is already VOL managed
+ *
+ * Return: TRUE / FALSE
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5T_already_vol_managed(const H5T_t *dt)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Sanity check */
+ HDassert(dt);
+
+ FUNC_LEAVE_NOAPI( dt->vol_obj != NULL )
+} /* end H5T_already_vol_managed() */
+