From 0b398e57b8f6f3ddf092754bb7b101b63487ce27 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Fri, 1 Jun 2012 09:23:35 -0500 Subject: [svn-r22423] add link and object iterate callbacks update some deprecated routines to use VOL --- src/H5Gdeprec.c | 163 +++++++++++------------------------------------------- src/H5L.c | 59 ++++++-------------- src/H5O.c | 23 ++++---- src/H5Opkg.h | 3 + src/H5Pfapl.c | 9 +-- src/H5VL.c | 79 ++++++++++++++++++++++++-- src/H5VLdummy.c | 1 + src/H5VLnative.c | 102 +++++++++++++++++++++++++++++++++- src/H5VLprivate.h | 5 ++ src/H5VLpublic.h | 7 +++ 10 files changed, 252 insertions(+), 199 deletions(-) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 4a2cf28..8c23c7c 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -77,10 +77,6 @@ typedef struct { /* Local Prototypes */ /********************/ -static herr_t H5G_link_hard(hid_t cur_loc_id, const char *cur_name, - hid_t new_loc_id, const char *new_name); -static herr_t H5G_move(hid_t src_loc_id, const char *src_name, - hid_t dst_loc_id, const char *dst_name); static herr_t H5G_get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); @@ -424,60 +420,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_link_hard - * - * Purpose: Creates a hard link from NEW_NAME to CUR_NAME. - * - * CUR_NAME must name an existing object. CUR_NAME and - * NEW_NAME are interpreted relative to CUR_LOC_ID and - * NEW_LOC_ID, which are either file IDs or group IDs. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_link_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, - const char *new_name) -{ - H5G_loc_t cur_loc, *cur_loc_p; /* Information about current link's group */ - H5G_loc_t new_loc, *new_loc_p; /* Information about new link's group */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Finish checking arguments */ - if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") - if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - new_loc_p = &new_loc; - if(cur_loc_id == H5L_SAME_LOC) - cur_loc_p = new_loc_p; - else if(new_loc_id == H5L_SAME_LOC) - new_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, - H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_hard() */ - - -/*------------------------------------------------------------------------- * Function: H5Gmove * * Purpose: Moves and renames a link. The new API to do this is H5Lmove. @@ -529,63 +471,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_move - * - * Purpose: Renames an object within an HDF5 file and moves it to a new - * group. The original name SRC is unlinked from the group graph - * and then inserted with the new name DST (which can specify a - * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name) -{ - H5G_loc_t src_loc, *src_loc_p; /* Group info for source location */ - H5G_loc_t dst_loc, *dst_loc_p; /* Group info for destination location */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; - - /* Move the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, H5P_DEFAULT, - H5P_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_move() */ - - -/*------------------------------------------------------------------------- * Function: H5Gunlink * * Purpose: Removes a link. The new API is H5Ldelete/H5Ldelete_by_idx. @@ -623,21 +508,19 @@ done: herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) { - H5G_loc_t loc; /* Group's location */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szx", loc_id, name, size, buf); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - /* Call the new link routine which provides this capability */ - if(H5L_get_val(&loc, name, buf, size, H5P_DEFAULT, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "couldn't get link info") + /* Get the link info through the VOL */ + if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_VAL, H5_REQUEST_NULL, name, buf, + size, NULL, H5P_LINK_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) @@ -664,18 +547,17 @@ done: herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { - H5G_loc_t loc; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, name, comment); - 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 specified") - if(H5G_loc_set_comment(&loc, name, comment, H5P_DEFAULT, H5AC_dxpl_id) < 0) + /* set comment on object through the VOL */ + if(H5VL_object_misc(loc_id, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, + name, comment, H5P_LINK_ACCESS_DEFAULT) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value") done: @@ -709,21 +591,22 @@ done: int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { - H5G_loc_t loc; + ssize_t size; int ret_value; FUNC_ENTER_API(FAIL) H5TRACE4("Is", "i*sz*s", loc_id, name, bufsize, buf); - 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 specified") if(bufsize > 0 && !buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified") - if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value") + if(H5VL_object_get(loc_id, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL, + &size, buf, bufsize, name, H5P_LINK_ACCESS_DEFAULT) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment") + + ret_value = (int)size; done: FUNC_LEAVE_API(ret_value) @@ -793,6 +676,26 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, if(idx_p) *idx_p = (int)last_obj; +#if 0 + herr_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "i*s*Isx*x", loc_id, name, idx_p, op, op_data); + + /* Check args */ + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if(idx_p && *idx_p < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") + if(!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* iterate over the links through the VOL */ + if((ret_value = H5VL_link_iterate(loc_id, name, FALSE, H5_INDEX_NAME, H5_ITER_INC, (hsize_t *)idx_p, + op, op_data, H5P_LINK_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") +#endif + done: FUNC_LEAVE_API(ret_value) } /* end H5Giterate() */ diff --git a/src/H5L.c b/src/H5L.c index 349d8af..97116ea 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -703,8 +703,9 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Get the link info through the VOL */ - if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_VAL, H5_REQUEST_NULL, name, buf, size, NULL, lapl_id)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") + if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_VAL, H5_REQUEST_NULL, name, buf, + size, NULL, lapl_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) @@ -1123,9 +1124,6 @@ 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 */ - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1142,22 +1140,11 @@ H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") - /* Set up iteration beginning/end info */ - idx = (idx_p == NULL ? 0 : *idx_p); - last_lnk = 0; - - /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_NEW; - lnk_op.op_func.op_new = op; - - /* Iterate over the links */ - if((ret_value = H5G_iterate(id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + /* iterate over the links through the VOL */ + if((ret_value = H5VL_link_iterate(id, ".", FALSE, idx_type, order, idx_p, + op, op_data, H5P_LINK_ACCESS_DEFAULT)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") - /* Set the index we stopped at */ - if(idx_p) - *idx_p = last_lnk; - done: FUNC_LEAVE_API(ret_value) } /* end H5Literate() */ @@ -1190,9 +1177,6 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data, hid_t lapl_id) { - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1214,22 +1198,11 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up iteration beginning/end info */ - idx = (idx_p == NULL ? 0 : *idx_p); - last_lnk = 0; - - /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_NEW; - lnk_op.op_func.op_new = op; - - /* Iterate over the links */ - if((ret_value = H5G_iterate(loc_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) + /* iterate over the links through the VOL */ + if((ret_value = H5VL_link_iterate(loc_id, group_name, FALSE, idx_type, order, idx_p, + op, op_data, lapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") - /* Set the index we stopped at */ - if(idx_p) - *idx_p = last_lnk; - done: FUNC_LEAVE_API(ret_value) } /* end H5Literate_by_name() */ @@ -1285,9 +1258,10 @@ H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - /* Call internal group visitation routine */ - if((ret_value = H5G_visit(grp_id, ".", idx_type, order, op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + /* iterate over the links through the VOL */ + if((ret_value = H5VL_link_iterate(grp_id, ".", TRUE, idx_type, order, NULL, + op, op_data, H5P_LINK_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) @@ -1347,9 +1321,10 @@ H5Lvisit_by_name(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") - /* Call internal group visitation routine */ - if((ret_value = H5G_visit(loc_id, group_name, idx_type, order, op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + /* visit the links through the VOL */ + if((ret_value = H5VL_link_iterate(loc_id, group_name, TRUE, idx_type, order, NULL, + op, op_data, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5O.c b/src/H5O.c index 8bf524d..2f09b6f 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -80,9 +80,6 @@ typedef struct { static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh); static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type); -static herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, - hid_t dxpl_id); static herr_t H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr); static const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); @@ -748,7 +745,7 @@ H5Oset_comment(hid_t obj_id, const char *comment) /* set comment on object through the VOL */ if(H5VL_object_misc(obj_id, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, ".", comment, H5P_LINK_ACCESS_DEFAULT) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value") done: FUNC_LEAVE_API(ret_value) @@ -792,7 +789,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, /* set comment on object through the VOL */ if(H5VL_object_misc(loc_id, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, name, comment, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value") done: FUNC_LEAVE_API(ret_value) @@ -825,7 +822,7 @@ H5Oget_comment(hid_t loc_id, char *comment, size_t bufsize) if(H5VL_object_get(loc_id, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL, &ret_value, comment, bufsize, ".", H5P_LINK_ACCESS_DEFAULT) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment") done: FUNC_LEAVE_API(ret_value) @@ -924,9 +921,9 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - /* Call internal object visitation routine */ - if((ret_value = H5O_visit(obj_id, ".", idx_type, order, op, op_data, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + /* iterate over the objects through the VOL */ + if((ret_value = H5VL_object_visit(obj_id, ".", idx_type, order, op, op_data, H5P_LINK_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) @@ -990,9 +987,9 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_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") - /* Call internal object visitation routine */ - if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + /* iterate over the objects through the VOL */ + if((ret_value = H5VL_object_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) @@ -3205,7 +3202,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, hid_t dxpl_id) diff --git a/src/H5Opkg.h b/src/H5Opkg.h index d4cc3fb..1a3f5c7 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -533,6 +533,9 @@ H5_DLL int H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t * H5_DLL herr_t H5O_inc_rc(H5O_t *oh); H5_DLL herr_t H5O_dec_rc(H5O_t *oh); H5_DLL herr_t H5O_free(H5O_t *oh); +H5_DLL herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, + hid_t dxpl_id); /* Object header message routines */ H5_DLL int H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index a6f0ea9..37f6869 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -2162,15 +2162,12 @@ done: /*------------------------------------------------------------------------- * Function: H5P_set_vol * - * Purpose: Set the file vol (VOL_ID) for a file access property list - * (PLIST_ID) and supply an optional struct containing the - * vol-specific properites (VOL_INFO). The vol properties will + * Purpose: Set the vol plugin for a file access property list + * (PLIST_ID). The vol properties will * be copied into the property list and the reference count on - * the vol will be incremented, allowing the caller to close the - * vol ID but still use the property list. + * the vol will be incremented. * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Mohamad Chaarawi diff --git a/src/H5VL.c b/src/H5VL.c index d4b1961..a873862 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -192,8 +192,6 @@ H5VL_free_cls(H5VL_class_t *cls) if(cls->terminate && cls->terminate() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "vol plugin '%s' did not terminate cleanly", cls->name) - H5MM_xfree(cls); - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_free_cls() */ @@ -430,7 +428,6 @@ H5VL_fapl_close(H5VL_class_t *vol_cls) if(NULL != vol_cls) { vol_cls->nrefs--; - //H5MM_xfree(vol_cls); } done: @@ -460,9 +457,6 @@ H5VL_close(H5VL_class_t *vol_plugin) vol_plugin->nrefs--; - if(0 == vol_plugin->nrefs) - H5MM_xfree(vol_plugin); - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_close() */ @@ -1775,6 +1769,43 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_link_iterate + * + * Purpose: Iterate over links in a group + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_link_iterate(hid_t loc_id, const char *name, hbool_t recursive, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate_t op, void *op_data, hid_t lapl_id) +{ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + + if(NULL == vol_plugin->link_cls.iterate) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link iterate' method") + + if((ret_value = (vol_plugin->link_cls.iterate)(loc_id, name, recursive, idx_type, + order, idx, op, op_data, lapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "iteration failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_iterate() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_link_get * * Purpose: Get specific information about the link through the VOL @@ -1935,6 +1966,42 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_object_visit + * + * Purpose: Iterate over links in a group + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id) +{ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + + if(NULL == vol_plugin->object_cls.visit) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link iterate' method") + + if((ret_value = (vol_plugin->object_cls.visit)(loc_id, obj_name, idx_type, order, op, + op_data, lapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "object visitation failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_visit() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_object_lookup * * Purpose: Lookup the object location in the file diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index b32c487..7be5825 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -62,6 +62,7 @@ static hid_t H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcp H5VL_class_t H5VL_dummy_g = { "dummy", /* name */ 0, /* nrefs */ + H5VL_dummy_init, H5VL_dummy_term, /*terminate */ { /* attribute_cls */ NULL, /* create */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 8e3b271..24b8947 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -103,12 +103,18 @@ static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t req); static herr_t H5VL_native_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req); +static herr_t H5VL_native_link_iterate(hid_t loc_id, const char *name, hbool_t recursive, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate_t op, void *op_data, hid_t lapl_id); static herr_t H5VL_native_link_get(hid_t loc_id, H5VL_link_get_t get_type, hid_t req, va_list arguments); static herr_t H5VL_native_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req); static hid_t H5VL_native_object_open(void *location, hid_t lapl_id, hid_t req); static herr_t H5VL_native_object_copy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t req); +static herr_t H5VL_native_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, + hid_t lapl_id); static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, void **location, hid_t req, va_list arguments); static herr_t H5VL_native_object_free_loc(void *location, hid_t req); static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, hid_t req, va_list arguments); @@ -116,10 +122,11 @@ static herr_t H5VL_native_object_misc(hid_t id, H5VL_object_misc_t misc_type, hi static herr_t H5VL_native_object_optional(hid_t id, H5VL_object_optional_t optional_type, hid_t req, va_list arguments); static herr_t H5VL_native_object_close(hid_t object_id, hid_t req); -H5VL_class_t H5VL_native_g = { +static H5VL_class_t H5VL_native_g = { "native", /* name */ 0, /* nrefs */ - H5VL_native_term, /*terminate */ + NULL, /* initialize */ + H5VL_native_term, /* terminate */ { /* attribute_cls */ H5VL_native_attr_create, /* create */ H5VL_native_attr_open, /* open */ @@ -161,12 +168,14 @@ H5VL_class_t H5VL_native_g = { { /* link_cls */ H5VL_native_link_create, /* create */ H5VL_native_link_move, /* move */ + H5VL_native_link_iterate, /* iterate */ H5VL_native_link_get, /* get */ H5VL_native_link_remove /* remove */ }, { /* object_cls */ H5VL_native_object_open, /* open */ H5VL_native_object_copy, /* copy */ + H5VL_native_object_visit, /* visit */ H5VL_native_object_lookup, /* lookup */ H5VL_native_object_free_loc, /* free location */ H5VL_native_object_get, /* get */ @@ -2326,6 +2335,61 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_native_link_iterate + * + * Purpose: Iterates through links in a group + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t H5VL_native_link_iterate(hid_t loc_id, const char *name, hbool_t recursive, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, + H5L_iterate_t op, void *op_data, hid_t lapl_id) +{ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if (!recursive) { + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_lnk; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + + /* Set up iteration beginning/end info */ + idx = (idx_p == NULL ? 0 : *idx_p); + last_lnk = 0; + + /* Build link operator info */ + lnk_op.op_type = H5G_LINK_OP_NEW; + lnk_op.op_func.op_new = op; + + /* Iterate over the links */ + if((ret_value = H5G_iterate(loc_id, name, idx_type, order, idx, &last_lnk, &lnk_op, + op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") + + /* Set the index we stopped at */ + if(idx_p) + *idx_p = last_lnk; + } + else { + /* Call internal group visitation routine */ + if((ret_value = H5G_visit(loc_id, name, idx_type, order, op, op_data, + lapl_id, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_iterate() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_native_link_get * * Purpose: Gets certain data about a link @@ -2539,6 +2603,40 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_object_copy() */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_visit + * + * Purpose: Iterates through all objects linked to an object + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t H5VL_native_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, + hid_t lapl_id) +{ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Call internal object visitation routine */ + if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, + lapl_id, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_visit() */ + + /*------------------------------------------------------------------------- * Function: H5VL_native_object_lookup diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 80eff2c..5784926 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -86,12 +86,17 @@ H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t req); H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req); +H5_DLL herr_t H5VL_link_iterate(hid_t loc_id, const char *name, hbool_t recursive, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate_t op, void *op_data, hid_t lapl_id); H5_DLL herr_t H5VL_link_get(hid_t loc_id, H5VL_link_get_t get_type, hid_t req, ...); H5_DLL herr_t H5VL_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req); H5_DLL hid_t H5VL_object_open_by_loc(hid_t loc_id, void *obj_loc, hid_t lapl_id, hid_t req); H5_DLL herr_t H5VL_object_copy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t req); +H5_DLL herr_t H5VL_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id); H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, hid_t req, ...); H5_DLL herr_t H5VL_object_misc(hid_t id, H5VL_object_misc_t misc_type, hid_t req, ...); H5_DLL herr_t H5VL_object_optional(hid_t id, H5VL_object_misc_t optional_type, hid_t req, ...); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 0aa5ca9..fbcb0b5 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -25,6 +25,7 @@ #include "H5public.h" #include "H5Fpublic.h" #include "H5Lpublic.h" +#include "H5Opublic.h" /* Dataset creation property names */ #define H5VL_DSET_TYPE_ID "dataset_type_id" @@ -213,6 +214,9 @@ typedef struct H5VL_link_class_t { hid_t lcpl_id, hid_t lapl_id, hid_t req); herr_t (*move) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dest_name, hbool_t copy_flag, hid_t lcpl, hid_t lapl, hid_t req); + herr_t (*iterate) (hid_t loc_id, const char *name, hbool_t recursive, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate_t op, void *op_data, hid_t lapl_id); herr_t (*get) (hid_t loc_id, H5VL_link_get_t get_type, hid_t req, va_list arguments); herr_t (*remove)(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req); } H5VL_link_class_t; @@ -222,6 +226,8 @@ typedef struct H5VL_object_class_t { hid_t (*open) (void *obj_loc, hid_t lapl_id, hid_t req); herr_t (*copy) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t req); + herr_t (*visit) (hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate_t op, void *op_data, hid_t lapl_id); herr_t (*lookup)(hid_t loc_id, H5VL_object_lookup_t lookup_type, void **location, hid_t req, va_list arguments); herr_t (*free_loc)(void *location, hid_t req); herr_t (*get) (hid_t loc_id, H5VL_object_get_t get_type, hid_t req, va_list arguments); @@ -234,6 +240,7 @@ typedef struct H5VL_object_class_t { typedef struct H5VL_class_t { const char *name; unsigned nrefs; /* Ref count for times struct is pointed to */ + herr_t (*initialize)(void); herr_t (*terminate)(void); H5VL_attr_class_t attr_cls; H5VL_datatype_class_t datatype_cls; -- cgit v0.12