diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2014-03-17 17:37:27 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2014-03-17 17:37:27 (GMT) |
commit | ad72021fd1b22c0e83053a30b3fcd66c40e29a84 (patch) | |
tree | 6a9cf3543c63b0a6a380737a845d296c9ab13adc /testff/h5ff_client_index.c | |
parent | bcf7c98ef92b4b318d0afcf21ad3b95b522e18f8 (diff) | |
download | hdf5-ad72021fd1b22c0e83053a30b3fcd66c40e29a84.zip hdf5-ad72021fd1b22c0e83053a30b3fcd66c40e29a84.tar.gz hdf5-ad72021fd1b22c0e83053a30b3fcd66c40e29a84.tar.bz2 |
[svn-r24813] Add H5Xpublic/H5Vpublic to hdf5.h
Add index test in testff
Add indexing query callback to H5Vcreate
Cleanup
Diffstat (limited to 'testff/h5ff_client_index.c')
-rw-r--r-- | testff/h5ff_client_index.c | 206 |
1 files changed, 96 insertions, 110 deletions
diff --git a/testff/h5ff_client_index.c b/testff/h5ff_client_index.c index cd59728..d5c7264 100644 --- a/testff/h5ff_client_index.c +++ b/testff/h5ff_client_index.c @@ -14,14 +14,13 @@ static int my_rank = 0, my_size = 1; static void -write_dataset(const char *file_name, const char *dataset_name, +write_dataset(hid_t file_id, const char *dataset_name, hsize_t total, hsize_t ncomponents, hid_t datatype_id, hsize_t ntuples, hsize_t start, void *buf) { - hid_t file_id, dataset_id, view_id; + hid_t dataset_id; hid_t file_space_id, mem_space_id; - hid_t tid1, rid1, rid2, trspl_id; - hid_t fapl_id; + hid_t tid0, rid0, trspl_id; hsize_t dims[2] = {total, ncomponents}; hsize_t offset[2] = {start, 0}; hsize_t count[2] = {ntuples, ncomponents}; @@ -30,36 +29,21 @@ write_dataset(const char *file_name, const char *dataset_name, herr_t ret; void *dset_token1; size_t token_size1; - double lower_bound1 = 39.1, upper_bound1 = 42.1; - int lower_bound2 = 295, upper_bound2 = 298; - hid_t query_id1, query_id2, query_id3, query_id4, query_id5, query_id6; - hid_t query_id; MPI_Request mpi_reqs[2]; - /* Choose the IOD VOL plugin to use with this file. */ - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_iod(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL); - - /* Open an existing file. */ - file_id = H5Fcreate_ff(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id, - H5_EVENT_STACK_NULL); - - ret = H5Pclose(fapl_id); - assert(0 == ret); - /* acquire container version 0 - EXACT. */ version = 0; - rid1 = H5RCacquire(file_id, &version, H5P_DEFAULT, H5_EVENT_STACK_NULL); + rid0 = H5RCacquire(file_id, &version, H5P_DEFAULT, H5_EVENT_STACK_NULL); assert(0 == version); /* create transaction object */ - tid1 = H5TRcreate(file_id, rid1, (uint64_t)1); - assert(tid1); + tid0 = H5TRcreate(file_id, rid0, (uint64_t)1); + assert(tid0); trspl_id = H5Pcreate(H5P_TR_START); ret = H5Pset_trspl_num_peers(trspl_id, (unsigned int) my_size); assert(0 == ret); - ret = H5TRstart(tid1, trspl_id, H5_EVENT_STACK_NULL); + ret = H5TRstart(tid0, trspl_id, H5_EVENT_STACK_NULL); assert(0 == ret); ret = H5Pclose(trspl_id); assert(0 == ret); @@ -71,9 +55,16 @@ write_dataset(const char *file_name, const char *dataset_name, if(0 == my_rank) { /* Create a dataset. */ dataset_id = H5Dcreate_ff(file_id, dataset_name, datatype_id, file_space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid1, H5_EVENT_STACK_NULL); + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid0, H5_EVENT_STACK_NULL); assert(dataset_id); +#ifdef H5_HAVE_INDEXING + /* Add indexing information */ + ret = H5Xcreate_ff(file_id, H5X_PLUGIN_DUMMY, dataset_id, H5P_DEFAULT, + tid0, H5_EVENT_STACK_NULL); + assert(0 == ret); +#endif + /* get the token size of each dset */ ret = H5Oget_token(dataset_id, NULL, &token_size1); assert(0 == ret); @@ -88,7 +79,7 @@ write_dataset(const char *file_name, const char *dataset_name, /* bcast the token sizes and the tokens */ MPI_Ibcast(&token_size1, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[0]); - MPI_Ibcast(dset_token1, token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, + MPI_Ibcast(dset_token1, (int) token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[1]); MPI_Waitall(2, mpi_reqs, MPI_STATUS_IGNORE); } @@ -102,11 +93,11 @@ write_dataset(const char *file_name, const char *dataset_name, dset_token1 = malloc(token_size1); /* recieve the token */ - MPI_Ibcast(dset_token1, token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, + MPI_Ibcast(dset_token1, (int) token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[0]); MPI_Waitall(1, mpi_reqs, MPI_STATUS_IGNORE); - dataset_id = H5Oopen_by_token(dset_token1, tid1, H5_EVENT_STACK_NULL); + dataset_id = H5Oopen_by_token(dset_token1, tid0, H5_EVENT_STACK_NULL); } free(dset_token1); @@ -120,122 +111,112 @@ write_dataset(const char *file_name, const char *dataset_name, /* Write the first dataset. */ ret = H5Dwrite_ff(dataset_id, datatype_id, mem_space_id, file_space_id, - H5P_DEFAULT, buf, tid1, H5_EVENT_STACK_NULL); + H5P_DEFAULT, buf, tid0, H5_EVENT_STACK_NULL); assert(0 == ret); /* Close the data space for the first dataset. */ ret = H5Sclose(mem_space_id); assert(0 == ret); - /* Finish transaction 1. */ - ret = H5TRfinish(tid1, H5P_DEFAULT, &rid2, H5_EVENT_STACK_NULL); + /* Close the first dataset. */ + ret = H5Dclose_ff(dataset_id, H5_EVENT_STACK_NULL); + assert(0 == ret); + + ret = H5Sclose(file_space_id); + assert(0 == ret); + + /* Finish transaction 0. */ + ret = H5TRfinish(tid0, H5P_DEFAULT, NULL, H5_EVENT_STACK_NULL); assert(0 == ret); /* release container version 0. */ - ret = H5RCrelease(rid1, H5_EVENT_STACK_NULL); + ret = H5RCrelease(rid0, H5_EVENT_STACK_NULL); assert(0 == ret); - MPI_Barrier(MPI_COMM_WORLD); + ret = H5RCclose(rid0); + assert(0 == ret); + + ret = H5TRclose(tid0); + assert(0 == ret); +} + +static hid_t +query_and_view(hid_t file_id, const char *dataset_name) +{ + double lower_bound1 = 39.1, upper_bound1 = 42.1; + int lower_bound2 = 295, upper_bound2 = 298; + hid_t query_id1, query_id2, query_id3, query_id4, query_id5, query_id6; + hid_t query_id, view_id; + hid_t dataset_id; + hid_t rid1; + uint64_t version; + herr_t ret; /* Create a simple query */ /* query = (39.1 < x < 42.1) || (295 < x < 298) */ query_id1 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_GREATER_THAN, H5T_NATIVE_DOUBLE, &lower_bound1); assert(query_id1); + query_id2 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_LESS_THAN, H5T_NATIVE_DOUBLE, &upper_bound1); assert(query_id2); + query_id3 = H5Qcombine(query_id1, H5Q_COMBINE_AND, query_id2); assert(query_id3); + query_id4 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_GREATER_THAN, H5T_NATIVE_INT, &lower_bound2); assert(query_id4); + query_id5 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_LESS_THAN, H5T_NATIVE_INT, &upper_bound2); assert(query_id5); + query_id6 = H5Qcombine(query_id4, H5Q_COMBINE_AND, query_id5); assert(query_id6); + query_id = H5Qcombine(query_id3, H5Q_COMBINE_OR, query_id6); assert(query_id); - view_id = H5Vcreate_ff(dataset_id, query_id, H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); - assert(view_id > 0); - - { - hsize_t attr_count, obj_count, reg_count; - hssize_t num_points; - hid_t region_space; - int r_ndims; - hsize_t r_dims[2]; - - H5Qclose(query_id); - ret = H5Dclose_ff(dataset_id, H5_EVENT_STACK_NULL); - assert(0 == ret); - - ret = H5Vget_location_ff(view_id, &dataset_id, H5_EVENT_STACK_NULL); - assert(0 == ret); - - ret = H5Dclose_ff(dataset_id, H5_EVENT_STACK_NULL); - assert(0 == ret); - - ret = H5Vget_query(view_id, &query_id); - assert(0 == ret); - - ret = H5Vget_counts(view_id, &attr_count, &obj_count, ®_count); - assert(0 == ret); - assert(0 == attr_count); - assert(0 == obj_count); - assert(1 == reg_count); - - ret = H5Vget_elem_regions_ff(view_id, 0, 1, &dataset_id, - ®ion_space, H5_EVENT_STACK_NULL); - assert(0 == ret); + /* acquire container version 1 - EXACT. */ + version = 1; + rid1 = H5RCacquire(file_id, &version, H5P_DEFAULT, H5_EVENT_STACK_NULL); + assert(rid1 > 0); + assert(1 == version); - r_ndims = H5Sget_simple_extent_dims(region_space, r_dims, NULL); + MPI_Barrier(MPI_COMM_WORLD); - assert(2 == r_ndims); - assert(total == r_dims[0]); - assert(ncomponents == r_dims[1]); + dataset_id = H5Dopen_ff(file_id, dataset_name, H5P_DEFAULT, rid1, + H5_EVENT_STACK_NULL); - num_points = H5Sget_select_elem_npoints(region_space); - assert(9 == num_points); + view_id = H5Vcreate_ff(dataset_id, query_id, H5P_DEFAULT, rid1, + H5_EVENT_STACK_NULL); + assert(view_id > 0); - ret = H5Sclose(region_space); - assert(0 == ret); - } + /* TODO do stuff here */ H5Vclose(view_id); - H5Qclose(query_id); - H5Qclose(query_id6); - H5Qclose(query_id5); - H5Qclose(query_id4); - H5Qclose(query_id3); - H5Qclose(query_id2); - H5Qclose(query_id1); - - /* Close the first dataset. */ ret = H5Dclose_ff(dataset_id, H5_EVENT_STACK_NULL); assert(0 == ret); - ret = H5Sclose(file_space_id); - assert(0 == ret); /* release container version 1. */ - ret = H5RCrelease(rid2, H5_EVENT_STACK_NULL); + ret = H5RCrelease(rid1, H5_EVENT_STACK_NULL); assert(0 == ret); ret = H5RCclose(rid1); assert(0 == ret); - ret = H5RCclose(rid2); - assert(0 == ret); - ret = H5TRclose(tid1); - assert(0 == ret); - MPI_Barrier(MPI_COMM_WORLD); + H5Qclose(query_id); + H5Qclose(query_id6); + H5Qclose(query_id5); + H5Qclose(query_id4); + H5Qclose(query_id3); + H5Qclose(query_id2); + H5Qclose(query_id1); - /* Close the file. */ - ret = H5Fclose_ff(file_id, H5_EVENT_STACK_NULL); - assert(0 == ret); + return query_id; } int @@ -247,6 +228,8 @@ main(int argc, char **argv) hsize_t ncomponents = 3; hsize_t start, total; int *data; + hid_t file_id, fapl_id; + herr_t ret; hsize_t i, j; int provided; @@ -277,11 +260,30 @@ main(int argc, char **argv) MPI_Barrier(MPI_COMM_WORLD); - write_dataset(file_name, dataset_name, total, ncomponents, H5T_NATIVE_INT, + /* Choose the IOD VOL plugin to use with this file. */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_iod(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL); + + /* Open an existing file. */ + file_id = H5Fcreate_ff(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id, + H5_EVENT_STACK_NULL); + + ret = H5Pclose(fapl_id); + assert(0 == ret); + + write_dataset(file_id, dataset_name, total, ncomponents, H5T_NATIVE_INT, ntuples, start, data); MPI_Barrier(MPI_COMM_WORLD); + query_and_view(file_id, dataset_name); + + MPI_Barrier(MPI_COMM_WORLD); + + /* Close the file. */ + ret = H5Fclose_ff(file_id, 1, H5_EVENT_STACK_NULL); + assert(0 == ret); + free(data); MPI_Barrier(MPI_COMM_WORLD); @@ -290,19 +292,3 @@ main(int argc, char **argv) return 0; } - -//H5Xregister(&index_plugin_struct); -//dsid = H5Dcreate(fid, "A", ...); -//H5Xcreate(fid, 32, dsid, H5P_DEFAULT); -//H5Dwrite(dsid, ...); -//H5Dclose(dsid); -// -//dsid = H5Dopen(fid, "A", ...); -//int query_val = 15; -//qid = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_EQUAL, H5T_NATIVE_INT, &query_val); -//vid = H5Vcreate(dsid, qid, H5P_DEFAULT); -//H5Dclose(dsid); -//H5Xdelete(dsid, 32); - - - |