diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2014-11-11 19:59:35 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2016-11-29 23:42:29 (GMT) |
commit | af174b6e765bbfd47eda9138b10976a150893698 (patch) | |
tree | a075d441f213aa0b6d086f4baef7b8e353116446 | |
parent | 57906dab3a85bb4afccf90993cc94d526e8e1ab5 (diff) | |
download | hdf5-af174b6e765bbfd47eda9138b10976a150893698.zip hdf5-af174b6e765bbfd47eda9138b10976a150893698.tar.gz hdf5-af174b6e765bbfd47eda9138b10976a150893698.tar.bz2 |
Add support for H5Xget_size
-rw-r--r-- | src/H5Dint.c | 36 | ||||
-rw-r--r-- | src/H5Dprivate.h | 1 | ||||
-rw-r--r-- | src/H5X.c | 97 | ||||
-rw-r--r-- | src/H5Xdummy.c | 38 | ||||
-rw-r--r-- | src/H5Xprivate.h | 8 | ||||
-rw-r--r-- | src/H5Xpublic.h | 4 |
6 files changed, 176 insertions, 8 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c index 8d47078..daa8a72 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -3211,6 +3211,42 @@ done: } /* end H5D_remove_index() */ /*------------------------------------------------------------------------- + * Function: H5D_get_index_size + * + * Purpose: Get index index. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t H5D_get_index_size(H5D_t *dset, hsize_t *idx_size) +{ + H5X_class_t *idx_class = NULL; + hsize_t actual_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(dset); + HDassert(idx_size); + + if (!dset->shared->idx_handle) + HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "no index attached to dataset"); + + idx_class = dset->shared->idx_class; + if (NULL == (idx_class->get_size)) + HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin get size callback not defined"); + if (FAIL == idx_class->get_size(dset->shared->idx_handle, &actual_size)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "cannot get index size"); + + *idx_size = actual_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_get_index_size() */ + +/*------------------------------------------------------------------------- * Function: H5D__query_index * * Purpose: Returns a dataspace selection of dataset elements that match diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 9c8d358..159a96f 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -180,6 +180,7 @@ H5_DLL herr_t H5D_get_index(H5D_t *dset, unsigned max_count, H5X_class_t **idx_class, void **idx_handle, H5O_idxinfo_t **idx_info, unsigned *actual_count); H5_DLL herr_t H5D_remove_index(H5D_t *dset, unsigned plugin_id); +H5_DLL herr_t H5D_get_index_size(H5D_t *dset, hsize_t *idx_size); /* Functions that operate on vlen data */ H5_DLL herr_t H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id, @@ -482,22 +482,111 @@ done: herr_t H5Xget_count(hid_t scope_id, hsize_t *idx_count) { - H5D_t *dset = NULL; - unsigned actual_count; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", scope_id, idx_count); - if (NULL == (dset = (H5D_t *) H5I_object_verify(scope_id, H5I_DATASET))) + if (NULL == H5I_object_verify(scope_id, H5I_DATASET)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (!idx_count) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_count is NULL"); + + if (FAIL == H5X_get_count(scope_id, idx_count)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "cannot get index count"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xget_count() */ + +/*------------------------------------------------------------------------- + * Function: H5X_get_count + * + * Purpose: Determine the number of index objects on a dataset. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5X_get_count(hid_t dset_id, hsize_t *idx_count) +{ + H5D_t *dset = NULL; + unsigned actual_count; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(dset_id != H5I_BADID); + HDassert(idx_count); + + if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if (FAIL == H5D_get_index(dset, 1, NULL, NULL, NULL, &actual_count)) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin is not registered"); *idx_count = actual_count; done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_get_count() */ + +/*------------------------------------------------------------------------- + * Function: H5Xget_size + * + * Purpose: Returns the amount of storage allocated for an index. + * + * Return: Greater than or equal to zero on success/Zero on failure + * + *------------------------------------------------------------------------- + */ +hsize_t +H5Xget_size(hid_t scope_id) +{ + hsize_t ret_value = 0; /* Return value */ + + FUNC_ENTER_API(0) + + if (NULL == H5I_object_verify(scope_id, H5I_DATASET)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset") + + if (FAIL == H5X_get_size(scope_id, &ret_value)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, 0, "cannot get index storage size"); + +done: FUNC_LEAVE_API(ret_value) -} /* end H5Xget_count() */ +} /* end H5Xget_size() */ + +/*------------------------------------------------------------------------- + * Function: H5X_get_size + * + * Purpose: Returns the amount of storage allocated for an index. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5X_get_size(hid_t dset_id, hsize_t *idx_size) +{ + H5D_t *dset = NULL; + hsize_t actual_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(dset_id != H5I_BADID); + HDassert(idx_size); + + if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + + if (FAIL == H5D_get_index_size(dset, &actual_size)) + HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin is not registered"); + + *idx_size = actual_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_get_size() */ diff --git a/src/H5Xdummy.c b/src/H5Xdummy.c index 1e12848..2ea3b27 100644 --- a/src/H5Xdummy.c +++ b/src/H5Xdummy.c @@ -99,6 +99,9 @@ static herr_t H5X__dummy_get_query_data_cb(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_udata); +static herr_t +H5X_dummy_get_size(void *idx_handle, hsize_t *idx_size); + /*********************/ /* Package Variables */ /*********************/ @@ -126,7 +129,7 @@ const H5X_class_t H5X_DUMMY[1] = {{ H5X_dummy_query, /* query */ NULL, /* refresh */ NULL, /* copy */ - NULL /* get_size */ + H5X_dummy_get_size /* get_size */ }}; /*------------------------------------------------------------------------- @@ -553,3 +556,36 @@ done: H5MM_free(buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5X_dummy_query() */ + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_get_size + * + * Purpose: This function gets the storage size of the index. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5X_dummy_get_size(void *idx_handle, hsize_t *idx_size) +{ + H5X_dummy_t *dummy = (H5X_dummy_t *) idx_handle; + hsize_t size; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + H5X_DUMMY_LOG_DEBUG("Enter"); + + if (NULL == dummy) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL index handle"); + if (!idx_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL pointer"); + + size = H5Dget_storage_size(dummy->idx_anon_id); + + *idx_size = size; + +done: + H5X_DUMMY_LOG_DEBUG("Leave"); + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_get_size */ diff --git a/src/H5Xprivate.h b/src/H5Xprivate.h index 21cd938..6c8fd5b 100644 --- a/src/H5Xprivate.h +++ b/src/H5Xprivate.h @@ -44,9 +44,11 @@ H5_DLL H5X_class_t *H5X_registered(unsigned plugin_id); H5_DLL herr_t H5X_register(const H5X_class_t *index_plugin); H5_DLL herr_t H5X_unregister(unsigned plugin_id); -H5_DLL herr_t H5X_create(hid_t scope_id, unsigned plugin_id, hid_t xcpl_id); -H5_DLL herr_t H5X_remove(hid_t scope_id, unsigned plugin_id); +H5_DLL herr_t H5X_create(hid_t dset_id, unsigned plugin_id, hid_t xcpl_id); +H5_DLL herr_t H5X_remove(hid_t dset_id, unsigned plugin_id); -H5_DLL herr_t H5X_get_count(hid_t scope_id, hsize_t *idx_count); +H5_DLL herr_t H5X_get_count(hid_t dset_id, hsize_t *idx_count); + +H5_DLL herr_t H5X_get_size(hid_t dset_id, hsize_t *idx_size); #endif /* _H5Xprivate_H */ diff --git a/src/H5Xpublic.h b/src/H5Xpublic.h index 9d17aa7..da24fa2 100644 --- a/src/H5Xpublic.h +++ b/src/H5Xpublic.h @@ -100,6 +100,10 @@ H5_DLL herr_t H5Xremove(hid_t scope_id, unsigned plugin_id); H5_DLL herr_t H5Xget_count(hid_t scope_id, hsize_t *idx_count); +H5_DLL hsize_t H5Xget_size(hid_t scope_id); + + + /* H5_DLL herr_t H5Xget_type(hid_t object_id, hsize_t index_idx, unsigned *plugin_id); |