Skip to content

Commit

Permalink
Switch switch remainder of API routines to use VOL callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
qkoziol committed Nov 10, 2018
1 parent 140f72b commit ca1b902
Show file tree
Hide file tree
Showing 25 changed files with 462 additions and 561 deletions.
2 changes: 2 additions & 0 deletions bin/trace
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ $Source = "";
"unsigned" => "Iu",
"unsigned int" => "Iu",
"uint32_t" => "Iu",
"uint64_t" => "UL",
"H5I_type_t" => "It",
"H5G_link_t" => "Ll", #Same as H5L_type_t now
"H5L_type_t" => "Ll",
Expand Down Expand Up @@ -111,6 +112,7 @@ $Source = "";
"H5VL_link_specific_t" => "Vm",
"H5VL_object_get_t" => "Vn",
"H5VL_object_specific_t" => "Vo",
"H5VL_request_specific_t" => "Vr",
"void" => "x",
"FILE" => "x",
"H5A_operator_t" => "x",
Expand Down
25 changes: 15 additions & 10 deletions src/H5Adeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
hid_t acpl_id)
{
void *attr = NULL; /* attr token from VOL connector */
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
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 */
Expand Down Expand Up @@ -199,7 +199,7 @@ hid_t
H5Aopen_name(hid_t loc_id, const char *name)
{
void *attr = NULL; /* attr token from VOL connector */
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
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 */

Expand Down Expand Up @@ -264,7 +264,7 @@ hid_t
H5Aopen_idx(hid_t loc_id, unsigned idx)
{
void *attr = NULL; /* attr token from VOL connector */
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
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 */

Expand Down Expand Up @@ -327,7 +327,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx)
int
H5Aget_num_attrs(hid_t loc_id)
{
H5VL_object_t *vol_obj;
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
H5O_info_t oinfo;
int ret_value = -1;
Expand All @@ -338,7 +338,7 @@ H5Aget_num_attrs(hid_t loc_id)
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);

/* get the location object */
/* Get the location object */
if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier")

Expand Down Expand Up @@ -393,18 +393,23 @@ H5Aget_num_attrs(hid_t loc_id)
herr_t
H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data)
{
herr_t ret_value; /* Return value */
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
herr_t ret_value; /* Return value */

FUNC_ENTER_API(FAIL)
FUNC_ENTER_API(H5_ITER_ERROR)
H5TRACE4("e", "i*Iux*x", loc_id, attr_num, op, op_data);

/* check arguments */
if(H5I_ATTR == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "location is not valid for an attribute")

/* Get the location object */
if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier")

/* Call attribute iteration routine */
if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0)
HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes");
if((ret_value = H5VL_attr_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_ATTR_ITERATE_OLD, loc_id, attr_num, op, op_data)) < 0)
HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes");

