diff options
Diffstat (limited to 'src/H5R.c')
-rw-r--r-- | src/H5R.c | 145 |
1 files changed, 87 insertions, 58 deletions
@@ -33,6 +33,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Rpkg.h" /* References */ #include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -49,12 +50,6 @@ /* Local Prototypes */ /********************/ -static herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name, - H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); -static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref); -static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, - H5R_type_t ref_type, const void *_ref, char *name, size_t size); - /*********************/ /* Package Variables */ @@ -228,7 +223,7 @@ H5R_term_package(void) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static herr_t +herr_t H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id) { H5G_loc_t obj_loc; /* Group hier. location of object */ @@ -372,8 +367,8 @@ done: herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { - H5G_loc_t loc; /* File location */ - H5S_t *space = NULL; /* Pointer to dataspace containing region */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -382,8 +377,6 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t /* Check args */ if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - 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 given") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) @@ -392,12 +385,19 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported") if(space_id == (-1) && ref_type == H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") - if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - /* Create reference */ - if((ret_value = H5R_create(ref, &loc, name, ref_type, space, H5AC_ind_read_dxpl_id)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to create reference") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* create the ref through the VOL */ + if((ret_value = H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_REF_CREATE, + H5AC_ind_read_dxpl_id, H5_REQUEST_NULL, + ref, name, ref_type, space_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: FUNC_LEAVE_API(ret_value) @@ -594,18 +594,18 @@ done: hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_ref) { - H5G_loc_t loc; /* Group location */ - H5F_t *file = NULL; /* File object */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ - hid_t ret_value; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, _ref); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(oapl_id < 0) + if(oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") @@ -616,12 +616,23 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r if(H5P_verify_apl_and_dxpl(&oapl_id, H5P_CLS_DACC, &dxpl_id, obj_id, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* get the vol object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + loc_params.type = H5VL_OBJECT_BY_REF; + loc_params.loc_data.loc_by_ref.ref_type = ref_type; + loc_params.loc_data.loc_by_ref._ref = _ref; + loc_params.loc_data.loc_by_ref.lapl_id = oapl_id; + loc_params.obj_type = H5I_get_type(obj_id); - /* Create reference */ - if((ret_value = H5R_dereference(file, oapl_id, dxpl_id, ref_type, _ref, TRUE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") + /* Open the object through the VOL */ + if(NULL == (opened_obj = H5VL_object_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + &opened_type, dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") + + if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) @@ -649,7 +660,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static H5S_t * +H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref) { H5O_loc_t oloc; /* Object location */ @@ -723,28 +734,30 @@ done: hid_t H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) { - H5G_loc_t loc; /* Object's group location */ - H5S_t *space = NULL; /* Dataspace object */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("i", "iRt*x", id, ref_type, ref); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type != H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the dataspace with the correct region selected */ - if((space = H5R_get_region(loc.oloc->file, H5AC_ind_read_dxpl_id, ref)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Atomize */ - if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + /* Get the space id through the VOL */ + if(H5VL_object_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_REF_GET_REGION, + H5AC_ind_read_dxpl_id, H5_REQUEST_NULL, &ret_value, ref_type, ref) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) @@ -864,23 +877,31 @@ herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the object information */ - if(H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object type") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* get the object type through the VOL */ + if((ret_value = H5VL_object_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + H5VL_REF_GET_TYPE, H5AC_ind_read_dxpl_id, + H5_REQUEST_NULL, obj_type, ref_type, ref)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) @@ -915,20 +936,25 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static ssize_t -H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, +ssize_t +H5R_get_name(H5G_loc_t *loc, hid_t lapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { + H5F_t *f; hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */ + H5O_loc_t oloc; /* Object location describing object for reference */ ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check args */ - HDassert(f); HDassert(_ref); + /* Get the file pointer from the entry */ + f = loc->oloc->file; + HDassert(f); + /* Initialize the object location */ H5O_loc_reset(&oloc); oloc.file = f; @@ -971,8 +997,8 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty } /* end switch */ /* Retrieve file ID for name search */ - if((file_id = H5I_get_file_id(id, FALSE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID") + if((file_id = H5F_get_id(f, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID") /* Get name, length, etc. */ if((ret_value = H5G_get_name_by_addr(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0) @@ -1024,28 +1050,31 @@ ssize_t H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { - H5G_loc_t loc; /* Group location */ - H5F_t *file; /* File object */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("Zs", "iRt*x*sz", id, ref_type, _ref, name, size); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); - /* Get name */ - if((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_ind_read_dxpl_id, id, ref_type, _ref, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object path") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* get the object type through the VOL */ + if(H5VL_object_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_REF_GET_NAME, + H5AC_ind_read_dxpl_id, H5_REQUEST_NULL, + &ret_value, name, size, ref_type, _ref) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_name() */ |