summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5A.c2
-rw-r--r--src/H5Aint.c31
-rw-r--r--src/H5Dint.c37
-rw-r--r--src/H5T.c4
-rw-r--r--src/H5Tcommit.c21
-rw-r--r--src/H5Tprivate.h1
-rw-r--r--src/H5VLint.c2
-rw-r--r--src/H5VLnative.c23
8 files changed, 82 insertions, 39 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 257cdd4..f17dfa1 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -257,7 +257,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id,
/* get the file object */
if(NULL == (obj = (void *)H5VL_get_object(loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid identifier")
/* get the plugin pointer */
if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 3a4bfd4..687dfc9 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -743,6 +743,7 @@ hid_t
H5A_get_type(H5A_t *attr)
{
H5T_t *dt = NULL;
+ H5T_t *type = NULL;
hid_t ret_value = FAIL;
FUNC_ENTER_NOAPI_NOINIT
@@ -767,14 +768,38 @@ H5A_get_type(H5A_t *attr)
if(H5T_lock(dt, FALSE) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype")
- /* Atomize */
- if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype ID")
+ /* Create an atom */
+ if(H5T_committed(dt)) {
+ /* If this is a committed datatype, we need to recreate the
+ two level IDs, where the VOL object is a copy of the
+ returned datatype */
+ ssize_t nalloc = 0;
+ size_t size;
+ unsigned char *buf = NULL;
+
+ /* Copy the dataset's datatype */
+ if(NULL == (type = H5T_copy(dt, H5T_COPY_REOPEN)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype")
+
+ H5T_set_vol_object(type, (void *)dt);
+
+ if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
+
+ if (H5VL_native_register_aux(ret_value) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ }
+ else {
+ 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")
+ if(type && H5T_close(type) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 77e6ebd..09f99e8 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -905,7 +905,7 @@ H5D_t *
H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
hid_t dapl_id, hid_t dxpl_id)
{
- const H5T_t *type; /* Datatype for dataset */
+ const H5T_t *type, *dt; /* Datatype for dataset */
H5D_t *new_dset = NULL;
H5P_genplist_t *dc_plist = NULL; /* New Property list */
hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */
@@ -923,8 +923,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
HDassert(H5I_GENPROP_LST == H5I_get_type(dxpl_id));
/* Get the dataset's datatype */
- if(NULL == (type = (const H5T_t *)H5I_object(type_id)))
+ if(NULL == (dt = (const H5T_t *)H5I_object(type_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype")
+ /* Get the actual datatype object if this is a named datatype */
+ if(NULL == (type = (const H5T_t *)H5T_get_named_type(dt)))
+ type = dt;
/* Check if the datatype is "sensible" for use in a dataset */
if(H5T_is_sensible(type) != TRUE)
@@ -2676,6 +2679,7 @@ hid_t
H5D_get_type(H5D_t *dset)
{
H5T_t *dt = NULL;
+ H5T_t *type = NULL;
hid_t ret_value = FAIL;
FUNC_ENTER_NOAPI_NOINIT
@@ -2697,13 +2701,36 @@ H5D_get_type(H5D_t *dset)
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(H5T_committed(dt)) {
+ /* If this is a committed datatype, we need to recreate the
+ two level IDs, where the VOL object is a copy of the
+ returned datatype */
+ ssize_t nalloc = 0;
+ size_t size;
+ unsigned char *buf = NULL;
+
+ /* Copy the dataset's datatype */
+ if(NULL == (type = H5T_copy(dt, H5T_COPY_REOPEN)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype")
+
+ H5T_set_vol_object(type, (void *)dt);
+
+ if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
+
+ if (H5VL_native_register_aux(ret_value) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ }
+ else {
+ 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")
+ if(type && H5T_close(type) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5T.c b/src/H5T.c
index 30dec9a..b0cb67d 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3143,7 +3143,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
/* Check if the VOL_obj exists, then this type is the one we want to copy */
//if(NULL != old->vol_obj)
- // old_dt = (H5T_t *)(old->vol_obj);
+ //old_dt = (H5T_t *)(old->vol_obj);
/* Allocate space */
if(NULL == (new_dt = H5FL_MALLOC(H5T_t)))
@@ -3153,7 +3153,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
/* Copy shared information (entry information is copied last) */
*(new_dt->shared) = *(old_dt->shared);
-
+ new_dt->vol_obj = NULL;
/* Check what sort of copy we are making */
switch (method) {
case H5T_COPY_TRANSIENT:
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index 707ef21..e2995b8 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -160,19 +160,6 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- /*
- * Check arguments. We cannot commit an immutable type because H5Tclose()
- * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing
- * 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")
- if(H5T_STATE_IMMUTABLE == type->shared->state)
- 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)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible")
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
@@ -1072,3 +1059,11 @@ H5T_close_datatype(void *type, H5VL_t *vol_plugin)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_close_datatype() */
+
+herr_t
+H5T_set_vol_object(H5T_t *type, void *vol_obj)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+ type->vol_obj = vol_obj;
+ FUNC_LEAVE_NOAPI(SUCCEED)
+}
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 5408b49..49674fd 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -142,6 +142,7 @@ H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc);
H5_DLL H5T_t *H5T_decode(const unsigned char *buf);
H5_DLL void * H5T_get_named_type(H5T_t *dt);
H5_DLL hid_t H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hid_t req);
+H5_DLL herr_t H5T_set_vol_object(H5T_t *type, void *vol_obj);
/* Reference specific functions */
H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt);
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 41d407c..b0c532a 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -385,7 +385,7 @@ H5VL_get_object(hid_t id)
/* get the object */
if(NULL == (ret_value = (void *)H5I_object(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid file identifier")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier")
if (H5I_DATATYPE == H5I_get_type(id)) {
if (NULL == (ret_value = H5T_get_named_type((H5T_t *)ret_value)))
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 413bb2f..9f79946 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -473,8 +473,7 @@ H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *att
hbool_t loc_found = FALSE;
H5P_genplist_t *plist; /* Property list pointer */
hid_t type_id, space_id;
- H5T_t *type; /* Datatype to use for attribute */
- H5T_t *named_type; /* Named Datatype to use for attribute */
+ H5T_t *type, *dt; /* Datatype to use for attribute */
H5S_t *space; /* Dataspace to use for attribute */
H5A_t *attr = NULL;
void *ret_value = NULL;
@@ -495,16 +494,16 @@ H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *att
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR))
HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file")
- if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a type")
+ /* Get the actual datatype object if this is a named datatype */
+ if(NULL == (type = (H5T_t *)H5T_get_named_type(dt)))
+ type = dt;
+
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space")
- //if(NULL != (named_type = (H5T_t *)H5T_get_named_type(type)))
- if(H5T_STATE_OPEN == type->shared->state || H5T_STATE_NAMED == type->shared->state){
- type = (H5T_t *)(type->vol_obj);
- }
-
if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Acreate */
/* Go do the real work for attaching the attribute to the dataset */
if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)))
@@ -1022,7 +1021,7 @@ H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char
/* Copy the datatype - the copied one will be the type that is
committed, and attached to original datatype above the VOL
layer*/
- if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT)))
+ if(NULL == (type = H5T_copy(dt, H5T_COPY_REOPEN)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy");
if(NULL != name) { /* H5Tcommit */
@@ -1049,11 +1048,7 @@ H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char
} /* end if */
}
ret_value = (void *)type;
- /* Increment reference count on atom because the commit callback in the native implementation
- return the same object as the type ID itself
- if(H5I_inc_ref(type_id, TRUE) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing type ID failed")
- */
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_datatype_commit() */