done:
FUNC_LEAVE_API(ret_value)
Expand Down
7 changes: 3 additions & 4 deletions src/H5Aint.c
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,7 @@ H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5
if(obj_loc_id != H5I_INVALID_HID) {
if(H5I_dec_app_ref(obj_loc_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object");
}
} /* end if */
else if(loc_found && H5G_loc_free(&obj_loc) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location");

Expand Down Expand Up @@ -2688,7 +2688,7 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op,
hsize_t idx; /* Index of attribute to start iterating at */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_PACKAGE
FUNC_ENTER_PACKAGE_NOERR

/* Build attribute operator info */
attr_op.op_type = H5A_ATTR_OP_APP;
Expand All @@ -2699,13 +2699,12 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op,

/* Call internal attribute iteration routine */
if((ret_value = H5A__iterate_common(loc_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, &idx, &attr_op, op_data)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes")
HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes");

/* Translate hsize_t index value to legacy unsigned index value*/
if(attr_num)
*attr_num = (unsigned)idx;

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__iterate_old() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
Expand Down
7 changes: 7 additions & 0 deletions src/H5Apkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ typedef struct {
H5A_t **attrs; /* Pointer to array of attribute pointers */
} H5A_attr_table_t;

/* Types for optional attribute VOL operations */
typedef enum H5VL_attr_optional_t {
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5VL_ATTR_ITERATE_OLD /* H5Aiterate (deprecated routine) */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
} H5VL_attr_optional_t;


/*****************************/
/* Package Private Variables */
Expand Down
2 changes: 1 addition & 1 deletion src/H5Dint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@ H5D_nameof(const H5D_t *dataset)
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR

FUNC_LEAVE_NOAPI(dataset ? &(dataset->path) : (H5G_name_t *)NULL)
FUNC_LEAVE_NOAPI(dataset ? (H5G_name_t *)&(dataset->path) : (H5G_name_t *)NULL)
} /* end H5D_nameof() */


Expand Down
2 changes: 1 addition & 1 deletion src/H5Dpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ typedef struct H5D_type_info_t {
hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */
} H5D_type_info_t;

/* types for dataset optional VOL operations */
/* Types for dataset optional VOL operations */
typedef enum H5VL_dataset_optional_t {
H5VL_DATASET_FORMAT_CONVERT, /* H5Dformat_convert (internal) */
H5VL_DATASET_GET_CHUNK_INDEX_TYPE, /* H5Dget_chunk_index_type */
Expand Down
20 changes: 10 additions & 10 deletions src/H5G.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,13 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id,
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")

/* Get the gcpl structure and set the link properties on it */
if (NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id)))
if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
if (H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0)
if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set property value for lcpl id")

/* get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
/* Get the location object */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")

/* Set the location parameters */
Expand Down Expand Up @@ -439,7 +439,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);

/* get the location object */
/* Get the location object */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")

Expand Down Expand Up @@ -590,7 +590,7 @@ H5Gget_info(hid_t loc_id, H5G_info_t *group_info)
/* Retrieve the group's information */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = id_type;
if((ret_value = H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0)
if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info")

done:
Expand Down Expand Up @@ -632,7 +632,7 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info,
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info")

/* Get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")

/* Set up location parameters */
Expand All @@ -642,7 +642,7 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info,
loc_params.obj_type = H5I_get_type(loc_id);

/* Retrieve the group's information */
if((ret_value = H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0)
if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info")

done:
Expand Down Expand Up @@ -688,7 +688,7 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info")

/* get the location object */
/* Get the location object */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")

Expand All @@ -702,7 +702,7 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
loc_params.obj_type = H5I_get_type(loc_id);

/* Retrieve the group's information */
if((ret_value = H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0)
if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info")

done:
Expand Down
68 changes: 0 additions & 68 deletions src/H5Gcompact.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,71 +572,3 @@ H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo,
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G__compact_lookup_by_idx() */

#ifndef H5_NO_DEPRECATED_SYMBOLS

/*-------------------------------------------------------------------------
* Function: H5G__compact_get_type_by_idx
*
* Purpose: Returns the type of objects in the group by giving index.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Sep 12, 2005
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G__compact_get_type_by_idx(H5O_loc_t *oloc, const H5O_linfo_t *linfo,
hsize_t idx)
{
H5G_link_table_t ltable = {0, NULL}; /* Link table */
H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */

FUNC_ENTER_PACKAGE

/* Sanity check */
HDassert(oloc);

/* Build table of all link messages */
if(H5G__compact_build_table(oloc, linfo, H5_INDEX_NAME, H5_ITER_INC, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "can't create link message table")

/* Check for going out of bounds */
if(idx >= ltable.nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5G_UNKNOWN, "index out of bound")

/* Determine type of object */
if(ltable.lnks[idx].type == H5L_TYPE_SOFT)
ret_value = H5G_LINK;
else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN)
ret_value = H5G_UDLINK;
else if(ltable.lnks[idx].type == H5L_TYPE_HARD){
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */

/* Build temporary object location */
tmp_oloc.file = oloc->file;
tmp_oloc.addr = ltable.lnks[idx].u.hard.addr;

/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type")

/* Map to group object type */
if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type)))
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type")
} else {
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type")
} /* end else */

done:
/* Release link table */
if(ltable.lnks && H5G__link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table")

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G__compact_get_type_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

77 changes: 0 additions & 77 deletions src/H5Gdense.c
Original file line number Diff line number Diff line change
Expand Up @@ -1777,80 +1777,3 @@ H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G__dense_delete() */

#ifndef H5_NO_DEPRECATED_SYMBOLS

/*-------------------------------------------------------------------------
* Function: H5G__dense_get_type_by_idx
*
* Purpose: Returns the type of objects in the group by giving index.
*
* Note: This routine assumes a lookup on the link name index in
* increasing order and isn't currently set up to be as
* flexible as other routines in this code module, because
* the H5Gget_objtype_by_idx that it's supporting is
* deprecated.
*
* Return: Success: Non-negative, object type
* Failure: Negative
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
* Sep 19 2006
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G__dense_get_type_by_idx(H5F_t *f, H5O_linfo_t *linfo, hsize_t idx)
{
H5G_link_table_t ltable = {0, NULL}; /* Table of links */
H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */

FUNC_ENTER_PACKAGE

/*
* Check arguments.
*/
HDassert(f);
HDassert(linfo);

/* Build the table of links for this group */
if(H5G__dense_build_table(f, linfo, H5_INDEX_NAME, H5_ITER_INC, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "error building table of links")

/* Check for going out of bounds */
if(idx >= ltable.nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "index out of bound")

/* Determine type of object */
if(ltable.lnks[idx].type == H5L_TYPE_SOFT)
ret_value = H5G_LINK;
else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN)
ret_value = H5G_UDLINK;
else if(ltable.lnks[idx].type == H5L_TYPE_HARD) {
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */

/* Build temporary object location */
tmp_oloc.file = f;
tmp_oloc.addr = ltable.lnks[idx].u.hard.addr;

/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type")

/* Map to group object type */
if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type)))
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type")
} else {
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type")
} /* end else */

done:
/* Release link table */
if(ltable.lnks && H5G__link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table")

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G__dense_get_type_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

Loading

0 comments on commit ca1b902

Please sign in to comment.