diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2015-11-12 18:27:58 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2015-11-12 18:27:58 (GMT) |
commit | 48b507795750ac61f2cb1ab0b85b2ca9cfc7a0ea (patch) | |
tree | c35bd490b891805fa942f8234cf32e43c13260c6 | |
parent | a1b08ae861a9303bf849d3d5b80897bcb014f98d (diff) | |
download | hdf5-48b507795750ac61f2cb1ab0b85b2ca9cfc7a0ea.zip hdf5-48b507795750ac61f2cb1ab0b85b2ca9cfc7a0ea.tar.gz hdf5-48b507795750ac61f2cb1ab0b85b2ca9cfc7a0ea.tar.bz2 |
[svn-r28329] - add new FF reference API + FF implementation
- dereference still missing
- add simple example to test API
-rw-r--r-- | examples/Makefile.am | 2 | ||||
-rw-r--r-- | examples/h5ff_client_ref.c | 395 | ||||
-rw-r--r-- | src/H5FF.c | 10 | ||||
-rw-r--r-- | src/H5FF_ref.c | 1340 | ||||
-rw-r--r-- | src/H5FFpublic.h | 43 | ||||
-rw-r--r-- | src/H5M.c | 2 | ||||
-rw-r--r-- | src/H5Rpublic.h | 4 | ||||
-rw-r--r-- | src/H5VLiod.c | 10 | ||||
-rw-r--r-- | src/H5VLiod_client.h | 3 | ||||
-rw-r--r-- | src/H5VLiod_dtype.c | 15 | ||||
-rw-r--r-- | src/H5VLiod_obj.c | 20 | ||||
-rw-r--r-- | src/Makefile.am | 2 |
12 files changed, 1806 insertions, 40 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index 2e37baf..ee4c3cf 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -28,7 +28,7 @@ endif if BUILD_EFF_CONDITIONAL ##INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/test ##LDADD = $(LIBH5TEST) $(LIBHDF5) $(MYAXE_LIBS) $(MYDAOS_POSIX_LIBS) $(MYPLFS_LIBS) $(MYIOD_LIBS) - EXAMPLE_PROG_EFF = h5ff_server \ + EXAMPLE_PROG_EFF = h5ff_server h5ff_client_ref\ h5ff_client_map h5ff_client_multiple_cont h5ff_client_obj \ h5ff_client_dset h5ff_client_attr h5ff_client_links h5ff_client_view \ h5ff_client_vl_data h5ff_python_exec h5ff_client_analysis \ diff --git a/examples/h5ff_client_ref.c b/examples/h5ff_client_ref.c new file mode 100644 index 0000000..d9d08ab --- /dev/null +++ b/examples/h5ff_client_ref.c @@ -0,0 +1,395 @@ +/* + * h5ff_client_attr.c: Client side test for attribute routines. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> +#include <string.h> +#include "mpi.h" +#include "hdf5.h" + + +int main(int argc, char **argv) { + char file_name[50]; + hid_t file_id; + hid_t gid1; + hid_t sid, dtid; + hid_t sid2; + hid_t did1, map1; + hid_t aid1, aid2, aid3, aid4, aid5; + hid_t tid1, tid2, rid1, rid2, rid3; + hid_t fapl_id, trspl_id; + hid_t e_stack; + htri_t exists1; + htri_t exists2; + + uint64_t version; + uint64_t trans_num; + + int *wdata1 = NULL, *wdata2 = NULL; + int *rdata1 = NULL, *rdata2 = NULL; + char str_data[128]; + const unsigned int nelem=60; + hsize_t dims[1]; + + int my_rank, my_size; + int provided; + MPI_Request mpi_req; + + uint32_t cs_scope = 0; + size_t num_events = 0; + H5ES_status_t status; + unsigned int i = 0; + herr_t ret; + + sprintf(file_name, "%s_%s", getenv("USER"), "eff_file_ref.h5"); + + MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); + if(MPI_THREAD_MULTIPLE != provided) { + fprintf(stderr, "MPI does not have MPI_THREAD_MULTIPLE support\n"); + exit(1); + } + + /* Call EFF_init to initialize the EFF stack. */ + EFF_init(MPI_COMM_WORLD, MPI_INFO_NULL); + + MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); + MPI_Comm_size(MPI_COMM_WORLD, &my_size); + fprintf(stderr, "APP processes = %d, my rank is %d\n", my_size, my_rank); + + /* Choose the IOD VOL plugin to use with this file. */ + fapl_id = H5Pcreate (H5P_FILE_ACCESS); + ret = H5Pset_fapl_iod(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL); + assert(0 == ret); + + /* set the metada data integrity checks to happend at transfer through mercury */ + cs_scope |= H5_CHECKSUM_TRANSFER; + ret = H5Pset_metadata_integrity_scope(fapl_id, cs_scope); + assert(ret == 0); + + /* create an event Queue for managing asynchronous requests. */ + e_stack = H5EScreate(); + assert(e_stack); + + /* create the file. */ + file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + assert(file_id > 0); + + /* create 1-D dataspace with 60 elements */ + dims [0] = nelem; + sid = H5Screate_simple(1, dims, NULL); + + dtid = H5Tcopy(H5T_STD_I32LE); + + /* start transaction 2 with default Leader/Delegate model. Leader + which is rank 0 here starts the transaction. It can be + asynchronous, but we make it synchronous here so that the + Leader can tell its delegates that the transaction is + started. */ + if(0 == my_rank) { + /* acquire container version 1 - EXACT. + This can be asynchronous, but here we need the acquired ID + right after the call to start the transaction so we make synchronous. */ + version = 1; + rid1 = H5RCacquire(file_id, &version, H5P_DEFAULT, H5_EVENT_STACK_NULL); + + /* create transaction object */ + tid1 = H5TRcreate(file_id, rid1, (uint64_t)2); + assert(tid1); + ret = H5TRstart(tid1, H5P_DEFAULT, e_stack); + assert(0 == ret); + + sid2 = H5Screate(H5S_SCALAR); assert( sid2 ); + + /* create group /G1 */ + gid1 = H5Gcreate_ff(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT, tid1, e_stack); + assert(gid1 > 0); + + /* create dataset /G1/D1 */ + did1 = H5Dcreate_ff(gid1, "D1", dtid, sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack); + assert(did1 > 0); + + /* Commit the datatype dtid to the file. */ + ret = H5Tcommit_ff(file_id, "DT1", dtid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT, tid1, e_stack); + assert(ret == 0); + + /* create a Map object on the root group */ + map1 = H5Mcreate_ff(file_id, "MAP1", H5T_STD_I32LE, H5T_STD_I32LE, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack); + assert(map1 > 0); + + /* create an attribute on root group */ + aid1 = H5Acreate_ff(file_id, "ROOT_ATTR", dtid, sid, + H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack); + assert(aid1 > 0); + + /* create an attribute on group G1. */ + aid2 = H5Acreate_ff(gid1, "GROUP_ATTR", dtid, sid, + H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack); + assert(aid2 > 0); + + /* create an attribute on dataset */ + aid3 = H5Acreate_ff(did1, "DSET_ATTR", dtid, sid, + H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack); + assert(aid3 > 0); + + /* create an attribute on datatype */ + aid4 = H5Acreate_ff(dtid, "DTYPE_ATTR", dtid, sid, + H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack); + assert(aid4 > 0); + + aid5 = H5Acreate_ff(map1, "MAP_ATTR", dtid, sid2, H5P_DEFAULT, + H5P_DEFAULT, tid1, H5_EVENT_STACK_NULL ); + assert(aid5 > 0); + + H5Sclose(sid2); + + ret = H5Aclose_ff(aid1, e_stack); + assert(ret == 0); + ret = H5Aclose_ff(aid2, e_stack); + assert(ret == 0); + ret = H5Aclose_ff(aid3, e_stack); + assert(ret == 0); + ret = H5Aclose_ff(aid4, e_stack); + assert(ret == 0); + ret = H5Aclose_ff(aid5, e_stack); + assert(ret == 0); + ret = H5Dclose_ff(did1, e_stack); + assert(ret == 0); + ret = H5Gclose_ff(gid1, e_stack); + assert(ret == 0); + +#if 0 + printf("OPEN DT by token:\n"); + { + size_t token_size; + void *token; + hid_t new_id; + + H5Oget_token(dtid, NULL, &token_size); + token = malloc(token_size); + H5Oget_token(dtid, token, &token_size); + + new_id = H5Oopen_by_token(token, tid1, H5_EVENT_STACK_NULL); + H5Tclose(new_id); + free(token); + } +#endif + + /* make this synchronous so we know the container version has been acquired */ + ret = H5TRfinish(tid1, H5P_DEFAULT, &rid2, H5_EVENT_STACK_NULL); + assert(0 == ret); + + /* release container version 1. This is async. */ + ret = H5RCrelease(rid1, e_stack); + assert(0 == ret); + + /* Local op */ + ret = H5TRclose(tid1); + assert(0 == ret); + } + + H5ESget_count(e_stack, &num_events); + H5ESwait_all(e_stack, &status); + H5ESclear(e_stack); + printf("%d events in event stack. Completion status = %d\n", num_events, status); + if(0 != num_events) assert(status == H5ES_STATUS_SUCCEED); + + /* test creating internal references */ + { + href_ff_t ref1, ref2, ref3, ref4, ref5, ref6; + hsize_t start[1], count[1]; + hid_t dspace_region; + H5O_type_t obj_type; + + ret = H5Rcreate_object_ff(&ref1, file_id, "/G1", H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); + assert(ret == 0); + ret = H5Rprint_ref(&ref1); + assert(ret == 0); + + ret = H5Rcreate_object_ff(&ref2, map1, ".", H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); + assert(ret == 0); + ret = H5Rprint_ref(&ref2); + assert(ret == 0); + + start[0] = 10; + count[0] = 30; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL); + assert(ret == 0); + ret = H5Rcreate_region_ff(&ref3, file_id, "/G1/D1", sid, H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); + assert(ret == 0); + ret = H5Rprint_ref(&ref3); + assert(ret == 0); + + ret = H5Rcreate_attr_ff(&ref4, map1, ".", "Temperature", H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); + assert(ret == 0); + ret = H5Rprint_ref(&ref4); + assert(ret == 0); + ret = H5Rcreate_attr_ff(&ref5, dtid, ".", "TYPE_SIZE1", H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); + assert(ret == 0); + ret = H5Rprint_ref(&ref5); + assert(ret == 0); + ret = H5Rcreate_attr_ff(&ref6, file_id, "/DT1", "TYPE_SIZE2", H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); + assert(ret == 0); + ret = H5Rprint_ref(&ref6); + assert(ret == 0); + + H5E_BEGIN_TRY { + dspace_region = H5Rget_region_ff(&ref1); + } H5E_END_TRY; + assert (dspace_region < 0); + H5E_BEGIN_TRY { + dspace_region = H5Rget_region_ff(&ref4); + } H5E_END_TRY; + assert (dspace_region < 0); + + dspace_region = H5Rget_region_ff(&ref3); + assert(dspace_region > 0); + assert(H5Sget_simple_extent_ndims(dspace_region) == 1); + assert(H5Sget_select_npoints(dspace_region) == 30); + ret = H5Sclose(dspace_region); + assert(0 == ret); + + H5Rget_obj_type_ff(&ref1, &obj_type); + assert(obj_type == H5O_TYPE_GROUP); + H5Rget_obj_type_ff(&ref2, &obj_type); + assert(obj_type == H5O_TYPE_MAP); + H5Rget_obj_type_ff(&ref3, &obj_type); + assert(obj_type == H5O_TYPE_DATASET); + H5Rget_obj_type_ff(&ref6, &obj_type); + assert(obj_type == H5O_TYPE_NAMED_DATATYPE); + + H5E_BEGIN_TRY { + assert (H5Rget_filename_ff(&ref1, NULL, 0) < 0); + assert (H5Rget_filename_ff(&ref3, NULL, 0) < 0); + assert (H5Rget_filename_ff(&ref6, NULL, 0) < 0); + assert (H5Rget_name_ff(&ref1, NULL, 0) < 0); + assert (H5Rget_name_ff(&ref3, NULL, 0) < 0); + assert (H5Rget_name_ff(&ref6, NULL, 0) < 0); + } H5E_END_TRY; + + ret = H5Rdestroy_ff(&ref1); + assert(ret == 0); + ret = H5Rdestroy_ff(&ref2); + assert(ret == 0); + ret = H5Rdestroy_ff(&ref3); + assert(ret == 0); + ret = H5Rdestroy_ff(&ref4); + assert(ret == 0); + ret = H5Rdestroy_ff(&ref5); + assert(ret == 0); + ret = H5Rdestroy_ff(&ref6); + assert(ret == 0); + } + + ret = H5Mclose_ff(map1, e_stack); + assert(ret == 0); + + /* test creating external references */ + { + href_ff_t ref1, ref2, ref3; + hid_t dspace_region; + hsize_t start[1], count[1]; + H5O_type_t obj_type; + char fname[1024], pname[1024]; + + ret = H5Rcreate_object_ext_ff(&ref1, "ref1_file", "/G1/G2/G3"); + assert(ret == 0); + + start[0] = 10; + count[0] = 30; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL); + assert(ret == 0); + ret = H5Rcreate_region_ext_ff(&ref2, "ref2_file", "/G5/D4", sid); + assert(ret == 0); + + ret = H5Rcreate_attr_ext_ff(&ref3, "ref3_file", "/G18/M6", "Temperature"); + assert(ret == 0); + + ret = H5Rprint_ref(&ref1); + assert(ret == 0); + ret = H5Rprint_ref(&ref2); + assert(ret == 0); + ret = H5Rprint_ref(&ref3); + assert(ret == 0); + + H5E_BEGIN_TRY { + dspace_region = H5Rget_region_ff(&ref1); + } H5E_END_TRY; + assert (dspace_region < 0); + H5E_BEGIN_TRY { + dspace_region = H5Rget_region_ff(&ref3); + } H5E_END_TRY; + assert (dspace_region < 0); + + dspace_region = H5Rget_region_ff(&ref2); + assert(dspace_region > 0); + assert(H5Sget_simple_extent_ndims(dspace_region) == 1); + assert(H5Sget_select_npoints(dspace_region) == 30); + ret = H5Sclose(dspace_region); + assert(0 == ret); + + H5E_BEGIN_TRY { + ret = H5Rget_obj_type_ff(&ref1, &obj_type); + assert (ret < 0); + ret = H5Rget_obj_type_ff(&ref2, &obj_type); + assert (ret < 0); + ret = H5Rget_obj_type_ff(&ref3, &obj_type); + assert (ret < 0); + } H5E_END_TRY; + + assert(H5Rget_filename_ff(&ref1, fname, 1024) == 9); + assert(strcmp(fname, "ref1_file") == 0); + assert(H5Rget_filename_ff(&ref2, fname, 1024) == 9); + assert(strcmp(fname, "ref2_file") == 0); + assert(H5Rget_filename_ff(&ref3, fname, 1024) == 9); + assert(strcmp(fname, "ref3_file") == 0); + + assert(H5Rget_name_ff(&ref1, pname, 1024) == 9); + assert(strcmp(pname, "/G1/G2/G3") == 0); + assert(H5Rget_name_ff(&ref2, pname, 1024) == 6); + assert(strcmp(pname, "/G5/D4") == 0); + assert(H5Rget_name_ff(&ref3, pname, 1024) == 7); + assert(strcmp(pname, "/G18/M6") == 0); + + ret = H5Rdestroy_ff(&ref1); + assert(ret == 0); + ret = H5Rdestroy_ff(&ref2); + assert(ret == 0); + ret = H5Rdestroy_ff(&ref3); + assert(ret == 0); + } + + if(0 == my_rank) { + /* release container version 2. This is async. */ + ret = H5RCrelease(rid2, e_stack); + assert(0 == ret); + + ret = H5RCclose(rid1); + assert(0 == ret); + ret = H5RCclose(rid2); + assert(0 == ret); + } + + ret = H5Sclose(sid); + assert(ret == 0); + ret = H5Tclose(dtid); + assert(ret == 0); + ret = H5Pclose(fapl_id); + assert(ret == 0); + + H5Fclose_ff(file_id, 1, H5_EVENT_STACK_NULL); + + ret = H5ESclose(e_stack); + assert(ret == 0); + + MPI_Barrier(MPI_COMM_WORLD); + EFF_finalize(); + MPI_Finalize(); + + return 0; +} @@ -52,7 +52,7 @@ #include "H5VLiod.h" /* IOD plugin - tmp */ #include "H5VLiod_client.h" /* Client IOD - tmp */ #include "H5VLiod_server.h" /* Server IOD - tmp */ -#include "H5Xprivate.h" /* Indexing */ +#include "H5Xprivate.h" /* Indexing */ #ifdef H5_HAVE_EFF /****************/ @@ -2255,7 +2255,7 @@ H5Aexists_ff(hid_t obj_id, const char *attr_name, htri_t *ret, hid_t rcxt_id, hi herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "i*s*bii", obj_id, attr_name, ret, rcxt_id, estack_id); + H5TRACE5("e", "i*s*tii", obj_id, attr_name, ret, rcxt_id, estack_id); /* check arguments */ if(H5I_ATTR == H5I_get_type(obj_id)) @@ -2324,7 +2324,7 @@ H5Aexists_by_name_ff(hid_t loc_id, const char *obj_name, const char *attr_name, herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*s*si*bii", loc_id, obj_name, attr_name, lapl_id, ret, rcxt_id, + H5TRACE7("e", "i*s*si*tii", loc_id, obj_name, attr_name, lapl_id, ret, rcxt_id, estack_id); /* check arguments */ @@ -2942,7 +2942,7 @@ H5Lexists_ff(hid_t loc_id, const char *name, hid_t lapl_id, htri_t *ret, herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*si*bii", loc_id, name, lapl_id, ret, rcxt_id, estack_id); + H5TRACE6("e", "i*si*tii", loc_id, name, lapl_id, ret, rcxt_id, estack_id); /* Check arguments */ if(!name || !*name) @@ -3466,7 +3466,7 @@ H5Oexists_by_name_ff(hid_t loc_id, const char *name, htri_t *ret, hid_t lapl_id, herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*s*biii", loc_id, name, ret, lapl_id, rcxt_id, estack_id); + H5TRACE6("e", "i*s*tiii", loc_id, name, ret, lapl_id, rcxt_id, estack_id); /* Check args */ if(!name || !*name) diff --git a/src/H5FF_ref.c b/src/H5FF_ref.c new file mode 100644 index 0000000..8c464bc --- /dev/null +++ b/src/H5FF_ref.c @@ -0,0 +1,1340 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Wrappers around existing HDF5 to support Exascale FastForward + * functionality. + */ + + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5FFmodule.h" /* This source code file is part of the H5FF module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5ESprivate.h" /* Event Stacks */ +#include "H5FFprivate.h" /* FastForward wrappers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL plugins */ +#include "H5VLiod.h" /* IOD plugin - tmp */ +#include "H5VLiod_client.h" /* Client IOD - tmp */ +#include "H5VLiod_server.h" /* Server IOD - tmp */ + +static herr_t H5R_print_token(const void *token); + +static herr_t H5R_encode(H5R_type_t ref_type, void *buf, size_t *nalloc, void *_obj, + hid_t space_id, const char *attrname); +static herr_t H5R_encode_ext(H5R_type_t ref_type, void *buf, size_t *nalloc, const char *filename, + const char *pathname, hid_t space_id, const char *attrname); + + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_object_ff + * + * Purpose: Create an object reference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Rcreate_object_ff(href_ff_t *ref, hid_t loc_id, const char *name, hid_t lapl_id, + hid_t rcxt_id, hid_t H5_ATTR_UNUSED estack_id) +{ + H5VL_object_t *obj = NULL; + H5VL_loc_params_t loc_params; + hid_t dxpl_id = H5P_DATASET_XFER_DEFAULT; + H5P_genplist_t *plist; + hbool_t obj_opened = FALSE; + H5I_type_t opened_type; + H5VL_object_t *opened_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + + /* Need to open the object if a path to it is given */ + if(strcmp(name, ".")) { + printf("Object %s not location object, so We need to open it.\n", name); + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* store the transaction ID in the dxpl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + if(H5P_set(plist, H5VL_CONTEXT_ID, &rcxt_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for rcxt_id"); + + /* Open the object through the VOL */ + if(NULL == (opened_obj = (H5VL_object_t *)H5VL_object_open(obj->vol_obj, loc_params, + obj->vol_info->vol_cls, &opened_type, + dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + + obj_opened = TRUE; + } + else { + printf("path is %s. Location object already open.\n", name); + opened_obj = (H5VL_object_t *)obj->vol_obj; + } + + if(H5R_encode(H5R_OBJECT, NULL, &ref->buf_size, opened_obj, FAIL, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference"); + + if(NULL == (ref->buf = HDmalloc(ref->buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate reference buffer"); + + if(H5R_encode(H5R_OBJECT, ref->buf, &ref->buf_size, opened_obj, FAIL, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference"); + + ref->ref_type = H5R_OBJECT; + +done: + if(obj_opened) { + switch(opened_type) { + case H5I_DATASET: + if(H5VL_iod_dataset_close(opened_obj, dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_DATATYPE: + if(H5VL_iod_datatype_close(opened_obj, dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_MAP: + if(H5VL_iod_map_close(opened_obj, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_GROUP: + if(H5VL_iod_group_close(opened_obj, dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_ATTR: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_ES: + case H5I_RC: + case H5I_TR: + case H5I_QUERY: + case H5I_VIEW: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "invalid object type") + } + } + FUNC_LEAVE_API(ret_value) +} /* H5Rcreate_object_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_region_ff + * + * Purpose: Create a region reference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t H5Rcreate_region_ff(href_ff_t *ref, hid_t loc_id, const char *name, hid_t space_id, hid_t lapl_id, + hid_t rcxt_id, hid_t H5_ATTR_UNUSED estack_id) +{ + H5VL_object_t *obj = NULL; + H5VL_loc_params_t loc_params; + hid_t dxpl_id = H5P_DATASET_XFER_DEFAULT; + H5P_genplist_t *plist; + hbool_t obj_opened = FALSE; + H5I_type_t opened_type; + H5VL_object_t *opened_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if(space_id == (-1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") + + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + + /* Need to open the object if a path to it is given */ + if(strcmp(name, ".")) { + printf("Object %s not location object, so We need to open it.\n", name); + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* store the transaction ID in the dxpl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + if(H5P_set(plist, H5VL_CONTEXT_ID, &rcxt_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for rcxt_id"); + + /* Open the object through the VOL */ + if(NULL == (opened_obj = (H5VL_object_t *)H5VL_object_open(obj->vol_obj, loc_params, + obj->vol_info->vol_cls, &opened_type, + dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + + obj_opened = TRUE; + + if(H5I_DATASET != opened_type) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, FAIL, "Object is not a Dataset") + } + else { + opened_obj = (H5VL_object_t *)obj->vol_obj; + } + + if(H5R_encode(H5R_DATASET_REGION, NULL, &ref->buf_size, opened_obj, space_id, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference"); + + if(NULL == (ref->buf = HDmalloc(ref->buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate reference buffer"); + + if(H5R_encode(H5R_DATASET_REGION, ref->buf, &ref->buf_size, opened_obj, space_id, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference"); + + ref->ref_type = H5R_DATASET_REGION; +done: + if(obj_opened) { + if(H5VL_iod_dataset_close(opened_obj, dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + } + FUNC_LEAVE_API(ret_value) +} /* H5Rcreate_region_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_attr_ff + * + * Purpose: Create an attribute reference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t H5Rcreate_attr_ff(href_ff_t *ref, hid_t loc_id, const char *name, const char *attr_name, hid_t lapl_id, + hid_t rcxt_id, hid_t H5_ATTR_UNUSED estack_id) +{ + H5VL_object_t *obj = NULL; + H5VL_loc_params_t loc_params; + hid_t dxpl_id = H5P_DATASET_XFER_DEFAULT; + H5P_genplist_t *plist; + hbool_t obj_opened = FALSE; + H5I_type_t opened_type; + H5VL_object_t *opened_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if(!attr_name || !*attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name given") + + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + + /* Need to open the object if a path to it is given */ + if(strcmp(name, ".")) { + printf("Object %s not location object, so We need to open it.\n", name); + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* store the transaction ID in the dxpl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + if(H5P_set(plist, H5VL_CONTEXT_ID, &rcxt_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for rcxt_id"); + + /* Open the object through the VOL */ + if(NULL == (opened_obj = (H5VL_object_t *)H5VL_object_open(obj->vol_obj, loc_params, + obj->vol_info->vol_cls, &opened_type, + dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + + obj_opened = TRUE; + } + else { + opened_obj = (H5VL_object_t *)obj->vol_obj; + } + + if(H5R_encode(H5R_ATTR, NULL, &ref->buf_size, opened_obj, FAIL, attr_name) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference"); + + if(NULL == (ref->buf = HDmalloc(ref->buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate reference buffer"); + + if(H5R_encode(H5R_ATTR, ref->buf, &ref->buf_size, opened_obj, FAIL, attr_name) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference"); + + ref->ref_type = H5R_ATTR; +done: + if(obj_opened) { + switch(opened_type) { + case H5I_DATASET: + if(H5VL_iod_dataset_close(opened_obj, dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_DATATYPE: + if(H5VL_iod_datatype_close(opened_obj, dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_MAP: + if(H5VL_iod_map_close(opened_obj, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_GROUP: + if(H5VL_iod_group_close(opened_obj, dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "Can't close object"); + break; + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_ATTR: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_ES: + case H5I_RC: + case H5I_TR: + case H5I_QUERY: + case H5I_VIEW: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "invalid object type") + } + } + FUNC_LEAVE_API(ret_value) +} /* H5Rcreate_attr_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_object_ext_ff + * + * Purpose: Create an external object reference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t H5Rcreate_object_ext_ff(href_ff_t *ref, const char *filename, const char *pathname) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if(!filename || !*filename) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filename given") + if(!pathname || !*pathname) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no pathname given") + + if(H5R_encode_ext(H5R_OBJECT_EXT, NULL, &ref->buf_size, filename, pathname, FAIL, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference") + + if(NULL == (ref->buf = HDmalloc(ref->buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate reference buffer") + + if(H5R_encode_ext(H5R_OBJECT_EXT, ref->buf, &ref->buf_size, filename, pathname, FAIL, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference") + + ref->ref_type = H5R_OBJECT_EXT; +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rcreate_object_ext_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_region_ext_ff + * + * Purpose: Create an external region reference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t H5Rcreate_region_ext_ff(href_ff_t *ref, const char *filename, const char *pathname, + hid_t space_id) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if(!filename || !*filename) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filename given") + if(!pathname || !*pathname) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no pathname given") + if(space_id == (-1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") + + if(H5R_encode_ext(H5R_DATASET_REGION_EXT, NULL, &ref->buf_size, filename, pathname, space_id, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference") + + if(NULL == (ref->buf = HDmalloc(ref->buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate reference buffer") + + if(H5R_encode_ext(H5R_DATASET_REGION_EXT, ref->buf, &ref->buf_size, filename, pathname, space_id, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference") + + ref->ref_type = H5R_DATASET_REGION_EXT; +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rcreate_region_ext_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_attr_ext_ff + * + * Purpose: Create an external attributereference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t H5Rcreate_attr_ext_ff(href_ff_t *ref, const char *filename, const char *pathname, + const char *attr_name) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if(!filename || !*filename) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filename given") + if(!pathname || !*pathname) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no pathname given") + if(!attr_name || !*attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name given") + + if(H5R_encode_ext(H5R_ATTR_EXT, NULL, &ref->buf_size, filename, pathname, -1, attr_name) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference") + + if(NULL == (ref->buf = HDmalloc(ref->buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate reference buffer") + + if(H5R_encode_ext(H5R_ATTR_EXT, ref->buf, &ref->buf_size, filename, pathname, -1, attr_name) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Can't determine buffer size to encode reference") + + ref->ref_type = H5R_ATTR_EXT; +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rcreate_attr_ext_ff */ + +#if 0 + +/*------------------------------------------------------------------------- + * Function: H5Rdereference_ff + * + * Purpose: Dereference an existing reference (FF) + * + * Return: Success: dereferenced object ID + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +hid_t H5Rdereference_ff(hid_t loc_id, hid_t oapl_id, const href_ff_t *ref, + hid_t rcxt_id, hid_t estack_id) +{ + hid_t ret_value; /* Return value */ + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rdereference_ff */ + +#endif + + +/*------------------------------------------------------------------------- + * Function: H5Rdestroy_ff + * + * Purpose: Free resources by a reference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t H5Rdestroy_ff(href_ff_t *ref) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if(ref->buf == NULL || ref->buf_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference") + + HDfree(ref->buf); + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rdestroy_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rget_region_ff + * + * Purpose: return dataspace from a region reference (FF) + * + * Return: Success: dataspace ID + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +hid_t H5Rget_region_ff(const href_ff_t *ref) +{ + const uint8_t *p; + H5S_t *ds = NULL; + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer"); + if(ref->buf == NULL || ref->buf_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference") + if(ref->ref_type != H5R_DATASET_REGION_EXT && ref->ref_type != H5R_DATASET_REGION) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not a region reference"); + + p = (uint8_t *)ref->buf; + + /* get the region selection */ + if(ref->ref_type == H5R_DATASET_REGION) { + size_t token_size, space_size; + + /* token */ + UINT64DECODE(p, token_size); + p += token_size; + + /* space */ + UINT64DECODE(p, space_size); + if((ds = H5S_decode((const unsigned char **)&p)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object"); + } + else { + size_t name_size, space_size; + /* file name */ + UINT64DECODE(p, name_size); + p += name_size; + /* path name */ + UINT64DECODE(p, name_size); + p += name_size; + + /* space */ + UINT64DECODE(p, space_size); + if((ds = H5S_decode((const unsigned char **)&p)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object"); + } + + /* Register the type and return the ID */ + if((ret_value = H5I_register(H5I_DATASPACE, ds, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, FAIL, "unable to register dataspace") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rget_region_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rget_obj_type_ff + * + * Purpose: Retrieve object type from reference (FF) + * + * Return: Success: 0 + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t H5Rget_obj_type_ff(const href_ff_t *ref, H5O_type_t *obj_type) +{ + const uint8_t *p; + H5I_type_t obji_type; + size_t token_size; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer"); + if(ref->buf == NULL || ref->buf_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference"); + if(ref->ref_type != H5R_OBJECT && ref->ref_type != H5R_DATASET_REGION && + ref->ref_type != H5R_ATTR) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type"); + + p = (uint8_t *)ref->buf; + + UINT64DECODE(p, token_size); + p += sizeof(iod_obj_id_t) * 3; + HDmemcpy(&obji_type, p, sizeof(H5I_type_t)); + + if(obji_type == H5I_DATASET) + *obj_type = H5O_TYPE_DATASET; + else if(obji_type == H5I_DATATYPE) + *obj_type = H5O_TYPE_NAMED_DATATYPE; + else if(obji_type == H5I_GROUP) + *obj_type = H5O_TYPE_GROUP; + else if(obji_type == H5I_MAP) + *obj_type = H5O_TYPE_MAP; + else + HDassert("Invalid Object type" && 0); + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rget_obj_type_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rget_name_ff + * + * Purpose: Return object name from reference + * + * Return: Success: length of the name if successful. + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +ssize_t H5Rget_name_ff(const href_ff_t *ref, char *name/*out*/, size_t size) +{ + const uint8_t *p; + size_t name_size; + ssize_t ret_value = -1; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer"); + if(ref->buf == NULL || ref->buf_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference"); + if(ref->ref_type != H5R_OBJECT_EXT && ref->ref_type != H5R_DATASET_REGION_EXT && + ref->ref_type != H5R_ATTR_EXT) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type"); + + p = (uint8_t *)ref->buf; + /* file name */ + UINT64DECODE(p, name_size); + p += name_size; + + /* path name */ + UINT64DECODE(p, name_size); + + if(name && size >= name_size) { + HDmemcpy(name, p, name_size); + name[name_size] = '\0'; + } + else if(name) { + HDmemcpy(name, p, size); + name[size] = '\0'; + } + + ret_value = (ssize_t)name_size; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rget_name_ff */ + + +/*------------------------------------------------------------------------- + * Function: H5Rget_filename_ff + * + * Purpose: Filename associated with the reference (FF) + * + * Return: Success: length of the filename if successful. + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * November, 2015 + * + *------------------------------------------------------------------------- + */ +ssize_t H5Rget_filename_ff(const href_ff_t *ref, char *name/*out*/, size_t size) +{ + const uint8_t *p; + size_t name_size; + ssize_t ret_value = -1; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(ref == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer"); + if(ref->buf == NULL || ref->buf_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference"); + if(ref->ref_type != H5R_OBJECT_EXT && ref->ref_type != H5R_DATASET_REGION_EXT && + ref->ref_type != H5R_ATTR_EXT) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type"); + + p = (uint8_t *)ref->buf; + /* file name */ + UINT64DECODE(p, name_size); + + if(name && size >= name_size) { + HDmemcpy(name, p, name_size); + name[name_size] = '\0'; + } + else if(name) { + HDmemcpy(name, p, size); + name[size] = '\0'; + } + + ret_value = (ssize_t)name_size; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Rget_filename_ff */ + +static herr_t +H5R_encode(H5R_type_t ref_type, void *buf, size_t *nalloc, void *_obj, + hid_t space_id, const char *attrname) +{ + H5VL_iod_object_t *obj = (H5VL_iod_object_t *)_obj; + uint8_t *p = (uint8_t *)buf; /* Temporary pointer to encoding buffer */ + size_t token_size; + size_t buf_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); + HDassert(ref_type == H5R_OBJECT || ref_type == H5R_DATASET_REGION || + ref_type == H5R_ATTR); + + if(H5VL_iod_get_token(obj, NULL, &token_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to get location token"); + buf_size += token_size + sizeof(uint64_t); + + if(buf) { + UINT64ENCODE(p, token_size); + if(H5VL_iod_get_token(obj, p, &token_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to get location token"); + p += token_size; + } + + if(ref_type == H5R_DATASET_REGION) { + size_t dspace_size; + + HDassert(space_id >= 0); + + if(H5Sencode(space_id, NULL, &dspace_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "Can't encode dataspace"); + buf_size += dspace_size + sizeof(uint64_t); + + if(buf) { + UINT64ENCODE(p, dspace_size); + if(H5Sencode(space_id, p, &dspace_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "Can't encode dataspace"); + } + } + else if (ref_type == H5R_ATTR) { + uint64_t attrname_size; + + HDassert(attrname); + + attrname_size = strlen(attrname); + buf_size += attrname_size + sizeof(uint64_t); + + if(buf) { + UINT64ENCODE(p, attrname_size); + HDmemcpy(p, attrname, attrname_size); + } + } + + *nalloc = buf_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + +static herr_t +H5R_encode_ext(H5R_type_t ref_type, void *buf, size_t *nalloc, const char *filename, + const char *pathname, hid_t space_id, const char *attrname) +{ + uint8_t *p = (uint8_t *)buf; /* Temporary pointer to encoding buffer */ + size_t filename_size, pathname_size; + size_t buf_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); + HDassert(ref_type == H5R_OBJECT_EXT || ref_type == H5R_DATASET_REGION_EXT || + ref_type == H5R_ATTR_EXT); + HDassert(filename); + HDassert(pathname); + + filename_size = strlen(filename); + pathname_size = strlen(pathname); + buf_size += sizeof(uint64_t) * 2; /* size of filename and pathname */ + buf_size += filename_size; + buf_size += pathname_size; + + if(buf) { + UINT64ENCODE(p, filename_size); + HDmemcpy(p, filename, filename_size); + p += filename_size; + + UINT64ENCODE(p, pathname_size); + HDmemcpy(p, pathname, pathname_size); + p += pathname_size; + } + + if(H5R_DATASET_REGION_EXT == ref_type) { + size_t dspace_size; + + HDassert(space_id >= 0); + if(H5Sencode(space_id, NULL, &dspace_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "Can't encode dataspace"); + buf_size += dspace_size + sizeof(uint64_t); + + if(buf) { + UINT64ENCODE(p, dspace_size); + if(H5Sencode(space_id, p, &dspace_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "Can't encode dataspace"); + } + } + else if(H5R_ATTR_EXT == ref_type) { + uint64_t attrname_size; + + HDassert(attrname); + + attrname_size = strlen(attrname); + buf_size += attrname_size + sizeof(uint64_t); + if(buf) { + UINT64ENCODE(p, attrname_size); + HDmemcpy(p, attrname, attrname_size); + } + } + + *nalloc = buf_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + +herr_t +H5Rprint_ref(href_ff_t *ref) +{ + const uint8_t *p; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + HDassert(ref); + HDassert(ref->buf); + + p = (uint8_t *)ref->buf; + + printf("================================================\n"); + + switch(ref->ref_type) { + case H5R_OBJECT: + { + size_t token_size; + + printf("Ref type = %d (%s)\n", (int)ref->ref_type, "Object Ref"); + printf("Total Buffer size = %zu\n", ref->buf_size); + + UINT64DECODE(p, token_size); + printf("Token size = %zu\n", token_size); + H5R_print_token(p); + p += token_size; + break; + } + case H5R_DATASET_REGION: + { + size_t token_size; + + printf("Ref type = %d (%s)\n", (int)ref->ref_type, "Dataset Region Ref"); + printf("Total Buffer size = %zu\n", ref->buf_size); + + UINT64DECODE(p, token_size); + printf("Token size = %zu\n", token_size); + H5R_print_token(p); + p += token_size; + + /* decode selection */ + { + H5S_t *ds; + size_t space_size; + + UINT64DECODE(p, space_size); + printf("Region selection size = %zu\n", space_size); + + if((ds = H5S_decode((const unsigned char **)&p)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object"); + p += space_size; + + printf("Dataspace Rank = %d\n", H5S_get_simple_extent_ndims(ds)); + printf("Num points selected = %d\n", (int)H5S_get_select_npoints(ds)); + + H5S_close(ds); + } + break; + } + case H5R_ATTR: + { + size_t token_size; + + printf("Ref type = %d (%s)\n", (int)ref->ref_type, "Attr Ref"); + printf("Total Buffer size = %zu\n", ref->buf_size); + + UINT64DECODE(p, token_size); + printf("Token size = %zu\n", token_size); + H5R_print_token(p); + p += token_size; + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("Attribute Name length = %zu\n", name_size); + printf("Attribute Name = %s\n", name); + } + + break; + } + case H5R_OBJECT_EXT: + { + printf("Ref type = %d (%s)\n", (int)ref->ref_type, "External Object Ref"); + printf("Total Buffer size = %zu\n", ref->buf_size); + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + printf("File Name length = %zu\n", name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("File Name = %s\n", name); + } + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("Path Name length = %zu\n", name_size); + printf("Path Name = %s\n", name); + } + + break; + } + case H5R_DATASET_REGION_EXT: + { + printf("Ref type = %d (%s)\n", (int)ref->ref_type, "External Dataset Region Ref"); + printf("Total Buffer size = %zu\n", ref->buf_size); + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("File Name length = %zu\n", name_size); + printf("File Name = %s\n", name); + } + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("Path Name length = %zu\n", name_size); + printf("Path Name = %s\n", name); + } + + /* decode selection */ + { + H5S_t *ds; + size_t space_size; + + UINT64DECODE(p, space_size); + printf("Region selection size = %zu\n", space_size); + + if((ds = H5S_decode((const unsigned char **)&p)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object"); + p += space_size; + + printf("Dataspace Rank = %d\n", H5S_get_simple_extent_ndims(ds)); + printf("Num points selected = %d\n", (int)H5S_get_select_npoints(ds)); + + H5S_close(ds); + } + + break; + } + case H5R_ATTR_EXT: + { + printf("Ref type = %d (%s)\n", (int)ref->ref_type, "External Attr Ref"); + printf("Total Buffer size = %zu\n", ref->buf_size); + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("File Name length = %zu\n", name_size); + printf("File Name = %s\n", name); + } + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("Path Name length = %zu\n", name_size); + printf("Path Name = %s\n", name); + } + + { + size_t name_size; + char name[1024]; + + UINT64DECODE(p, name_size); + HDmemcpy(name, p, name_size); + p += name_size; + name[name_size] = '\0'; + printf("Attribute Name length = %zu\n", name_size); + printf("Attribute Name = %s\n", name); + } + + break; + } + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("bad reference" && 0); + } + + printf("================================================\n"); +done: + FUNC_LEAVE_API(ret_value) +} + +static herr_t +H5R_print_token(const void *token) +{ + const uint8_t *buf_ptr = (const uint8_t *)token; + H5I_type_t obj_type; + iod_obj_id_t iod_id, mdkv_id, attrkv_id; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + HDmemcpy(&iod_id, buf_ptr, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(&mdkv_id, buf_ptr, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(&attrkv_id, buf_ptr, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(&obj_type, buf_ptr, sizeof(H5I_type_t)); + buf_ptr += sizeof(H5I_type_t); + + switch(obj_type) { + case H5I_ATTR: + printf("Object type = %s\n", "ATTRIBUTE"); + + /* decode dtype */ + { + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + /* Create datatype by decoding buffer */ + //if(NULL == (dt = H5T_decode((const unsigned char *)buf_ptr))) + //HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "can't decode object"); + buf_ptr += dt_size; + } + + /* decode dspace */ + { + H5S_t *ds; + size_t space_size; + + HDmemcpy(&space_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if((ds = H5S_decode((const unsigned char **)&buf_ptr)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object"); + buf_ptr += space_size; + + printf("Token Dataspace Rank = %d\n", H5S_get_simple_extent_ndims(ds)); + + H5S_close(ds); + } + + break; + case H5I_DATASET: + printf("Object type = %s\n", "DATASET"); + + /* decode creation property list */ + { + size_t plist_size; + + HDmemcpy(&plist_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += plist_size; + } + + /* decode dtype */ + { + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += dt_size; + } + + /* decode dspace */ + { + H5S_t *ds; + size_t space_size; + + HDmemcpy(&space_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if((ds = H5S_decode((const unsigned char **)&buf_ptr)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object"); + buf_ptr += space_size; + + printf("Token Dataspace Rank = %d\n", H5S_get_simple_extent_ndims(ds)); + printf("Token Num points selected = %d\n", (int)H5S_get_select_npoints(ds)); + + H5S_close(ds); + } + + break; + case H5I_DATATYPE: + printf("Object type = %s\n", "DATATYPE"); + + /* decode creation property list */ + { + size_t plist_size; + + HDmemcpy(&plist_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += plist_size; + } + + /* decode dtype */ + { + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += dt_size; + } + + break; + case H5I_GROUP: + printf("Object type = %s\n", "GROUP"); + + /* decode creation property list */ + { + size_t plist_size; + + HDmemcpy(&plist_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += plist_size; + } + + break; + case H5I_MAP: + printf("Object type = %s\n", "MAP"); + + /* decode creation property list */ + { + size_t plist_size; + + HDmemcpy(&plist_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += plist_size; + } + + /* decode key_type */ + { + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += dt_size; + } + /* decode val_type */ + { + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + buf_ptr += dt_size; + } + + break; + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_ES: + case H5I_RC: + case H5I_TR: + case H5I_QUERY: + case H5I_VIEW: + 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_CANTINIT, FAIL, "not a valid file object (dataset, map, group, or datatype)"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +}/* end H5R_print_token() */ diff --git a/src/H5FFpublic.h b/src/H5FFpublic.h index 4f6ae1c..d92bc7b 100644 --- a/src/H5FFpublic.h +++ b/src/H5FFpublic.h @@ -65,9 +65,14 @@ typedef enum H5FF_checksum_bitflag_t { H5_CHECKSUM_ALL = 0x07 } H5FF_checksum_bitflag_t; +typedef struct href_ff_t { + size_t buf_size;/* Size of serialized reference */ + void *buf; /* Pointer to serialized reference */ + H5R_type_t ref_type; +} href_ff_t; + #define H5R_OBJ_FF_REF_BUF_SIZE sizeof(haddr_t) -/* Object reference structure for user's code */ -typedef haddr_ff_t hobj_ff_ref_t; + /********************/ /* Public Variables */ @@ -184,20 +189,28 @@ H5_DLL herr_t H5Oget_info_by_name_ff(hid_t loc_id, const char *object_name, H5_DLL herr_t H5Oclose_ff(hid_t object_id, hid_t estack_id); -#if 0 /* Functions in H5R.c */ -H5_DLL herr_t H5Rcreate_object_ff(href_t *ref, hid_t loc_id, const char *name, hid_t rcxt_id, hid_t estack_id); -H5_DLL herr_t H5Rcreate_region_ff(href_t *ref, hid_t loc_id, const char *name, hid_t space_id, hid_t rcxt_id, hid_t estack_id); -H5_DLL herr_t H5Rcreate_attr_ff(href_t *ref, hid_t loc_id, const char *name, const char *atrr_name, hid_t rcxt_id, hid_t estack_id); -//H5_DLL herr_t H5Rcreate_object_ext(href_t *ref, const char *filename, const char *pathname); -//H5_DLL herr_t H5Rcreate_region_ext(href_t *ref, const char *filename, const char *pathname, hid_t space_id); -//H5_DLL herr_t H5Rcreate_attr_ext(href_t *ref, const char *filename, const char *pathname, const char *atrr_name); -H5_DLL herr_t H5Rdestroy(href_t *ref); -H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, const href_t *ref); -H5_DLL hid_t H5Rget_region(hid_t dataset, const href_t *ref); -H5_DLL herr_t H5Rget_obj_type2(const href_t *ref, H5O_type_t *obj_type); -H5_DLL ssize_t H5Rget_name(const href_t *ref, char *name/*out*/, size_t size); -H5_DLL ssize_t H5Rget_filename(const href_t *ref, char *name/*out*/, size_t size); +H5_DLL herr_t H5Rcreate_object_ff(href_ff_t *ref, hid_t loc_id, const char *name, hid_t lapl_id, + hid_t rcxt_id, hid_t estack_id); +H5_DLL herr_t H5Rcreate_region_ff(href_ff_t *ref, hid_t loc_id, const char *name, hid_t space_id, + hid_t lapl_id, hid_t rcxt_id, hid_t estack_id); +H5_DLL herr_t H5Rcreate_attr_ff(href_ff_t *ref, hid_t loc_id, const char *name, const char *attr_name, + hid_t lapl_id, hid_t rcxt_id, hid_t estack_id); +H5_DLL herr_t H5Rcreate_object_ext_ff(href_ff_t *ref, const char *filename, const char *pathname); +H5_DLL herr_t H5Rcreate_region_ext_ff(href_ff_t *ref, const char *filename, const char *pathname, + hid_t space_id); +H5_DLL herr_t H5Rcreate_attr_ext_ff(href_ff_t *ref, const char *filename, const char *pathname, + const char *attr_name); +H5_DLL herr_t H5Rprint_ref(href_ff_t *ref); + +H5_DLL herr_t H5Rdestroy_ff(href_ff_t *ref); +H5_DLL ssize_t H5Rget_filename_ff(const href_ff_t *ref, char *name/*out*/, size_t size); +H5_DLL herr_t H5Rget_obj_type_ff(const href_ff_t *ref, H5O_type_t *obj_type); +H5_DLL hid_t H5Rget_region_ff(const href_ff_t *ref); +H5_DLL ssize_t H5Rget_name_ff(const href_ff_t *ref, char *name/*out*/, size_t size); +#if 0 +H5_DLL hid_t H5Rdereference_ff(hid_t loc_id, hid_t oapl_id, const href_ff_t *ref, + hid_t rcxt_id, hid_t estack_id); #endif H5_DLL herr_t H5Aprefetch_ff(hid_t attr_id, hid_t rcxt_id, hrpl_t *replica_id, @@ -669,7 +669,7 @@ H5Mexists_ff(hid_t map_id, hid_t key_mem_type_id, const void *key, herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "ii*x*bii", map_id, key_mem_type_id, key, exists, rcxt_id, + H5TRACE6("e", "ii*x*tii", map_id, key_mem_type_id, key, exists, rcxt_id, estack_id); /* check arguments */ diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index e990661..5ff29c1 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -31,6 +31,10 @@ typedef enum { H5R_BADTYPE = (-1), /*invalid Reference Type */ H5R_OBJECT, /*Object reference */ H5R_DATASET_REGION, /*Dataset Region Reference */ + H5R_ATTR, /*Attribute reference */ + H5R_OBJECT_EXT, /*External Object reference */ + H5R_DATASET_REGION_EXT, /*External Dataset Region Reference */ + H5R_ATTR_EXT, /*External Attribute reference */ H5R_MAXTYPE /*highest type (Invalid as true type) */ } H5R_type_t; diff --git a/src/H5VLiod.c b/src/H5VLiod.c index b4c1871..70057f6 100644 --- a/src/H5VLiod.c +++ b/src/H5VLiod.c @@ -147,7 +147,6 @@ static herr_t H5VL_iod_attribute_close(void *attr, hid_t dxpl_id, void **req); static void *H5VL_iod_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); static void *H5VL_iod_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); static herr_t H5VL_iod_datatype_get(void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_iod_datatype_close(void *dt, hid_t dxpl_id, void **req); /* Dataset callbacks */ static void *H5VL_iod_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); @@ -159,7 +158,6 @@ static herr_t H5VL_iod_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_sp static herr_t H5VL_iod_dataset_specific(void *_dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); static herr_t H5VL_iod_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_iod_dataset_close(void *dset, hid_t dxpl_id, void **req); /* File callbacks */ static void *H5VL_iod_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); @@ -171,7 +169,6 @@ static herr_t H5VL_iod_file_close(void *file, hid_t dxpl_id, void **req); static void *H5VL_iod_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); static void *H5VL_iod_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); static herr_t H5VL_iod_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_iod_group_close(void *grp, hid_t dxpl_id, void **req); /* Link callbacks */ static herr_t H5VL_iod_link_create(H5VL_link_create_type_t create_type, void *obj, @@ -1959,7 +1956,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5VL_iod_group_close(void *_grp, hid_t H5_ATTR_UNUSED dxpl_id, void **req) { H5VL_iod_group_t *grp = (H5VL_iod_group_t *)_grp; @@ -3116,7 +3113,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5VL_iod_dataset_close(void *_dset, hid_t H5_ATTR_UNUSED dxpl_id, void **req) { H5VL_iod_dset_t *dset = (H5VL_iod_dset_t *)_dset; @@ -3573,7 +3570,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5VL_iod_datatype_close(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void **req) { H5VL_iod_dtype_t *dtype = (H5VL_iod_dtype_t *)obj; @@ -6240,7 +6237,6 @@ H5VL_iod_get_token(void *_obj, void *token, size_t *token_size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if(H5P__encode(plist, TRUE, NULL, &plist_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode plist") - *token_size += dt_size + plist_size + sizeof(size_t)*2; break; diff --git a/src/H5VLiod_client.h b/src/H5VLiod_client.h index 5388d71..dc6be2f 100644 --- a/src/H5VLiod_client.h +++ b/src/H5VLiod_client.h @@ -512,5 +512,8 @@ H5_DLL herr_t H5VL_iod_dataset_get_index_info(void *dset, size_t *count, H5_DLL herr_t H5VL_iod_dataset_remove_index_info(void *dset, hid_t trans_id, void **req); +herr_t H5VL_iod_datatype_close(void *dt, hid_t dxpl_id, void **req); +herr_t H5VL_iod_dataset_close(void *dt, hid_t dxpl_id, void **req); +herr_t H5VL_iod_group_close(void *dt, hid_t dxpl_id, void **req); #endif /* H5_HAVE_EFF */ #endif /* _H5VLiod_client_H */ diff --git a/src/H5VLiod_dtype.c b/src/H5VLiod_dtype.c index c389f52..e05d13c 100644 --- a/src/H5VLiod_dtype.c +++ b/src/H5VLiod_dtype.c @@ -430,10 +430,17 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t H5_ATTR_UNUSED axe_engine, file_desc->frag[0].offset = 0; file_desc->frag[0].len = (iod_size_t)buf_size; - /* read the serialized type value from the BLOB object */ - ret = iod_blob_read(dtype_oh.rd_oh, rtid, NULL, mem_desc, file_desc, &blob_cs, NULL); - if(ret < 0) - HGOTO_ERROR_FF(ret, "unable to read from BLOB object"); + if(cs_scope & H5_CHECKSUM_IOD) { + /* read the serialized type value from the BLOB object */ + ret = iod_blob_read(dtype_oh.rd_oh, rtid, NULL, mem_desc, file_desc, &blob_cs, NULL); + if(ret < 0) + HGOTO_ERROR_FF(ret, "unable to read from BLOB object"); + } + else { + ret = iod_blob_read(dtype_oh.rd_oh, rtid, NULL, mem_desc, file_desc, NULL, NULL); + if(ret < 0) + HGOTO_ERROR_FF(ret, "unable to read from BLOB object"); + } if(blob_cs && (cs_scope & H5_CHECKSUM_IOD)) { /* calculate a checksum for the datatype */ diff --git a/src/H5VLiod_obj.c b/src/H5VLiod_obj.c index 247459d..1afb5bb 100644 --- a/src/H5VLiod_obj.c +++ b/src/H5VLiod_obj.c @@ -257,12 +257,20 @@ H5VL_iod_server_object_open_cb(AXE_engine_t H5_ATTR_UNUSED axe_engine, file_desc->frag[0].offset = 0; file_desc->frag[0].len = (iod_size_t)buf_size; - /* read the serialized type value from the BLOB object */ - ret = iod_blob_read(obj_oh.rd_oh, rtid, NULL, mem_desc, file_desc, - &blob_cs, NULL); - if(ret < 0) - HGOTO_ERROR_FF(ret, "unable to read BLOB object"); - + if(cs_scope & H5_CHECKSUM_IOD) { + /* read the serialized type value from the BLOB object */ + ret = iod_blob_read(obj_oh.rd_oh, rtid, NULL, mem_desc, file_desc, + &blob_cs, NULL); + if(ret < 0) + HGOTO_ERROR_FF(ret, "unable to read BLOB object"); + } + else { + /* read the serialized type value from the BLOB object */ + ret = iod_blob_read(obj_oh.rd_oh, rtid, NULL, mem_desc, file_desc, + NULL, NULL); + if(ret < 0) + HGOTO_ERROR_FF(ret, "unable to read BLOB object"); + } if(blob_cs && (cs_scope & H5_CHECKSUM_IOD)) { /* calculate a checksum for the datatype */ dt_cs = H5_checksum_crc64(buf, buf_size); diff --git a/src/Makefile.am b/src/Makefile.am index 1615d51..0d44e02 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,7 +67,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5FD.c H5FDcore.c \ H5FDfamily.c H5FDint.c H5FDlog.c \ H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ - H5FF.c H5ES.c H5RC.c H5TR.c H5M.c H5AS.c H5V.c\ + H5FF.c H5FF_ref.c H5ES.c H5RC.c H5TR.c H5M.c H5AS.c H5V.c\ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c H5FSstat.c H5FStest.c \ H5G.c H5Gbtree2.c H5Gcache.c \ H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \ |