From 1c06cb8e57b4c96b16c05dea6c6e75c44f84f388 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Wed, 8 Feb 2017 16:25:44 -0600 Subject: Add support for H5Dget_space, H5Dget_type, H5Dget_access_plist, and H5Dget_create_plist. H5Dget_space_status returns not allocated, as in the FF1 plugin. Added tests for the first four functions to h5dsm_dset_open.c --- examples/h5dsm_dset_open.c | 65 ++++++++++++++++++++++++++++++++++- src/H5VLdaosm.c | 84 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 145 insertions(+), 4 deletions(-) diff --git a/examples/h5dsm_dset_open.c b/examples/h5dsm_dset_open.c index b5b1def..2c67497 100644 --- a/examples/h5dsm_dset_open.c +++ b/examples/h5dsm_dset_open.c @@ -3,7 +3,10 @@ int main(int argc, char *argv[]) { uuid_t pool_uuid; char *pool_grp = NULL; - hid_t file = -1, dset = -1, fapl = -1; + hid_t file = -1, dset = -1, fapl = -1, space = -1, type = -1, dcpl = -1, dapl = -1, def_dcpl = -1, def_dapl = -1; + int ndims; + hsize_t dims[2]; + htri_t tri_ret; H5VL_daosm_snap_id_t snap_id; (void)MPI_Init(&argc, &argv); @@ -40,6 +43,48 @@ int main(int argc, char *argv[]) { if((dset = H5Dopen2(file, argv[3], H5P_DEFAULT)) < 0) ERROR; + /* Check dataset dataspace */ + if((space = H5Dget_space(dset)) < 0) + ERROR; + if((ndims = H5Sget_simple_extent_ndims(space)) < 0) + ERROR; + if(ndims != 2) + PRINTF_ERROR("ndims == %d, expected 2\n", ndims); + if(H5Sget_simple_extent_dims(space, dims, NULL) < 0) + ERROR; + if(dims[0] != 4) + PRINTF_ERROR("dims[0] == %d, expected 4\n", (int)dims[0]); + if(dims[1] != 6) + PRINTF_ERROR("dims[1] == %d, expected 6\n", (int)dims[1]); + + /* Check dataset datatype */ + if((type = H5Dget_type(dset)) < 0) + ERROR; + if((tri_ret = H5Tequal(type, H5T_NATIVE_INT)) < 0) + ERROR; + if(!tri_ret) + PRINTF_ERROR("datatype does not equal H5T_NATIVE_INT\n"); + + /* Check DCPL */ + if((dcpl = H5Dget_create_plist(dset)) < 0) + ERROR; + if((def_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + ERROR; + if((tri_ret = H5Pequal(dcpl, def_dcpl)) < 0) + ERROR; + if(!tri_ret) + PRINTF_ERROR("DCPL does not equal default\n"); + + /* Check DAPL */ + if((dapl = H5Dget_access_plist(dset)) < 0) + ERROR; + if((def_dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + ERROR; + if((tri_ret = H5Pequal(dapl, def_dapl)) < 0) + ERROR; + if(!tri_ret) + PRINTF_ERROR("DAPL does not equal default\n"); + /* Close */ if(H5Dclose(dset) < 0) ERROR; @@ -47,6 +92,18 @@ int main(int argc, char *argv[]) { ERROR; if(H5Pclose(fapl) < 0) ERROR; + if(H5Sclose(space) < 0) + ERROR; + if(H5Tclose(type) < 0) + ERROR; + if(H5Pclose(dcpl) < 0) + ERROR; + if(H5Pclose(dapl) < 0) + ERROR; + if(H5Pclose(def_dcpl) < 0) + ERROR; + if(H5Pclose(def_dapl) < 0) + ERROR; printf("Success\n"); @@ -59,6 +116,12 @@ error: H5Dclose(dset); H5Fclose(file); H5Pclose(fapl); + H5Sclose(space); + H5Tclose(type); + H5Pclose(dcpl); + H5Pclose(dapl); + H5Pclose(def_dcpl); + H5Pclose(def_dapl); } H5E_END_TRY; (void)daos_fini(); diff --git a/src/H5VLdaosm.c b/src/H5VLdaosm.c index 041d1a3..5338398 100644 --- a/src/H5VLdaosm.c +++ b/src/H5VLdaosm.c @@ -87,8 +87,9 @@ static herr_t H5VL_daosm_dataset_write(void *_dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); /*static herr_t H5VL_daosm_dataset_specific(void *_dset, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_daosm_dataset_get(void *_dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);*/ + hid_t dxpl_id, void **req, va_list arguments);*/ +static herr_t H5VL_daosm_dataset_get(void *_dset, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); static herr_t H5VL_daosm_dataset_close(void *_dset, hid_t dxpl_id, void **req); /* Datatype callbacks */ @@ -166,7 +167,7 @@ static H5VL_class_t H5VL_daosm_g = { H5VL_daosm_dataset_open, /* open */ H5VL_daosm_dataset_read, /* read */ H5VL_daosm_dataset_write, /* write */ - NULL,//H5VL_iod_dataset_get, /* get */ + H5VL_daosm_dataset_get, /* get */ NULL,//H5VL_iod_dataset_specific, /* specific */ NULL, /* optional */ H5VL_daosm_dataset_close /* close */ @@ -2904,6 +2905,83 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_daosm_dataset_get + * + * Purpose: Gets certain information about a dataset + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Neil Fortner + * February, 2017 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_daosm_dataset_get(void *_dset, H5VL_dataset_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_daosm_dset_t *dset = (H5VL_daosm_dset_t *)_dset; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch (get_type) { + case H5VL_DATASET_GET_DCPL: + { + hid_t *plist_id = va_arg(arguments, hid_t *); + + /* Retrieve the file's access property list */ + if((*plist_id = H5Pcopy(dset->dcpl_id)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dset creation property list") + + break; + } + case H5VL_DATASET_GET_DAPL: + { + hid_t *plist_id = va_arg(arguments, hid_t *); + + /* Retrieve the file's access property list */ + if((*plist_id = H5Pcopy(dset->dapl_id)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dset access property list") + + break; + } + case H5VL_DATASET_GET_SPACE: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + + if((*ret_id = H5Scopy(dset->space_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get dataspace ID of dataset"); + break; + } + case H5VL_DATASET_GET_SPACE_STATUS: + { + H5D_space_status_t *allocation = va_arg(arguments, H5D_space_status_t *); + + *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; + break; + } + case H5VL_DATASET_GET_TYPE: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + + if((*ret_id = H5Tcopy(dset->type_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + break; + } + case H5VL_DATASET_GET_STORAGE_SIZE: + case H5VL_DATASET_GET_OFFSET: + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_daosm_dataset_get() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_daosm_dataset_close * * Purpose: Closes a daos-m HDF5 dataset. -- cgit v0.12