diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2014-05-29 22:04:19 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2014-05-29 22:04:19 (GMT) |
commit | 81cd798e0fcf16bf98b300d0ce8ec808828fab38 (patch) | |
tree | 1215f32dc6e3302c3d61f3bb686adc9f1f7b327c | |
parent | 5ba1cfe00a49a7a7d748ccf5f3ad0227d9105804 (diff) | |
download | hdf5-81cd798e0fcf16bf98b300d0ce8ec808828fab38.zip hdf5-81cd798e0fcf16bf98b300d0ce8ec808828fab38.tar.gz hdf5-81cd798e0fcf16bf98b300d0ce8ec808828fab38.tar.bz2 |
[svn-r25226] - implement and use H5Dquery_ff() when creating views (not tested with indexing enabled yet).
- cleanup old indexing code in view create at the client as it's not needed anymore.
-rw-r--r-- | examples/h5ff_client_obj.c | 3 | ||||
-rw-r--r-- | src/H5FF.c | 130 | ||||
-rw-r--r-- | src/H5V.c | 39 | ||||
-rw-r--r-- | src/H5VLiod.c | 77 | ||||
-rw-r--r-- | src/H5VLiod.h | 1 | ||||
-rw-r--r-- | src/H5VLiod_analysis.c | 36 | ||||
-rw-r--r-- | src/H5VLiod_client.c | 1 | ||||
-rw-r--r-- | src/H5VLiod_client.h | 4 | ||||
-rw-r--r-- | src/H5VLiod_dset.c | 2 | ||||
-rw-r--r-- | src/H5VLiod_view.c | 106 |
10 files changed, 258 insertions, 141 deletions
diff --git a/examples/h5ff_client_obj.c b/examples/h5ff_client_obj.c index 7dcdbbe..c5e75d3 100644 --- a/examples/h5ff_client_obj.c +++ b/examples/h5ff_client_obj.c @@ -250,8 +250,7 @@ int main(int argc, char **argv) { /* check if an object exists. This is asynchronous, so checking
the value should be done after the wait */
- ret = H5Oexists_by_name_ff(file_id, "G1", &exists,
- H5P_DEFAULT, rid2, e_stack);
+ ret = H5Oexists_by_name_ff(file_id, "G1", &exists, H5P_DEFAULT, rid2, e_stack);
assert(ret == 0);
if(my_rank == 0) {
@@ -4799,10 +4799,7 @@ H5VLiod_get_file_id(const char *filename, iod_handle_t coh, hid_t fapl_id, hid_t iod_handles_t root_oh; /* root object handle */ iod_cont_trans_stat_t *tids = NULL; iod_trans_id_t rtid; - uint64_t kv_oid_index, array_oid_index, blob_oid_index; iod_handle_t mdkv_oh; - iod_checksum_t *iod_cs = NULL; - iod_size_t key_size = 0, val_size = 0; hid_t fcpl_id; uint32_t cs_scope; iod_ret_t ret; @@ -4855,7 +4852,7 @@ H5VLiod_get_file_id(const char *filename, iod_handle_t coh, hid_t fapl_id, hid_t ret = iod_trans_start(coh, &rtid, NULL, 0, IOD_TRANS_R, NULL); if(ret < 0) - HGOTO_ERROR_FF(ret, "can't start transaction"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't start transaction"); /* open the root group */ IOD_OBJID_SETOWNER_APP(root_id) @@ -5000,4 +4997,129 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5VLiod_close_file_id() */ + +/*------------------------------------------------------------------------- + * Function: H5Dquery + * + * Purpose: returns a dataspace selection of dataset elements that + * matches the query + * + * Return: Success: The ID for a dataspace selection. + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * May 29, 2014 + * + *------------------------------------------------------------------------- + */ +hid_t +H5Dquery_ff(hid_t dset_id, hid_t query_id, hid_t scope_id, hid_t rcxt_id) +{ + void *dset = NULL; + H5P_genplist_t *xxpl_plist = NULL, *plist = NULL; /* Property list pointer */ + hid_t xxpl_id = FAIL; + unsigned plugin_id; + void *buf = NULL; + hid_t type_id=FAIL, space_id=scope_id, dset_space_id=FAIL; + hbool_t use_region_scope = TRUE; + hid_t ret_value = FAIL; + + FUNC_ENTER_API(FAIL) + + if(NULL == (dset = (void *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + +#ifdef H5_HAVE_INDEXING + /* Use indexing query callback if it exists */ + if (!(plugin_id = H5VL_iod_dataset_get_index_plugin_id(dset))) { + void *idx_handle = NULL; /* index */ + H5X_class_t *idx_class = NULL; + + if (NULL == (idx_class = H5X_registered(plugin_id))) + HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "can't get index plugin class"); + + if(NULL == (plist = H5I_object(H5P_INDEX_XFER_DEFAULT))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); + if((xxpl_id = H5P_copy_plist((H5P_genplist_t *)plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property list"); + + /* store the read context ID in the xxpl */ + if (NULL == (xxpl_plist = (H5P_genplist_t *) H5I_object(xxpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + if (H5P_set(xxpl_plist, H5VL_CONTEXT_ID, &rcxt_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id"); + + if (NULL == idx_class->query) + HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin query callback is not defined"); + if (FAIL == idx_class->query(idx_handle, query_id, xxpl_id, &ret_value)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTCLOSEOBJ, FAIL, "cannot query index"); + } + else +#endif + { + /* Brute force it */ + size_t elmt_size=0, buf_size=0; + size_t nelmts; + H5VL__iod_get_query_data_t udata; + + if((dset_space_id = H5Dget_space(dset_id)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get space id from dataset"); + if((type_id = H5Dget_type(dset_id)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get space id from dataset"); + + if(space_id < 0) { + use_region_scope = FALSE; + space_id = dset_space_id; + } + + nelmts = (size_t) H5Sget_select_npoints(space_id); + elmt_size = H5Tget_size(type_id); + buf_size = nelmts * elmt_size; + + /* allocate buffer to hold data */ + if(NULL == (buf = malloc(buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate data buffer"); + + FUNC_LEAVE_API_THREADSAFE; + ret_value = H5Dread_ff(dset_id, type_id, H5S_ALL, space_id, H5P_DEFAULT, + buf, rcxt_id, H5_EVENT_STACK_NULL); + FUNC_ENTER_API_THREADSAFE; + + if(SUCCEED != ret_value) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't read data from dataset"); + + if(FAIL == (udata.space_query = H5Scopy(space_id))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace") + if(H5Sselect_none(udata.space_query) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + + udata.query_id = query_id; + udata.num_elmts = 0; + + /* iterate over every element and apply the query on it. If the + query is not satisfied, then remove it from the query selection */ + if(H5Diterate(buf, type_id, space_id, H5VL__iod_get_query_data_cb, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "failed to apply query on Dataset") + + ret_value = udata.space_query; + } + +done: + if(xxpl_id != FAIL && H5I_dec_app_ref(xxpl_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close plist"); + if(space_id != FAIL && H5I_dec_app_ref(space_id) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace"); + if(use_region_scope) + if(dset_space_id != FAIL && H5I_dec_app_ref(dset_space_id) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace"); + if(type_id != FAIL && H5I_dec_app_ref(type_id) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't close dataspace"); + + if(buf) { + free(buf); + buf = NULL; + } + + FUNC_LEAVE_API(ret_value) +} #endif /* H5_HAVE_EFF */ @@ -308,10 +308,6 @@ H5Vcreate_ff(hid_t loc_id, hid_t query_id, hid_t vcpl_id, hid_t rcxt_id, hid_t e void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */ void *view = NULL; /* pointer to view object created */ void *obj = NULL; /* object token of loc_id */ -#ifdef H5_HAVE_INDEXING - void *idx_handle = NULL; /* index */ -#endif - hid_t dataspace_id = -1; H5VL_t *vol_plugin; /* VOL plugin information */ hid_t ret_value; @@ -346,36 +342,8 @@ H5Vcreate_ff(hid_t loc_id, hid_t query_id, hid_t vcpl_id, hid_t rcxt_id, hid_t e vol_plugin->nrefs ++; } -#ifdef H5_HAVE_INDEXING - /* Try to get indexing info (only for one dataset now) */ - if (H5I_object_verify(loc_id, H5I_DATASET) && - (NULL != (idx_handle = H5VL_iod_dataset_get_index(obj)))) { - H5X_class_t *idx_class = NULL; - H5P_genplist_t *xxpl_plist; /* Property list pointer */ - hid_t xxpl_id = H5P_INDEX_XFER_DEFAULT; - unsigned plugin_id; - - if (!(plugin_id = H5VL_iod_dataset_get_index_plugin_id(obj))) - HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "can't get index plugin ID from dataset"); - if (NULL == (idx_class = H5X_registered(plugin_id))) - HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "can't get index plugin class"); - - /* store the read context ID in the xxpl */ - if (NULL == (xxpl_plist = (H5P_genplist_t *) H5I_object(xxpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - if (H5P_set(xxpl_plist, H5VL_CONTEXT_ID, &rcxt_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id"); - - if (NULL == idx_class->query) - HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin query callback is not defined"); - if (FAIL == idx_class->query(idx_handle, query_id, xxpl_id, &dataspace_id)) - HGOTO_ERROR(H5E_INDEX, H5E_CANTCLOSEOBJ, FAIL, "cannot close index"); - } -#endif - /* call the IOD specific private routine to create a view object */ - if(NULL == (view = H5VL_iod_view_create(obj, query_id, dataspace_id, - vcpl_id, rcxt_id, req))) + if(NULL == (view = H5VL_iod_view_create(obj, query_id, vcpl_id, rcxt_id, req))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create view") if(request && *req) { @@ -388,11 +356,6 @@ H5Vcreate_ff(hid_t loc_id, hid_t query_id, hid_t vcpl_id, hid_t rcxt_id, hid_t e HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize view handle") done: - if(dataspace_id != -1) { - if(H5I_dec_ref(dataspace_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - } - if (ret_value < 0 && view) { if(H5V_close (view) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release view") diff --git a/src/H5VLiod.c b/src/H5VLiod.c index c7bfc9c..344cf5c 100644 --- a/src/H5VLiod.c +++ b/src/H5VLiod.c @@ -6369,7 +6369,7 @@ H5VL_iod_obj_open_token(const void *token, H5TR_t *tr, H5I_type_t *opened_type, dset->common.obj_name = NULL; #if H5_EFF_DEBUG - printf("Dataset open by token %"PRIu64": ID %"PRIu64"\n", + printf("Dataset open by token %"PRIu64": ID %"PRIx64"\n", g_axe_id, input.iod_id); #endif @@ -10227,11 +10227,11 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_iod_view_create(void *_obj, hid_t query_id, hid_t dataspace_id, - hid_t vcpl_id, hid_t rcxt_id, void **req) +H5VL_iod_view_create(void *_obj, hid_t query_id, hid_t vcpl_id, hid_t rcxt_id, void **req) { H5VL_iod_object_t *obj = (H5VL_iod_object_t *)_obj; /* location object to create the view */ H5VL_iod_view_t *view = NULL; /* the view object that is created and passed to the user */ + view_create_in_t input; iod_obj_id_t iod_id, mdkv_id, attrkv_id; iod_handles_t iod_oh; H5VL_iod_request_t **parent_reqs = NULL; @@ -10305,52 +10305,33 @@ H5VL_iod_view_create(void *_obj, hid_t query_id, hid_t dataspace_id, iod_id, g_axe_id); #endif - /* If we already have a dataspace id, no need to ship */ - if (dataspace_id != -1) { - view->remote_view.attr_info.count = 0; - view->remote_view.attr_info.tokens = NULL; - view->remote_view.obj_info.count = 0; - view->remote_view.obj_info.tokens = NULL; - view->remote_view.region_info.count = 0; -// view->remote_view.region_info.regions = H5MM_malloc(sizeof(hid_t)); -// view->remote_view.region_info.regions[0] = H5Scopy(dataspace_id); -// H5Sclose(dataspace_id); - /* TODO fix that */ - view->remote_view.region_info.tokens = NULL; - view->remote_view.region_info.regions = NULL; - - view->remote_view.valid_view = TRUE; - } else { - view_create_in_t input; - - /* Initialize the view types to be obtained from server */ - view->remote_view.attr_info.count = 0; - view->remote_view.attr_info.tokens = NULL; - view->remote_view.obj_info.count = 0; - view->remote_view.obj_info.tokens = NULL; - view->remote_view.region_info.count = 0; - view->remote_view.region_info.tokens = NULL; - view->remote_view.region_info.regions = NULL; - view->remote_view.valid_view = FALSE; + /* Initialize the view types to be obtained from server */ + view->remote_view.attr_info.count = 0; + view->remote_view.attr_info.tokens = NULL; + view->remote_view.obj_info.count = 0; + view->remote_view.obj_info.tokens = NULL; + view->remote_view.region_info.count = 0; + view->remote_view.region_info.tokens = NULL; + view->remote_view.region_info.regions = NULL; + view->remote_view.valid_view = FALSE; - /* set the input structure for the HG encode routine */ - input.coh = obj->file->remote_file.coh; - input.loc_id = iod_id; - input.loc_oh = iod_oh; - input.loc_mdkv_id = mdkv_id; - input.loc_attrkv_id = attrkv_id; - input.query_id = query_id; - input.vcpl_id = vcpl_id; - input.obj_type = obj->obj_type; - input.rcxt_num = rc->c_version; - input.cs_scope = obj->file->md_integrity_scope; - - if(H5VL__iod_create_and_forward(H5VL_VIEW_CREATE_ID, HG_VIEW_CREATE, - (H5VL_iod_object_t *)view, 1, num_parents, parent_reqs, - (H5VL_iod_req_info_t *)rc, &input, &view->remote_view, - view, req) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship view create"); - } + /* set the input structure for the HG encode routine */ + input.coh = obj->file->remote_file.coh; + input.loc_id = iod_id; + input.loc_oh = iod_oh; + input.loc_mdkv_id = mdkv_id; + input.loc_attrkv_id = attrkv_id; + input.query_id = query_id; + input.vcpl_id = vcpl_id; + input.obj_type = obj->obj_type; + input.rcxt_num = rc->c_version; + input.cs_scope = obj->file->md_integrity_scope; + + if(H5VL__iod_create_and_forward(H5VL_VIEW_CREATE_ID, HG_VIEW_CREATE, + (H5VL_iod_object_t *)view, 1, num_parents, parent_reqs, + (H5VL_iod_req_info_t *)rc, &input, &view->remote_view, + view, req) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship view create"); ret_value = (void *)view; diff --git a/src/H5VLiod.h b/src/H5VLiod.h index 04651b8..6f08062 100644 --- a/src/H5VLiod.h +++ b/src/H5VLiod.h @@ -100,6 +100,7 @@ H5_DLL herr_t H5Pget_dcpl_append_only(hid_t dcpl_id, hbool_t *flag); H5_DLL hid_t H5VLiod_get_file_id(const char *filename, iod_handle_t coh, hid_t fapl_id, hid_t *rcxt_id); H5_DLL herr_t H5VLiod_close_file_id(hid_t file_id); +H5_DLL hid_t H5Dquery_ff(hid_t dset_id, hid_t query_id, hid_t scope_id, hid_t rcxt_id); #endif /* H5_HAVE_EFF */ diff --git a/src/H5VLiod_analysis.c b/src/H5VLiod_analysis.c index 2b01eeb..80d952e 100644 --- a/src/H5VLiod_analysis.c +++ b/src/H5VLiod_analysis.c @@ -1194,42 +1194,6 @@ done: } /* end H5VL__iod_get_space_layout() */ /*------------------------------------------------------------------------- - * Function: H5VL__iod_get_query_data_cb - * - * - * Return: Success: SUCCEED - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL__iod_get_query_data_cb(void *elem, hid_t type_id, unsigned ndim, - const hsize_t *point, void *_udata) -{ - H5VL__iod_get_query_data_t *udata = (H5VL__iod_get_query_data_t *)_udata; - hbool_t result; - herr_t ret_value = SUCCEED; - - /* Apply the query */ - if(H5Qapply(udata->query_id, &result, type_id, elem) < 0) - HGOTO_ERROR_FF(FAIL, "unable to apply query to data element"); - - /* If element satisfies query, add it to the selection */ - if (result) { - /* TODO remove that after demo */ -#if 0 - fprintf(stderr, "(%d) Element |%d| matches query\n", my_rank_g, *((int *) elem)); -#endif - udata->num_elmts ++; - if(H5Sselect_elements(udata->space_query, H5S_SELECT_APPEND, 1, point) < 0) - HGOTO_ERROR_FF(FAIL, "unable to add point to selection") - } - -done: - return ret_value; -} /* end H5VL__iod_get_query_data_cb */ - -/*------------------------------------------------------------------------- * Function: H5VL__iod_get_query_data * * Purpose: Generates a dataspace from the query specified. The dataspace diff --git a/src/H5VLiod_client.c b/src/H5VLiod_client.c index b76ecf8..8108f3d 100644 --- a/src/H5VLiod_client.c +++ b/src/H5VLiod_client.c @@ -221,6 +221,7 @@ H5VL_iod_request_wait(H5VL_iod_file_t *file, H5VL_iod_request_t *request) container to avoid deadlock. */ while(1) { HDassert(request->state == H5VL_IOD_PENDING); + /* test the operation status */ FUNC_LEAVE_API_THREADSAFE; ret = HG_Wait(*((hg_request_t *)request->req), 0, &status); diff --git a/src/H5VLiod_client.h b/src/H5VLiod_client.h index 23de9b2..e04871c 100644 --- a/src/H5VLiod_client.h +++ b/src/H5VLiod_client.h @@ -490,8 +490,8 @@ H5_DLL herr_t H5VL_iod_prefetch(void *obj, hid_t rcxt_id, hrpl_t *replica_id, hid_t apl_id, void **req); H5_DLL herr_t H5VL_iod_evict(void *obj, uint64_t c_version, hid_t apl_id, void **req); -H5_DLL void * H5VL_iod_view_create(void *_obj, hid_t query_id, hid_t dataspace_id, - hid_t vcpl_id, hid_t rcxt_id, void **req); +H5_DLL void * H5VL_iod_view_create(void *_obj, hid_t query_id, hid_t vcpl_id, + hid_t rcxt_id, void **req); H5_DLL herr_t H5VL_iod_view_close(H5VL_iod_view_t *view); H5_DLL herr_t H5VL_iod_analysis_execute(const char *file_name, const char *obj_name, diff --git a/src/H5VLiod_dset.c b/src/H5VLiod_dset.c index 517961a..7a59ca7 100644 --- a/src/H5VLiod_dset.c +++ b/src/H5VLiod_dset.c @@ -653,7 +653,7 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t axe_engine, HG_BULK_READWRITE, &bulk_block_handle)) HGOTO_ERROR_FF(FAIL, "can't create bulk handle"); } - + /* if(H5VL__iod_server_adjust_buffer(dst_id, src_id, nelmts, dxpl_id, is_coresident, size, &buf, &is_vl_data, &buf_size) < 0) diff --git a/src/H5VLiod_view.c b/src/H5VLiod_view.c index 0ee7909..951c823 100644 --- a/src/H5VLiod_view.c +++ b/src/H5VLiod_view.c @@ -24,6 +24,8 @@ #include "H5VLiod_server.h" #include "H5Qpublic.h" +#include "H5RCpublic.h" +#include "H5TRpublic.h" #include "H5Vpublic.h" #ifdef H5_HAVE_EFF @@ -55,6 +57,8 @@ typedef struct { typedef struct { hid_t query_id; hid_t vcpl_id; + hid_t file_id; + hid_t rcxt_id; H5VL_iod_view_obj_t *view; } H5VL_build_view_t; @@ -69,7 +73,8 @@ static herr_t H5VL__iod_get_token(iod_handle_t coh, H5I_type_t obj_type, iod_obj_id_t iod_id, iod_trans_id_t rtid, uint32_t cs_scope, size_t *_token_size, void **_token); static herr_t -H5VL__iod_apply_query(hid_t qid, hid_t vcpl_id, iod_handle_t coh, iod_obj_id_t obj_id, +H5VL__iod_apply_query(hid_t file_id, hid_t rcxt_id, hid_t qid, hid_t vcpl_id, + iod_handle_t coh, iod_obj_id_t obj_id, iod_trans_id_t rtid, H5I_type_t obj_type, const char *link_name, const char *attr_name, size_t num_attrs, char *attr_list[], @@ -122,12 +127,20 @@ H5VL_iod_server_view_create_cb(AXE_engine_t UNUSED axe_engine, H5VL_build_view_t udata; H5VL_iod_view_entry_t *entry = NULL; H5VL_iod_view_obj_t *view = NULL; + hid_t file_id, rcxt_id, fapl_id; herr_t ret_value = SUCCEED; #if H5_EFF_DEBUG fprintf(stderr, "Start View create on OID %"PRIx64"\n", loc_id); #endif + /* wrap a file hid_t around the iod container handle */ + fapl_id = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_fapl_iod(fapl_id, MPI_COMM_SELF, MPI_INFO_NULL); + if((file_id = H5VLiod_get_file_id("bla", coh, fapl_id, &rcxt_id)) < 0) + HGOTO_ERROR_FF(FAIL, "can't get file ID"); + H5Pclose(fapl_id); + if(H5P_DEFAULT == input->vcpl_id) input->vcpl_id = H5Pcopy(H5P_VIEW_CREATE_DEFAULT); vcpl_id = input->vcpl_id; @@ -137,6 +150,8 @@ H5VL_iod_server_view_create_cb(AXE_engine_t UNUSED axe_engine, udata.view = view; udata.query_id = query_id; udata.vcpl_id = vcpl_id; + udata.file_id = file_id; + udata.rcxt_id = rcxt_id; if(H5VL_iod_server_iterate(coh, loc_id, rtid, obj_type, NULL, NULL, cs_scope, H5VL__iod_build_view_cb, &udata) < 0) @@ -199,6 +214,13 @@ H5VL_iod_server_view_create_cb(AXE_engine_t UNUSED axe_engine, } } + /* free the file ID and release the read context */ + if(H5RCrelease(rcxt_id, H5_EVENT_STACK_NULL) < 0) + HGOTO_ERROR_FF(FAIL, "can't release read context"); + H5RCclose(rcxt_id); + if(H5VLiod_close_file_id(file_id) < 0) + HGOTO_ERROR_FF(FAIL, "can't release file id"); + done: #if H5_EFF_DEBUG @@ -352,7 +374,8 @@ H5VL__iod_build_view_cb(iod_handle_t coh, iod_obj_id_t obj_id, iod_trans_id_t rt HGOTO_ERROR_FF(ret, "can't close object"); } - ret = H5VL__iod_apply_query(op_data->query_id, op_data->vcpl_id, + ret = H5VL__iod_apply_query(op_data->file_id, op_data->rcxt_id, + op_data->query_id, op_data->vcpl_id, coh, obj_id, rtid, obj_type, link_name, attr_name, (size_t)num_attrs, attr_list, cs_scope, &result, ®ion); @@ -394,7 +417,8 @@ done: } static herr_t -H5VL__iod_apply_query(hid_t qid, hid_t vcpl_id, iod_handle_t coh, iod_obj_id_t obj_id, +H5VL__iod_apply_query(hid_t file_id, hid_t rcxt_id, hid_t qid, hid_t vcpl_id, + iod_handle_t coh, iod_obj_id_t obj_id, iod_trans_id_t rtid, H5I_type_t obj_type, const char *link_name, const char *attr_name, size_t num_attrs, char *attr_list[], @@ -417,11 +441,39 @@ H5VL__iod_apply_query(hid_t qid, hid_t vcpl_id, iod_handle_t coh, iod_obj_id_t o if(H5Q_TYPE_DATA_ELEM == q_type) { if(H5I_DATASET == obj_type) { - hid_t sid; + hid_t sid, scope_id; + hid_t dset_id, trans_id; + size_t token_size = 0; + void *token = NULL; + + if(H5VL__iod_get_token(coh, obj_type, obj_id, rtid, cs_scope, + &token_size, &token) < 0) + HGOTO_ERROR_FF(FAIL, "failed to get object token"); + + trans_id = H5TRcreate(file_id, rcxt_id, rtid); + if((dset_id = H5Oopen_by_token(token, trans_id, H5_EVENT_STACK_NULL)) < 0) + HGOTO_ERROR_FF(FAIL, "failed to open dataset by token"); + H5TRclose(trans_id); + + /* Check if VCPL has a dataspace specified; otherwise, read the entire dataset. */ + if(H5Pget_view_elmt_scope(vcpl_id, &scope_id) < 0) + HGOTO_ERROR_FF(FAIL, "can't retrieve vcpl region scope"); + + sid = H5Dquery_ff(dset_id, qid, scope_id, rcxt_id); + if(FAIL == sid) + HGOTO_ERROR_FF(FAIL, "failed to apply query on dataset region"); + + if(H5Dclose_ff(dset_id, H5_EVENT_STACK_NULL) < 0) + HGOTO_ERROR_FF(FAIL, "failed to close dataset"); + + if(token) { + free(token); + token = NULL; + } /* add object to view with region if region is not NONE */ - if((sid = H5VL__iod_get_elmt_region(coh, obj_id, rtid, qid, vcpl_id, cs_scope)) < 0) - HGOTO_ERROR_FF(FAIL, "can't get region from query"); + //if((sid = H5VL__iod_get_elmt_region(coh, obj_id, rtid, qid, vcpl_id, cs_scope)) < 0) + //HGOTO_ERROR_FF(FAIL, "can't get region from query"); fprintf(stderr, "Found %zu Entries in subquery\n", H5Sget_select_npoints(sid)); if(H5Sget_select_npoints(sid) > 0) { @@ -493,7 +545,7 @@ H5VL__iod_apply_query(hid_t qid, hid_t vcpl_id, iod_handle_t coh, iod_obj_id_t o if(H5Qget_components(qid, &qid1, &qid2) < 0) HGOTO_ERROR_FF(FAIL, "can't get query components"); - ret = H5VL__iod_apply_query(qid1, vcpl_id, coh, obj_id, rtid, + ret = H5VL__iod_apply_query(file_id, rcxt_id, qid1, vcpl_id, coh, obj_id, rtid, obj_type, link_name, attr_name, num_attrs, attr_list, cs_scope, &result1, &sid1); @@ -506,7 +558,7 @@ H5VL__iod_apply_query(hid_t qid, hid_t vcpl_id, iod_handle_t coh, iod_obj_id_t o *result = QFALSE; } else { - ret = H5VL__iod_apply_query(qid2, vcpl_id, coh, obj_id, rtid, + ret = H5VL__iod_apply_query(file_id, rcxt_id, qid2, vcpl_id, coh, obj_id, rtid, obj_type, link_name, attr_name, num_attrs, attr_list, cs_scope, &result2, &sid2); @@ -875,7 +927,7 @@ H5VL__iod_get_elmt_region(iod_handle_t coh, iod_obj_id_t dset_id, iod_trans_id_t /* Check if VCPL has a dataspace specified; otherwise, read the entire dataset. */ if(H5Pget_view_elmt_scope(vcpl_id, &space_id) < 0) - HGOTO_ERROR_FF(FAIL, "can't retrieve vcpl region scope");; + HGOTO_ERROR_FF(FAIL, "can't retrieve vcpl region scope"); /* open the array object */ if(iod_obj_open_read(coh, dset_id, rtid, NULL, &dset_oh, NULL) < 0) @@ -922,7 +974,6 @@ H5VL__iod_get_elmt_region(iod_handle_t coh, iod_obj_id_t dset_id, iod_trans_id_t HGOTO_ERROR_FF(FAIL, "can't allocate read buffer"); /* read the data selection from IOD. */ - elmt_size = H5Tget_size(type_id); if(H5VL__iod_server_final_io(dset_oh, space_id, elmt_size, FALSE, buf, buf_size, (uint64_t)0, 0, rtid) < 0) HGOTO_ERROR_FF(FAIL, "can't read from array object"); @@ -961,6 +1012,41 @@ done: return ret_value; } /* end H5VL__iod_get_elmt_region() */ +/*------------------------------------------------------------------------- + * Function: H5VL__iod_get_query_data_cb + * + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__iod_get_query_data_cb(void *elem, hid_t type_id, unsigned ndim, + const hsize_t *point, void *_udata) +{ + H5VL__iod_get_query_data_t *udata = (H5VL__iod_get_query_data_t *)_udata; + hbool_t result; + herr_t ret_value = SUCCEED; + + /* Apply the query */ + if(H5Qapply(udata->query_id, &result, type_id, elem) < 0) + HGOTO_ERROR_FF(FAIL, "unable to apply query to data element"); + + /* If element satisfies query, add it to the selection */ + if (result) { +#if 0 + fprintf(stderr, "(%d) Element |%d| matches query\n", my_rank_g, *((int *) elem)); +#endif + udata->num_elmts ++; + if(H5Sselect_elements(udata->space_query, H5S_SELECT_APPEND, 1, point) < 0) + HGOTO_ERROR_FF(FAIL, "unable to add point to selection") + } + +done: + return ret_value; +} /* end H5VL__iod_get_query_data_cb */ + static void H5VL__iod_add_entry(H5VL_iod_view_list_t *list, H5VL_iod_view_entry_t* entry) { |