diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2012-07-09 22:20:16 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2012-07-09 22:20:16 (GMT) |
commit | e582da571d5ac665351768c9c4ae5fb3f863c9cc (patch) | |
tree | df8e40912c9e21c5addbed77f6c2f43482584c84 /src | |
parent | 843ccf86dd147e245bab269520741b0f103b4d6b (diff) | |
download | hdf5-e582da571d5ac665351768c9c4ae5fb3f863c9cc.zip hdf5-e582da571d5ac665351768c9c4ae5fb3f863c9cc.tar.gz hdf5-e582da571d5ac665351768c9c4ae5fb3f863c9cc.tar.bz2 |
[svn-r22532] fix more named datatype issues.
move the dataset ID registration to H5Dint where the term_interface func is located
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Aint.c | 2 | ||||
-rw-r--r-- | src/H5D.c | 6 | ||||
-rw-r--r-- | src/H5Dint.c | 10 | ||||
-rw-r--r-- | src/H5F.c | 7 | ||||
-rw-r--r-- | src/H5Fint.c | 13 | ||||
-rw-r--r-- | src/H5Gloc.c | 18 | ||||
-rw-r--r-- | src/H5I.c | 44 | ||||
-rw-r--r-- | src/H5T.c | 10 | ||||
-rw-r--r-- | src/H5Tcommit.c | 27 | ||||
-rw-r--r-- | src/H5Tdeprec.c | 118 | ||||
-rw-r--r-- | src/H5Toh.c | 2 | ||||
-rw-r--r-- | src/H5Torder.c | 2 | ||||
-rw-r--r-- | src/H5Tprecis.c | 4 | ||||
-rw-r--r-- | src/H5Tprivate.h | 2 | ||||
-rw-r--r-- | src/H5VLnative.c | 2 |
15 files changed, 143 insertions, 124 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c index cfe81dc..8d86931 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -779,7 +779,7 @@ H5A_get_type(H5A_t *attr) two level IDs, where the VOL object is a copy of the returned datatype */ /* Copy the dataset's datatype */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_REOPEN))) + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") H5T_set_vol_object(type, (void *)dt); @@ -86,6 +86,10 @@ DESCRIPTION static herr_t H5D__init_pub_interface(void) { + FUNC_ENTER_STATIC_NOERR + + FUNC_LEAVE_NOAPI(H5D_init()) +#if 0 herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -97,6 +101,7 @@ H5D__init_pub_interface(void) ret_value = H5D_init(); done: FUNC_LEAVE_NOAPI(ret_value) +#endif } /* H5D__init_pub_interface() */ @@ -197,7 +202,6 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, /* Get an atom for the dataset */ if((ret_value = H5I_register2(H5I_DATASET, dset, vol_plugin, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") - vol_plugin->nrefs ++; done: diff --git a/src/H5Dint.c b/src/H5Dint.c index 285ee9f..59a2015 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -162,6 +162,11 @@ H5D__init_interface(void) FUNC_ENTER_STATIC + /* Initialize the atom group for the dataset IDs */ + if(H5I_register_type2(H5I_DATASET, (size_t)H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS, + NULL, (H5I_free2_t)H5D_close_dataset)<H5I_FILE) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface") + /* Reset the "default dataset" information */ HDmemset(&H5D_def_dset, 0, sizeof(H5D_shared_t)); @@ -906,7 +911,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, *dt; /* 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 */ @@ -926,6 +931,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Get the dataset's datatype */ 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; @@ -2708,7 +2714,7 @@ H5D_get_type(H5D_t *dset) returned datatype */ /* Copy the dataset's datatype */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_REOPEN))) + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") H5T_set_vol_object(type, (void *)dt); @@ -269,13 +269,12 @@ H5Fget_obj_count(hid_t file_id, unsigned types) H5VL_t *vol_plugin; void *obj; - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the file object */ if(NULL == (obj = (void *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_COUNT, H5_REQUEST_NULL, &ret_value, types) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object count in file(s)") diff --git a/src/H5Fint.c b/src/H5Fint.c index 29c6a20..e584dd3 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -511,12 +511,15 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) break; case H5I_DATATYPE: - if(H5T_is_named((H5T_t*)obj_ptr)==TRUE) - oloc = H5T_oloc((H5T_t*)obj_ptr); - else - oloc = NULL; + { + H5T_t *type; + /* Get the actual datatype object that should be the vol_obj */ + if(NULL == (type = (H5T_t *)H5T_get_named_type((H5T_t*)obj_ptr))) + oloc = NULL; + else + oloc = H5T_oloc(type); break; - + } case H5I_UNINIT: case H5I_BADID: case H5I_FILE: diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 58ae55a..2a83f15 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -174,11 +174,19 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") break; case H5I_DATATYPE: - if(NULL == (loc->oloc = H5T_oloc((H5T_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") - if(NULL == (loc->path = H5T_nameof((H5T_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") - break; + { + H5T_t *dt = NULL; + + /* Get the actual datatype object if the VOL object is set */ + if(NULL == (dt = (H5T_t *)H5T_get_named_type((const H5T_t *)obj))) + dt = (H5T_t *) obj; + + if(NULL == (loc->oloc = H5T_oloc(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") + if(NULL == (loc->path = H5T_nameof(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") + break; + } case H5I_DATASET: if(NULL == (loc->oloc = H5D_oloc((H5D_t *)obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") @@ -578,6 +578,7 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) for(cur = type_ptr->id_list[i]; cur; cur = next) { hbool_t delete_node; /* Flag to indicate node should be removed from linked list */ + herr_t result1 = SUCCEED, result2 = SUCCEED; /* * Do nothing to the object if the reference count is larger than @@ -590,9 +591,11 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) /* Check for a 'free' function and call it, if it exists */ /* (Casting away const OK -QAK) */ - if((cur->aux_ptr && type_ptr->free_aux && (type_ptr->free_aux)((void *)cur->obj_ptr, (void *)cur->aux_ptr) < 0) || - (type_ptr->free_func && (type_ptr->free_func)((void *)cur->obj_ptr) < 0)) { - //if(type_ptr->free_func && (type_ptr->free_func)((void *)cur->obj_ptr) < 0) { + if(cur->aux_ptr && type_ptr->free_aux) + result1 = (type_ptr->free_aux)((void *)cur->obj_ptr, (void *)cur->aux_ptr); + if(type_ptr->free_func) + result2 = (type_ptr->free_func)((void *)cur->obj_ptr); + if(result1 < 0 || result2 < 0) { if(force) { #ifdef H5I_DEBUG if(H5DEBUG(I)) { @@ -1344,7 +1347,8 @@ H5I_dec_ref(hid_t id) */ if(1 == id_ptr->count) { /* (Casting away const OK -QAK) */ - if((!id_ptr->aux_ptr || !type_ptr->free_aux || (type_ptr->free_aux)((void *)id_ptr->obj_ptr, (void *)id_ptr->aux_ptr) >= 0) && + if((!type_ptr->free_aux || !id_ptr->aux_ptr || + (type_ptr->free_aux)((void *)id_ptr->obj_ptr, (void *)id_ptr->aux_ptr) >= 0) && (!type_ptr->free_func || (type_ptr->free_func)((void *)id_ptr->obj_ptr) >= 0)) { H5I_remove(id); ret_value = 0; @@ -2180,20 +2184,9 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size) FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", id, name, size); - /* add a workaround for named datatypes for now */ - if(H5I_TYPE(id) == H5I_DATATYPE) { - H5T_t *type = NULL, *dt = NULL; - - if(NULL == (dt = (H5T_t *)H5VL_get_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") - if(H5G_loc_real((void *)dt, H5I_DATATYPE, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - } - else { - /* Get object location */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location") - } + /* Get object location */ + if(H5G_loc(id, &loc) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location") /* Call internal group routine to retrieve object's name */ if((ret_value = H5G_get_name(&loc, name, size, NULL, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) @@ -2428,7 +2421,6 @@ H5I_register_type2(H5I_type_t type_id, size_t hash_size, unsigned reserved, type_ptr->nextid = reserved; type_ptr->free_func = free_func; type_ptr->free_aux = free_aux; - type_ptr->id_list = (H5I_id_info_t **)H5MM_calloc(hash_size * sizeof(H5I_id_info_t *)); if(NULL == type_ptr->id_list) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_BADID, "memory allocation failed") @@ -2563,7 +2555,7 @@ done: /*------------------------------------------------------------------------- * Function: H5I_register_aux * - * Purpose: increment the ref count on the high level ID given the low level ID + * Purpose: register an Auxilary object and a free func with an existing ID * * Return: Success: postive * Failure: FAIL @@ -2576,7 +2568,7 @@ done: herr_t H5I_register_aux(hid_t id, void *aux_ptr, H5I_free2_t free_func) { - H5I_id_type_t *type_ptr; /*ptr to the type*/ + H5I_id_type_t *type_ptr = NULL; /*ptr to the type*/ H5I_id_info_t *id_ptr = NULL; /*ptr to the id*/ H5I_type_t type; herr_t ret_value = SUCCEED; /*return value*/ @@ -2586,11 +2578,11 @@ H5I_register_aux(hid_t id, void *aux_ptr, H5I_free2_t free_func) /* Check arguments */ type = H5I_TYPE(id); if (type <= H5I_BADID || type >= H5I_next_type) - HGOTO_DONE(NULL); + HGOTO_DONE(FAIL); type_ptr = H5I_id_type_list_g[type]; if (!type_ptr || type_ptr->count <= 0) - HGOTO_DONE(NULL); + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid type") type_ptr->free_aux = free_func; @@ -2598,6 +2590,7 @@ H5I_register_aux(hid_t id, void *aux_ptr, H5I_free2_t free_func) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "Invalid ID") id_ptr->aux_ptr = aux_ptr; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_register_aux() */ @@ -2621,9 +2614,9 @@ void * H5I_get_aux(hid_t id) { H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ - void * ret_value = NULL; /*return value */ + void *ret_value = NULL; /*return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(NULL) if(NULL != (id_ptr = H5I_find_id(id))) { ret_value = (void *)id_ptr->aux_ptr; @@ -2656,7 +2649,6 @@ H5I_get_id(void *object, H5I_type_t type) FUNC_ENTER_NOAPI(FAIL) type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") @@ -743,7 +743,7 @@ H5T_init_interface(void) /* Initialize the atom group for the file IDs */ if(H5I_register_type2(H5I_DATATYPE, (size_t)H5I_DATATYPEID_HASHSIZE, H5T_RESERVED_ATOMS, - (H5I_free_t)H5T_close, (H5I_free2_t)H5T_close_datatype)<H5I_FILE) + (H5I_free_t)H5T_close, (H5I_free2_t)H5T_close_datatype)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Make certain there aren't too many classes of datatypes defined */ @@ -1717,14 +1717,6 @@ H5Tclose(hid_t type_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); -#if 0 - /* if this is a named datatype, go through the VOL layer */ - if(NULL != H5I_get_aux(type_id)) { - if(H5VL_datatype_close(type_id, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to free datatype") - } - else { -#endif /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 8599765..44e5b8b 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -134,6 +134,8 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id); /* Check arguments */ + if (H5Tcommitted(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -164,7 +166,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the file object */ + /* get the object from the loc_id */ if(NULL == (obj = (void *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* get the plugin pointer */ @@ -305,6 +307,10 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) FUNC_ENTER_API(FAIL) H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id); + /* check args */ + if (H5Tcommitted(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") + /* Get correct property list */ if(H5P_DEFAULT == tcpl_id) tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; @@ -491,7 +497,6 @@ done: htri_t H5Tcommitted(hid_t type_id) { - H5T_t *dt; H5T_t *type; /* Datatype to query */ htri_t ret_value; /* Return value */ @@ -502,13 +507,8 @@ H5Tcommitted(hid_t type_id) if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (NULL == type->vol_obj) - dt = type; - else - dt = (H5T_t *)type->vol_obj; - /* Set return value */ - ret_value = H5T_committed(dt); + ret_value = H5T_committed(type); done: FUNC_LEAVE_API(ret_value) @@ -530,11 +530,18 @@ done: htri_t H5T_committed(const H5T_t *type) { + const H5T_t *dt; + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(type); - FUNC_LEAVE_NOAPI(H5T_STATE_OPEN == type->shared->state || H5T_STATE_NAMED == type->shared->state) + if (NULL == type->vol_obj) + dt = type; + else + dt = (const H5T_t *)type->vol_obj; + + FUNC_LEAVE_NOAPI(H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state) } /* end H5T_committed() */ @@ -923,7 +930,7 @@ H5T_update_shared(H5T_t *dt) *------------------------------------------------------------------------- */ void * -H5T_get_named_type(H5T_t *dt) +H5T_get_named_type(const H5T_t *dt) { void *ret_value = NULL; /* Return value */ diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 32080fe..ce82b2d 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -47,7 +47,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Ppublic.h" /* Property Lists */ #include "H5Tpkg.h" /* Datatypes */ - +#include "H5VLprivate.h" /* VOL plugins */ #ifndef H5_NO_DEPRECATED_SYMBOLS /****************/ @@ -125,25 +125,49 @@ H5T_init_deprec_interface(void) herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *type; /* Datatype for ID */ + void *dt = NULL; + H5T_t *type = NULL; + void *obj = NULL; /* object token of loc_id */ + H5VL_t *vol_plugin; /* VOL plugin information */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*si", loc_id, name, type_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if (H5Tcommitted(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") 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") - /* Commit the datatype to the file, using default property list values */ - if(H5T__commit_named(&loc, name, type, H5P_LINK_CREATE_DEFAULT, - H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + 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 == (obj = (void *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object 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") + + /* commit the datatype through the VOL */ + if (NULL == (dt = H5VL_datatype_commit(obj, loc_params, vol_plugin, name, type_id, + H5P_LINK_CREATE_DEFAULT, H5P_DATATYPE_CREATE_DEFAULT, + H5P_DATATYPE_ACCESS_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype") + + /* attach the vol object created using the commit call to the + library datatype structure */ + /* set the committed type object to the VOL pluging pointer in the H5T_t struct */ + type->vol_obj = dt; + + /* attach VOL information to the ID */ + if (H5I_register_aux(type_id, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs ++; done: FUNC_LEAVE_API(ret_value) @@ -169,62 +193,42 @@ done: hid_t H5Topen1(hid_t loc_id, const char *name) { - H5T_t *type = NULL; - H5G_loc_t loc; - 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_dxpl_id; /* dxpl to use to open datatype */ - hid_t ret_value = FAIL; + void *dt = NULL; /* datatype token from VOL plugin */ + void *obj = NULL; /* object token of loc_id */ + H5VL_t *vol_plugin; /* VOL plugin information */ + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("i", "i*s", loc_id, name); + H5TRACE2("i", "i*si", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no 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*/, H5P_DEFAULT, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") - obj_found = TRUE; - - /* 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((type = H5T_open(&type_loc, dxpl_id)) == NULL) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "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") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); -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 */ + /* get the file object */ + if(NULL == (obj = (void *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file 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") + + /* Create the datatype through the VOL */ + if(NULL == (dt = H5VL_datatype_open(obj, loc_params, vol_plugin, name, + H5P_DATATYPE_ACCESS_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open datatype") + /* Get an atom for the datatype */ + if ((ret_value = H5VL_create_datatype(dt, vol_plugin, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") + +done: + if (ret_value < 0 && dt) + if(H5VL_datatype_close (dt, vol_plugin, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Topen1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Toh.c b/src/H5Toh.c index e90d22f..9c9313a 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -145,7 +145,7 @@ H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hb HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open datatype") /* Copy the dataset's datatype */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_REOPEN))) + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") H5T_set_vol_object(type, (void *)dt); diff --git a/src/H5Torder.c b/src/H5Torder.c index 35be454..b807464 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -236,6 +236,8 @@ H5Tset_order(hid_t type_id, H5T_order_t order) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") if(order < H5T_ORDER_LE || order > H5T_ORDER_NONE || order == H5T_ORDER_MIXED) HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order") + if (NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") if(H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is read-only") diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index dd89b59..671ae2e 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -179,7 +179,9 @@ H5Tset_precision(hid_t type_id, size_t prec) if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is committed") if (prec == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 49674fd..f4df875 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -140,7 +140,7 @@ H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); 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 void * H5T_get_named_type(const 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); diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 28e8f9d..6bf8fc0 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -1004,7 +1004,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_REOPEN))) + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); if(NULL != name) { /* H5Tcommit */ |