diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2018-10-10 15:10:15 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2018-10-10 15:10:15 (GMT) |
commit | e962df1591bc6eaee5b9e318de83b9c6698bc7b6 (patch) | |
tree | de3cb2001c62b76a89837ff1e90044574d71f19d /src/H5Adeprec.c | |
parent | 471150151d29eeb806333a8db41fefc9dfb452bb (diff) | |
download | hdf5-e962df1591bc6eaee5b9e318de83b9c6698bc7b6.zip hdf5-e962df1591bc6eaee5b9e318de83b9c6698bc7b6.tar.gz hdf5-e962df1591bc6eaee5b9e318de83b9c6698bc7b6.tar.bz2 |
VOL FEATURE
Diffstat (limited to 'src/H5Adeprec.c')
-rw-r--r-- | src/H5Adeprec.c | 164 |
1 files changed, 86 insertions, 78 deletions
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index e88c8c3..47983ea 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -43,6 +43,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual object layer */ /****************/ @@ -113,10 +114,10 @@ hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -125,33 +126,48 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read") + /* Get correct property list */ + if(H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + + /* Set creation properties */ + if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Create the attribute */ - if(NULL == (attr = H5A__create(&loc, name, type, space, acpl_id))) + if(NULL == (attr = H5VL_attr_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, + acpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -183,8 +199,9 @@ done: hid_t H5Aopen_name(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -193,23 +210,30 @@ H5Aopen_name(hid_t loc_id, const char *name) /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the attribute */ - if(NULL == (attr = H5A__open_by_name(&loc, ".", name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "can't open attribute: '%s'", name) + if (NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, + name, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") + if ((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -241,8 +265,9 @@ done: hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -250,22 +275,34 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_CRT_ORDER; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = (hsize_t)idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5A__open_by_idx(&loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx))) + if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, + NULL, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -293,56 +330,27 @@ done: int H5Aget_num_attrs(hid_t loc_id) { - H5O_loc_t *loc; /* Object location for attribute */ - void *obj; + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; + H5O_info_t oinfo; int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", loc_id); - if(H5I_BADID == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "bad location ID") - if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "location is not valid for an attribute") - if(NULL == (obj = H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, (-1), "illegal object atom") - - switch(H5I_get_type (loc_id)) { - case H5I_DATASET: - if(NULL == (loc = H5D_oloc((H5D_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "can't get location for object") - break; - - case H5I_DATATYPE: - if(NULL == (loc = H5T_oloc((H5T_t*)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "target datatype is not committed") - break; - - case H5I_GROUP: - if(NULL == (loc = H5G_oloc((H5G_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "can't get location for object") - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "inappropriate attribute target") - } - - /* Look up the # of attributes for the object */ - if((ret_value = H5O__attr_count(loc)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, (-1), "can't get attribute count for object") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Get the number of attributes for the object */ + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, &oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") + + H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); done: FUNC_LEAVE_API(ret_value) |