From 3d32d25d8fe666bddff0717dd67952f2602d80ab Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 29 Mar 2012 13:28:40 -0500 Subject: [svn-r22193] - add VOL callback for H5Dset_extent --- src/H5D.c | 10 +++------- src/H5VL.c | 39 +++++++++++++++++++++++++++++++++++++++ src/H5VLdummy.c | 1 + src/H5VLnative.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ src/H5VLprivate.h | 1 + src/H5VLpublic.h | 1 + 6 files changed, 88 insertions(+), 13 deletions(-) diff --git a/src/H5D.c b/src/H5D.c index e4f7dbb..6263804 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -808,21 +808,17 @@ done: herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]) { - H5D_t *dset; /* Dataset for this operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); - /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") - /* Private function */ - if(H5D_set_extent(dset, size, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset") + /* set the extent through the VOL */ + if((ret_value = H5VL_dataset_set_extent(dset_id, size)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5VL.c b/src/H5VL.c index 0e2bf88..83546de 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -1497,6 +1497,45 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_dataset_set_extent + * + * Purpose: Modifies the dimensions of a dataset + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_dataset_set_extent(hid_t uid, const hsize_t size[]) +{ + H5VL_id_wrapper_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check/fix arguments. */ + if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->dataset_cls.set_extent) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset set_extent' method") + if((ret_value = (uid_info->vol_plugin->dataset_cls.set_extent)(uid_info->obj_id, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "set_extent failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_set_extent() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_dataset_get * * Purpose: Get specific information about the dataset through the VOL diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index 3444919..c015dfe 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -82,6 +82,7 @@ H5VL_class_t H5VL_dummy_g = { NULL, NULL, NULL, + NULL, NULL }, { /* group_cls */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index f3cb2ae..e833a65 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -56,23 +56,25 @@ static hid_t H5VL_NATIVE_g = 0; /* Prototypes */ static herr_t H5VL_native_term(void); -static hid_t H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id); -static herr_t H5VL_native_file_close(hid_t fid); + static hid_t H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +static hid_t H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id); static herr_t H5VL_native_file_flush(hid_t fid, H5F_scope_t scope); static herr_t H5VL_native_file_get(hid_t file_id, H5VL_file_get_t get_type, int num_args, va_list arguments); +static herr_t H5VL_native_file_close(hid_t fid); static hid_t H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); static hid_t H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id); -static herr_t H5VL_native_dataset_close(hid_t dataset_id); static herr_t H5VL_native_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf); static herr_t H5VL_native_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf); +static herr_t H5VL_native_dataset_set_extent(hid_t dset_id, const hsize_t size[]); static herr_t H5VL_native_dataset_get(hid_t id, H5VL_dataset_get_t get_type, int num_args, va_list arguments); +static herr_t H5VL_native_dataset_close(hid_t dataset_id); static herr_t H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); @@ -81,16 +83,16 @@ static hid_t H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tap static hid_t H5VL_native_group_create(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); static hid_t H5VL_native_group_open(hid_t loc_id, const char *name, hid_t gapl_id); -static herr_t H5VL_native_group_close(hid_t group_id); static herr_t H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, int num_args, va_list arguments); +static herr_t H5VL_native_group_close(hid_t group_id); static hid_t H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id); -static herr_t H5VL_native_object_close(hid_t object_id); static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, int num_args, va_list arguments); static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, int num_args, va_list arguments); +static herr_t H5VL_native_object_close(hid_t object_id); H5VL_class_t H5VL_native_g = { "native", /* name */ @@ -113,6 +115,7 @@ H5VL_class_t H5VL_native_g = { H5VL_native_dataset_open, /* open */ H5VL_native_dataset_read, /* read */ H5VL_native_dataset_write, /* write */ + H5VL_native_dataset_set_extent, /* set extent */ H5VL_native_dataset_get, /* get */ H5VL_native_dataset_close /* close */ }, @@ -1654,9 +1657,43 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_set_extent + * + * Purpose: Set Extent of dataset + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_set_extent(hid_t dset_id, const hsize_t size[]) +{ + H5D_t *dset = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + + /* Private function */ + if(H5D_set_extent(dset, size, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_set_extent() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_native_dataset_get * - * Purpose: Gets certain data about a file + * Purpose: Gets certain information about a dataset * * Return: Success: 0 * Failure: -1 diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index ac7c1d2..6e86b7c 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -66,6 +66,7 @@ H5_DLL hid_t H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id); H5_DLL herr_t H5VL_dataset_close(hid_t uid); H5_DLL herr_t H5VL_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf); H5_DLL herr_t H5VL_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf); +H5_DLL herr_t H5VL_dataset_set_extent(hid_t uid, const hsize_t size[]); H5_DLL herr_t H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, int num_args, ...); H5_DLL herr_t H5VL_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 1702148..cb23f62 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -93,6 +93,7 @@ typedef struct H5VL_dataset_class_t { hid_t xfer_plist_id, void * buf); herr_t (*write) (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void * buf ); + herr_t (*set_extent) (hid_t uid, const hsize_t size[]); herr_t (*get) (hid_t file_id, H5VL_dataset_get_t get_type, int num_args, va_list arguments); herr_t (*close) (hid_t dataset_id); } H5VL_dataset_class_t; -- cgit v0.12