From 04b257f380589c9136005695921bafdb5aa940fc Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Mon, 26 Mar 2012 15:47:38 -0500 Subject: [svn-r22151] - object lookup returns the haddr_t - make the VL implementation for all variations of H5Oopen, H5Oget_info, H5Gget_info common, by looking up the object location first. --- src/H5Adeprec.c | 23 ++++++- src/H5D.c | 4 +- src/H5G.c | 47 +++++++++++--- src/H5L.c | 17 ++--- src/H5O.c | 70 +++++++++++++++++---- src/H5VL.c | 17 +++-- src/H5VLnative.c | 186 ++++++++++++++++++++----------------------------------- src/H5VLpublic.h | 7 ++- 8 files changed, 215 insertions(+), 156 deletions(-) diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 22faaa2..75f644f 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -302,14 +302,33 @@ done: Deprecated in favor of H5Oget_info --------------------------------------------------------------------------*/ int -H5Aget_num_attrs(hid_t loc_id) +H5Aget_num_attrs(hid_t id) { H5O_loc_t *loc; /* Object location for attribute */ void *obj; + H5I_t *uid_info; /* user id structure */ + hid_t loc_id; + H5I_type_t id_type; int ret_value; FUNC_ENTER_API(FAIL) - H5TRACE1("Is", "i", loc_id); + H5TRACE1("Is", "i", id); + + id_type = H5I_get_type(id); + /* get the actual ID from an upper ID level */ + /* MSC - this is a workaround to allow the test suite to pass and + at some point needs to be removed once all high level operations + that needs to go through the VOL actually go through the VOL*/ + if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || + H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || + H5I_ATTRIBUTE_PUBLIC == id_type) { + if(NULL == (uid_info = (H5I_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, NULL, "invalid user identifier") + loc_id = uid_info->obj_id; + } + else { + loc_id = id; + } /* check arguments */ if(H5I_BADID == H5I_get_type(loc_id)) diff --git a/src/H5D.c b/src/H5D.c index f04554a..c3c28ea 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -725,8 +725,8 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, H5TRACE4("e", "iii*h", dataset_id, type_id, space_id, size); /* Check args */ - if(H5I_DATASET != H5I_get_type(dataset_id) || - H5I_DATATYPE != H5I_get_type(type_id) || size == NULL) + if(H5I_DATASET_PUBLIC != H5I_get_type(dataset_id) || + H5I_DATATYPE != H5I_get_type(type_id) || size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") diff --git a/src/H5G.c b/src/H5G.c index df50dd6..0e0de6a 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -459,25 +459,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_info(hid_t obj_id, H5G_info_t *grp_info) +H5Gget_info(hid_t loc_id, H5G_info_t *grp_info) { H5I_type_t id_type; /* Type of ID */ + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", obj_id, grp_info); + H5TRACE2("e", "i*x", loc_id, grp_info); /* Check args */ - id_type = H5I_get_type(obj_id); + id_type = H5I_get_type(loc_id); if(!(H5I_GROUP_PUBLIC == id_type || H5I_FILE_PUBLIC == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(!grp_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if((ret_value = H5VL_group_get(obj_id, H5G_GET_INFO, 1, grp_info)) < 0) + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5O_LOOKUP, 1, &location) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_group_get(loc_id, H5G_GET_INFO, 2, grp_info, location)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Gget_info() */ @@ -499,6 +510,8 @@ herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, hid_t lapl_id) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -515,10 +528,19 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - if((ret_value = H5VL_group_get(loc_id, H5G_GET_INFO, 3, grp_info, name, lapl_id)) < 0) + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_NAME, 3, &location, name, lapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_group_get(loc_id, H5G_GET_INFO, 2, grp_info, location)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_name() */ @@ -541,6 +563,8 @@ herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -562,11 +586,20 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - if((ret_value = H5VL_group_get(loc_id, H5G_GET_INFO, 6, grp_info, group_name, - idx_type, order, n, lapl_id)) < 0) + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup(loc_id, H5O_LOOKUP_BY_IDX, 6, &location, group_name, + idx_type, order, n, lapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_group_get(loc_id, H5G_GET_INFO, 2, grp_info, location)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_idx() */ diff --git a/src/H5L.c b/src/H5L.c index 4f757f1..641d72c 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -1147,7 +1147,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate(hid_t uid, H5_index_t idx_type, H5_iter_order_t order, +H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data) { H5I_type_t id_type; /* Type of ID */ @@ -1159,19 +1159,22 @@ H5Literate(hid_t uid, H5_index_t idx_type, H5_iter_order_t order, herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "iIiIo*hx*x", grp_id, idx_type, order, idx_p, op, op_data); + H5TRACE6("e", "iIiIo*hx*x", id, idx_type, order, idx_p, op, op_data); /* Check arguments */ - id_type = H5I_get_type(uid); - - if (H5I_FILE_PUBLIC == id_type) { - if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + id_type = H5I_get_type(id); + /* get the actual ID from an upper ID level */ + /* MSC - this is a workaround to allow the test suite to pass and + at some point needs to be removed once all high level operations + that needs to go through the VOL actually go through the VOL*/ + if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type) { + if(NULL == (uid_info = (H5I_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") grp_id = uid_info->obj_id; id_type = H5I_get_type(grp_id); } else { - grp_id = uid; + grp_id = id; } if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) diff --git a/src/H5O.c b/src/H5O.c index 23632b1..c24b789 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -304,8 +304,8 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_IDX, 6, &location, group_name, - idx_type, order, n, lapl_id) < 0) + if(H5VL_object_lookup(loc_id, H5O_LOOKUP_BY_IDX, 6, &location, group_name, + idx_type, order, n, lapl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ @@ -581,6 +581,8 @@ done: herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -590,10 +592,33 @@ H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 1, oinfo)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") + /* Check id */ + if(H5I_GROUP_PUBLIC != H5I_get_type(loc_id) && H5I_DATASET_PUBLIC != H5I_get_type(loc_id) && + H5I_DATATYPE_PUBLIC != H5I_get_type(loc_id) && H5I_FILE_PUBLIC != H5I_get_type(loc_id)) { + H5G_loc_t loc; /* Location of group */ + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + if(H5G_loc_info(&loc, ".", TRUE, oinfo/*out*/, H5P_LINK_ACCESS_DEFAULT, + H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + } + + else { + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5O_LOOKUP, 1, &location) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 2, oinfo, location)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") + } done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Oget_info() */ @@ -614,6 +639,8 @@ done: herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -630,10 +657,19 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 3, oinfo, name, lapl_id)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_NAME, 3, &location, name, lapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 2, oinfo, location)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_name() */ @@ -656,6 +692,8 @@ herr_t H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -677,11 +715,20 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 6, oinfo, group_name, idx_type, - order, n, lapl_id)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup(loc_id, H5O_LOOKUP_BY_IDX, 6, &location, group_name, + idx_type, order, n, lapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 2, oinfo, location)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx() */ @@ -2382,9 +2429,8 @@ H5O_get_loc(hid_t id) /* MSC - this is a workaround to allow the test suite to pass and at some point needs to be removed once all high level operations that needs to go through the VOL actually go through the VOL*/ - if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || - H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || - H5I_ATTRIBUTE_PUBLIC == id_type) { + if (H5I_GROUP_PUBLIC == id_type || H5I_DATASET_PUBLIC == id_type || + H5I_DATATYPE_PUBLIC == id_type) { if(NULL == (uid_info = (H5I_t *)H5I_object(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, NULL, "invalid user identifier") object_id = uid_info->obj_id; diff --git a/src/H5VL.c b/src/H5VL.c index ab16fb3..7b0de41 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -938,12 +938,14 @@ H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, int num_args, ...) { H5I_t *uid_info; /* user id structure */ va_list arguments; /* argument list passed from the API call */ + H5I_type_t id_type; /* Type of ID */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) + id_type = H5I_get_type(uid); /* Check/fix arguments. */ - if(H5I_GROUP_PUBLIC != H5I_get_type(uid)) + if(H5I_GROUP_PUBLIC != id_type && H5I_FILE_PUBLIC != id_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ @@ -1115,12 +1117,16 @@ H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, int num_args, .. { H5I_t *uid_info; /* user id structure */ va_list arguments; /* argument list passed from the API call */ + H5I_type_t id_type; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) + id_type = H5I_get_type(uid); /* Check id */ - if(H5I_FILE_PUBLIC != H5I_get_type(uid) && H5I_GROUP_PUBLIC != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && + H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && + H5I_ATTRIBUTE_PUBLIC != id_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* lookup the ID struct */ @@ -1159,13 +1165,16 @@ H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, int num_args, ...) { H5I_t *uid_info; /* user id structure */ va_list arguments; /* argument list passed from the API call */ + H5I_type_t id_type; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) + id_type = H5I_get_type(uid); /* Check id */ - if(H5I_GROUP_PUBLIC != H5I_get_type(uid) && H5I_DATASET_PUBLIC != H5I_get_type(uid) && - H5I_DATATYPE_PUBLIC != H5I_get_type(uid) && H5I_FILE_PUBLIC != H5I_get_type(uid)) + if(H5I_GROUP_PUBLIC != id_type && H5I_DATASET_PUBLIC != id_type && + H5I_DATATYPE_PUBLIC != id_type && H5I_FILE_PUBLIC != id_type && + H5I_ATTRIBUTE_PUBLIC != id_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 7e29105..23e1ce5 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -1003,62 +1003,23 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, int num_args, va_ /* H5Fget_info2 */ case H5G_GET_INFO: { - H5G_loc_t loc; H5G_info_t *grp_info = va_arg (arguments, H5G_info_t *); + haddr_t *addr = va_arg (arguments, haddr_t *); + H5G_loc_t loc; + H5O_loc_t oloc; /* Opened object object location */ - /* Get group location */ if(H5G_loc(obj_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* Retrieve the object's information */ - if(1 == num_args) { - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } - else if(3 == num_args) { - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - char *name = va_arg (arguments, char *); - hid_t lapl_id = va_arg (arguments, hid_t); - - /* Set up opened group location to fill in */ - grp_loc.oloc = &grp_oloc; - grp_loc.path = &grp_path; - H5G_loc_reset(&grp_loc); + if(!H5F_addr_defined(*addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") - /* Find the group object */ - if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; + oloc.addr = *addr; + oloc.file = loc.oloc->file; - /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } - else if (6 == num_args) { - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - char *group_name = va_arg (arguments, char *); - H5_index_t idx_type = va_arg (arguments, H5_index_t); - H5_iter_order_t order = va_arg (arguments, H5_iter_order_t); - hsize_t n = va_arg (arguments, hsize_t); - hid_t lapl_id = va_arg (arguments, hid_t); - - /* Set up opened group location to fill in */ - grp_loc.oloc = &grp_oloc; - grp_loc.path = &grp_path; - H5G_loc_reset(&grp_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; - - /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } + /* Retrieve the group's information */ + if(H5G__obj_info(&oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") break; } default: @@ -1073,10 +1034,6 @@ done: HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") } /* end if */ } - if (H5G_GET_INFO == get_type) { - if(loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - } FUNC_LEAVE_NOAPI(ret_value) } @@ -1097,14 +1054,33 @@ done: static hid_t H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id) { - hid_t ret_value = FAIL; + H5G_loc_t loc; + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + haddr_t addr = *((haddr_t *)location); + hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT - //obj_loc = (H5G_loc_t *)(*location); + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + obj_loc.oloc->addr = addr; + obj_loc.oloc->file = loc.oloc->file; + H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ + /* Open the object */ - if((ret_value = H5O_open_by_loc((H5G_loc_t *)location, lapl_id, H5AC_dxpl_id, TRUE)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_object_open() */ @@ -1183,8 +1159,6 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, int num_args, va_li { herr_t ret_value = SUCCEED; /* Return value */ H5G_loc_t loc; /* Location of group */ - H5G_loc_t obj_loc; /* Location used to open group */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ FUNC_ENTER_NOAPI_NOINIT @@ -1196,43 +1170,18 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, int num_args, va_li case H5O_GET_INFO: { H5O_info_t *obj_info = va_arg (arguments, H5O_info_t *); + haddr_t *addr = va_arg (arguments, haddr_t *); + H5O_loc_t oloc; /* Opened object object location */ - /* Retrieve the object's information */ - if(1 == num_args) { - if(H5G_loc_info(&loc, ".", TRUE, obj_info/*out*/, H5P_LINK_ACCESS_DEFAULT, - H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") - } - else if(3 == num_args) { - char *name = va_arg (arguments, char *); - hid_t lapl_id = va_arg (arguments, hid_t); + if(!H5F_addr_defined(*addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") - if(H5G_loc_info(&loc, name, TRUE, obj_info/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") - } - else if (6 == num_args) { - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - char *group_name = va_arg (arguments, char *); - H5_index_t idx_type = va_arg (arguments, H5_index_t); - H5_iter_order_t order = va_arg (arguments, H5_iter_order_t); - hsize_t n = va_arg (arguments, hsize_t); - hid_t lapl_id = va_arg (arguments, hid_t); - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, H5AC_ind_dxpl_id, TRUE, obj_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") - } + oloc.addr = *addr; + oloc.file = loc.oloc->file; + + /* Retrieve the object's information */ + if(H5O_get_info(&oloc, H5AC_ind_dxpl_id, TRUE, obj_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") break; } /* H5Oget_comment / H5Oget_comment_by_name */ @@ -1262,12 +1211,12 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, int num_args, va_li HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") } done: - /* Release the object location */ + /* Release the object location if(loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_object_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_native_object_lookup @@ -1287,40 +1236,45 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, int num_args, va_list arguments) { H5G_loc_t loc; - H5G_loc_t *obj_loc, **location; /* Location used to open group */ + H5G_loc_t obj_loc; + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + haddr_t **location; + haddr_t obj_addr; hbool_t loc_found = FALSE; /* Entry at 'name' found */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT + location = va_arg (arguments, haddr_t **); + *location = (haddr_t *) malloc (sizeof (haddr_t)); + if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - location = va_arg (arguments, H5G_loc_t **); - - if (NULL == (*location = (H5G_loc_t *)malloc(sizeof(H5G_loc_t)))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "memory allocation failed for object location") - - obj_loc = (H5G_loc_t *)(*location); - /* Set up opened group location to fill in */ - obj_loc->path = (H5G_name_t *)malloc(sizeof(H5G_name_t)); - obj_loc->oloc = (H5O_loc_t *)malloc(sizeof(H5O_loc_t)); - H5G_loc_reset(obj_loc); + obj_loc.path = &obj_path; + obj_loc.oloc = &obj_oloc; + H5G_loc_reset(&obj_loc); switch (lookup_type) { + case H5O_LOOKUP: + { + obj_addr = loc.oloc->addr; + break; + } case H5O_LOOKUP_BY_NAME: { char *name = va_arg (arguments, char *); hid_t lapl_id = va_arg (arguments, hid_t); - HDassert(&loc); HDassert(name && *name); /* Find the object's location */ - if((ret_value = H5G_loc_find(&loc, name, obj_loc/*out*/, lapl_id, H5AC_dxpl_id)) < 0) + if((ret_value = H5G_loc_find(&loc, name, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; + obj_addr = (haddr_t)obj_loc.oloc->addr; break; } case H5O_LOOKUP_BY_IDX: @@ -1333,32 +1287,26 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, /* Find the object's location, according to the order in the index */ if((ret_value = H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, - obj_loc/*out*/, lapl_id, H5AC_dxpl_id)) < 0) + &obj_loc/*out*/, lapl_id, H5AC_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; + obj_addr = (haddr_t)obj_loc.oloc->addr; break; } case H5O_LOOKUP_BY_ADDR: { - haddr_t addr = va_arg (arguments, haddr_t); - - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") - - obj_loc->oloc->addr = addr; - obj_loc->oloc->file = loc.oloc->file; - H5G_name_reset(obj_loc->path); /* objects opened through this routine don't have a path name */ - loc_found = TRUE; + obj_addr = va_arg (arguments, haddr_t); break; } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't lookup this object") } + *location[0] = obj_addr; done: /* Release the object location if we failed after copying it */ if(ret_value == FAIL && loc_found) - if(H5G_loc_free(obj_loc) < 0) + if(H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 0c62563..7ebba77 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -67,9 +67,10 @@ typedef enum H5VL_object_get_t { /* types for all object lookup API routines */ typedef enum H5VL_object_lookup_t { - H5O_LOOKUP_BY_NAME = 0, - H5O_LOOKUP_BY_IDX = 1, - H5O_LOOKUP_BY_ADDR = 2 + H5O_LOOKUP = 0, + H5O_LOOKUP_BY_NAME = 1, + H5O_LOOKUP_BY_IDX = 2, + H5O_LOOKUP_BY_ADDR = 3 } H5VL_object_lookup_t; #define H5VL_VOL_DEFAULT 0 /* Default VOL plugin value */ -- cgit v0.12