summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2014-03-18 23:48:11 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2014-03-18 23:48:11 (GMT)
commit39fe636db8f4e389b58d213a34b83be175355051 (patch)
tree17736f5d2743364b9ccb221c52538a0651a2f367 /src
parent4be4ca8af6d99f19dde14941c146bd77f332f9e8 (diff)
downloadhdf5-39fe636db8f4e389b58d213a34b83be175355051.zip
hdf5-39fe636db8f4e389b58d213a34b83be175355051.tar.gz
hdf5-39fe636db8f4e389b58d213a34b83be175355051.tar.bz2
[svn-r24836] Modify client_index to create one dataset per process
More implementation of H5Xdummy Check that plugin callbacks are implemented Mores fixes / cleanup
Diffstat (limited to 'src')
-rw-r--r--src/H5FF.c11
-rw-r--r--src/H5V.c2
-rw-r--r--src/H5VLiod_client.c6
-rw-r--r--src/H5X.c47
-rw-r--r--src/H5Xdummy.c110
-rw-r--r--src/H5Xpublic.h1
6 files changed, 137 insertions, 40 deletions
diff --git a/src/H5FF.c b/src/H5FF.c
index fa1acc3..26867bb 100644
--- a/src/H5FF.c
+++ b/src/H5FF.c
@@ -819,6 +819,8 @@ H5Dopen_ff(hid_t loc_id, const char *name, hid_t dapl_id, hid_t rcxt_id, hid_t e
HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "can't get index plugin class");
/* Call open of index plugin */
+ if (NULL == idx_class->open)
+ HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin open callback is not defined");
if (NULL == (idx_handle = idx_class->open(loc_id, ret_value, xapl_id,
metadata_size, metadata)))
HGOTO_ERROR(H5E_INDEX, H5E_CANTOPENOBJ, FAIL, "indexing open callback failed");
@@ -913,7 +915,10 @@ H5Dwrite_ff(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
if (NULL == (idx_class = H5X_registered(plugin_id)))
HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "can't get index plugin class");
- idx_class->pre_update(idx_handle, mem_space_id, xxpl_id);
+ if (NULL == idx_class->pre_update)
+ HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin pre_update callback is not defined");
+ if (FAIL == idx_class->pre_update(idx_handle, mem_space_id, xxpl_id))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTUPDATE, FAIL, "cannot execute index pre_update operation");
}
#endif
@@ -1099,7 +1104,7 @@ H5Dclose_ff(hid_t dset_id, hid_t estack_id)
/*
* Close the index if the dataset is now closed
*/
- if (idx_handle && !H5I_get_ref(dset_id, FALSE)) {
+ if (idx_handle && (FAIL == H5I_get_ref(dset_id, FALSE))) {
H5X_class_t *idx_class = NULL;
unsigned plugin_id;
@@ -1108,6 +1113,8 @@ H5Dclose_ff(hid_t dset_id, hid_t estack_id)
if (NULL == (idx_class = H5X_registered(plugin_id)))
HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "can't get index plugin class");
+ if (NULL == idx_class->close)
+ HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin close callback is not defined");
if (FAIL == idx_class->close(idx_handle))
HGOTO_ERROR(H5E_INDEX, H5E_CANTCLOSEOBJ, FAIL, "cannot close index");
}
diff --git a/src/H5V.c b/src/H5V.c
index 00e2331..bb3bf06 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -366,6 +366,8 @@ H5Vcreate_ff(hid_t loc_id, hid_t query_id, hid_t vcpl_id, hid_t rcxt_id, hid_t e
if (H5P_set(xxpl_plist, H5VL_CONTEXT_ID, &rcxt_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id");
+ if (NULL == idx_class->query)
+ HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin query callback is not defined");
if (FAIL == idx_class->query(idx_handle, query_id, xxpl_id, &dataspace_id))
HGOTO_ERROR(H5E_INDEX, H5E_CANTCLOSEOBJ, FAIL, "cannot close index");
}
diff --git a/src/H5VLiod_client.c b/src/H5VLiod_client.c
index 54d1a07..4fb6b8a 100644
--- a/src/H5VLiod_client.c
+++ b/src/H5VLiod_client.c
@@ -682,11 +682,13 @@ H5VL_iod_request_complete(H5VL_iod_file_t *file, H5VL_iod_request_t *req)
/* Store the transaction ID in the xxpl */
if(NULL == (xxpl_plist = (H5P_genplist_t *)H5I_object(xxpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
if(H5P_set(xxpl_plist, H5VL_TRANS_ID, &info->trans_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id");
/* Call post_update */
+ if (NULL == idx_class->post_update)
+ HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin post_update callback is not defined");
if (FAIL == idx_class->post_update(info->idx_handle,
info->buf, info->dataspace_id, xxpl_id))
HGOTO_ERROR(H5E_INDEX, H5E_CANTUPDATE, FAIL, "unable to issue index post_update operation");
diff --git a/src/H5X.c b/src/H5X.c
index 4123c46..621afcb 100644
--- a/src/H5X.c
+++ b/src/H5X.c
@@ -37,6 +37,7 @@
#include "H5ESprivate.h"
#include "H5FFprivate.h" /* FF */
+#include "H5VLiod_client.h"
#include "H5Xpkg.h" /* Index plugins */
#ifdef H5_HAVE_INDEXING
@@ -189,13 +190,12 @@ H5X_registered(unsigned plugin_id)
H5X_class_t *ret_value = NULL;
size_t plugin_index;
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
if (H5X__registered(plugin_id, &plugin_index)) {
ret_value = &H5X_table_g[plugin_index];
}
-done:
FUNC_LEAVE_NOAPI(ret_value)
}
@@ -474,11 +474,13 @@ H5Xcreate_ff(hid_t file_id, unsigned plugin_id, hid_t scope_id, hid_t xcpl_id,
/* Store the transaction ID in the xapl_id */
if (NULL == (plist = (H5P_genplist_t *)H5I_object(xapl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
if (H5P_set(plist, H5VL_TRANS_ID, &trans_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id");
/* Call create of the plugin */
+ if (NULL == H5X_table_g[plugin_index].create)
+ HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin create callback is not defined");
if (NULL == (idx_handle = H5X_table_g[plugin_index].create(
file_id, dataset_id, xcpl_id, xapl_id, &metadata_size, &metadata)))
HGOTO_ERROR(H5E_INDEX, H5E_CANTCREATE, FAIL, "cannot create new plugin index");
@@ -590,11 +592,13 @@ H5Xremove_ff(hid_t file_id, unsigned plugin_id, hid_t scope_id, hid_t trans_id,
/* Store the transaction ID in the xapl_id */
if (NULL == (plist = (H5P_genplist_t *)H5I_object(xapl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
if (H5P_set(plist, H5VL_TRANS_ID, &trans_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id");
/* Call remove of the plugin */
+ if (NULL == H5X_table_g[plugin_index].remove)
+ HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin remove callback is not defined");
if (FAIL == H5X_table_g[plugin_index].remove(file_id, dataset_id,
metadata_size, metadata))
HGOTO_ERROR(H5E_INDEX, H5E_CANTCREATE, FAIL, "cannot remove index");
@@ -677,7 +681,7 @@ H5Xget_count_ff(hid_t scope_id, hsize_t *idx_count, hid_t rcxt_id,
}
/* Get index info */
- if (FAIL == H5VL_iod_dataset_get_index_info(dset, idx_count, NULL, NULL,
+ if (FAIL == H5VL_iod_dataset_get_index_info(dset, idx_count, NULL, NULL, NULL,
rcxt_id, req))
HGOTO_ERROR(H5E_INDEX, H5E_CANTSET, FAIL, "cannot get indexing info from dataset");
@@ -690,4 +694,33 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Xget_count_ff() */
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_xapl_transaction
+ *
+ * Purpose: Retrieve the transaction ID from this access plist.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_xapl_transaction(hid_t xapl_id, hid_t *trans_id)
+{
+ H5P_genplist_t *plist = NULL; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+
+ if (NULL == (plist = H5P_object_verify(xapl_id, H5P_INDEX_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a xapl");
+
+ /* Get the trans_id */
+ if (trans_id)
+ if (H5P_get(plist, H5VL_TRANS_ID, trans_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value");
+
+done:
+ FUNC_LEAVE_API(ret_value)
+}
+
#endif /* H5_HAVE_INDEXING */
diff --git a/src/H5Xdummy.c b/src/H5Xdummy.c
index 0ad2573..77d2682 100644
--- a/src/H5Xdummy.c
+++ b/src/H5Xdummy.c
@@ -37,37 +37,42 @@
/******************/
/* Local Typedefs */
/******************/
-
+typedef struct H5X_dummy_t {
+ hid_t dataset_id;
+ hid_t idx_anon_id;
+ void *idx_token;
+ size_t idx_token_size;
+} H5X_dummy_t;
/********************/
/* Local Prototypes */
/********************/
static void *
-H5X_dummy_create(hid_t fid, const char *dataset_name, hid_t icpl_id,
- hid_t iapl_id, size_t *metadata_size, void **metadata);
+H5X_dummy_create(hid_t file_id, hid_t dataset_id, hid_t xcpl_id,
+ hid_t xapl_id, size_t *metadata_size, void **metadata);
static herr_t
-H5X_dummy_remove(hid_t fid, const char *dataset_name, size_t metadata_size,
+H5X_dummy_remove(hid_t file_id, hid_t dataset_id, size_t metadata_size,
void *metadata);
static void *
-H5X_dummy_open(hid_t fid, const char *dataset_name, hid_t iapl_id,
+H5X_dummy_open(hid_t file_id, hid_t dataset_id, hid_t xapl_id,
size_t metadata_size, void *metadata);
static herr_t
H5X_dummy_close(void *idx_handle);
static herr_t
-H5X_dummy_pre_update(void *idx_handle, hid_t buffer_dataspace, hid_t ixpl_id);
+H5X_dummy_pre_update(void *idx_handle, hid_t dataspace_id, hid_t xxpl_id);
static herr_t
-H5X_dummy_post_update(void *idx_handle, const void *buffer, hid_t buffer_dataspace,
- hid_t ixpl_id);
+H5X_dummy_post_update(void *idx_handle, const void *buf, hid_t dataspace_id,
+ hid_t xxpl_id);
static herr_t
-H5X_dummy_query(void *idx_handle, hid_t query_id, hid_t idxpl_id,
- hid_t *dataspace_selection_id);
+H5X_dummy_query(void *idx_handle, hid_t query_id, hid_t xxpl_id,
+ hid_t *dataspace_id);
/*********************/
/* Package Variables */
@@ -107,14 +112,48 @@ const H5X_class_t H5X_DUMMY[1] = {
*------------------------------------------------------------------------
*/
static void *
-H5X_dummy_create(hid_t fid, const char *dataset_name, hid_t icpl_id,
- hid_t iapl_id, size_t *metadata_size, void **metadata)
+H5X_dummy_create(hid_t file_id, hid_t dataset_id, hid_t xcpl_id,
+ hid_t xapl_id, size_t *metadata_size, void **metadata)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ H5X_dummy_t *dummy = NULL;
+ hid_t type_id, space_id, trans_id;
+ void *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ printf("Calling H5X_dummy_create\n");
+
+ if (NULL == (dummy = (H5X_dummy_t *) H5MM_malloc(sizeof(H5X_dummy_t))))
+ HGOTO_ERROR(H5E_INDEX, H5E_NOSPACE, NULL, "can't allocate dummy struct");
+
+ dummy->dataset_id = dataset_id;
+
+ if (FAIL == (type_id = H5Dget_type(dataset_id)))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, NULL, "can't get type from dataset");
+ if (FAIL == (space_id = H5Dget_space(dataset_id)))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, NULL, "can't get dataspace from dataset");
+
+ if (FAIL == H5Pget_xapl_transaction(xapl_id, &trans_id))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, NULL, "can't get trans_id from xapl");
+
+ if (FAIL == (dummy->idx_anon_id = H5Dcreate_anon_ff(file_id, type_id, space_id,
+ H5P_DEFAULT, H5P_DEFAULT, trans_id, H5_EVENT_STACK_NULL)))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTCREATE, NULL, "can't create anonymous dataset");
- FUNC_ENTER_NOAPI(FAIL)
+ if (FAIL == H5Oget_token(dummy->idx_anon_id, NULL, &dummy->idx_token_size))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, NULL, "can't get token size for anonymous dataset");
- /* H5Dcreate_anon_ff + H5Oincr_refcount() */
+ if (NULL == (dummy->idx_token = H5MM_malloc(dummy->idx_token_size)))
+ HGOTO_ERROR(H5E_INDEX, H5E_NOSPACE, NULL, "can't allocate token for anonymous dataset");
+
+ if (FAIL == H5Oget_token(dummy->idx_anon_id, dummy->idx_token, &dummy->idx_token_size))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, NULL, "can't get token for anonymous dataset");
+
+ /* Metadata is token for anonymous dataset */
+ *metadata = dummy->idx_token;
+ *metadata_size = dummy->idx_token_size;
+
+ ret_value = dummy;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -130,12 +169,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5X_dummy_remove(hid_t fid, const char *dataset_name, size_t metadata_size,
+H5X_dummy_remove(hid_t file_id, hid_t dataset_id, size_t metadata_size,
void *metadata)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* TODO Does not do anything */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -152,14 +193,15 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5X_dummy_open(hid_t fid, const char *dataset_name, hid_t iapl_id,
+H5X_dummy_open(hid_t file_id, hid_t dataset_id, hid_t xapl_id,
size_t metadata_size, void *metadata)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOINIT
+
+ printf("Calling H5X_dummy_open\n");
- /* H5Oget_info */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5X_dummy_open() */
@@ -176,9 +218,14 @@ done:
static herr_t
H5X_dummy_close(void *idx_handle)
{
+ H5X_dummy_t *dummy = (H5X_dummy_t *) idx_handle;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOINIT
+
+ printf("Calling H5X_dummy_close\n");
+ if (FAIL == H5Dclose_ff(dummy->idx_anon_id))
+ HGOTO_ERROR(H5E_INDEX, H5E_CANTCLOSEOBJ, NULL, "can't close anonymous dataset for index");
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -194,12 +241,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5X_dummy_pre_update(void *idx_handle, hid_t buffer_dataspace, hid_t ixpl_id)
+H5X_dummy_pre_update(void *idx_handle, hid_t dataspace_id, hid_t xxpl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOINIT
+ printf("Calling H5X_dummy_pre_update\n");
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5X_dummy_pre_update() */
@@ -214,12 +262,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5X_dummy_post_update(void *idx_handle, const void *buffer, hid_t buffer_dataspace,
- hid_t ixpl_id)
+H5X_dummy_post_update(void *idx_handle, const void *buf, hid_t dataspace_id,
+ hid_t xxpl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOINIT
+
+ printf("Calling H5X_dummy_post_update\n");
/* Update index elements */
done:
@@ -236,12 +286,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5X_dummy_query(void *idx_handle, hid_t query_id, hid_t idxpl_id,
- hid_t *dataspace_selection_id)
+H5X_dummy_query(void *idx_handle, hid_t query_id, hid_t xxpl_id,
+ hid_t *dataspace_id)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOINIT
+
+ printf("Calling H5X_dummy_query\n");
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Xpublic.h b/src/H5Xpublic.h
index 559ba99..5136f31 100644
--- a/src/H5Xpublic.h
+++ b/src/H5Xpublic.h
@@ -110,6 +110,7 @@ H5_DLL herr_t H5Xget_type(hid_t object_id, hsize_t index_idx,
H5_DLL herr_t H5Xget_type_ff(hid_t object_id, hsize_t index_idx,
unsigned *plugin_id, hid_t rcxt_id, hid_t event_stack_id);
*/
+H5_DLL herr_t H5Pget_xapl_transaction(hid_t xapl_id, hid_t *trans_id);
#ifdef __cplusplus
}