From c0bba7e67c5b3aab4debf5e44a0ca3527dc4f7af Mon Sep 17 00:00:00 2001 From: Jerome Soumagne Date: Wed, 16 Mar 2016 11:21:18 -0500 Subject: Start modifications to H5X to support metadata indexing --- src/H5Dint.c | 16 ++++++------ src/H5Dio.c | 12 ++++----- src/H5Oidxinfo.c | 4 +-- src/H5X.c | 4 +-- src/H5Xdummy.c | 4 ++- src/H5Xfastbit.c | 4 ++- src/H5Xpublic.h | 76 ++++++++++++++++++++++++++++++++++++-------------------- 7 files changed, 73 insertions(+), 47 deletions(-) diff --git a/src/H5Dint.c b/src/H5Dint.c index f3927e2..f84bdb7 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -3253,9 +3253,9 @@ H5D_open_index(H5D_t *dset, hid_t xapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); if (NULL == metadata) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "no index metadata was found"); - if (NULL == idx_class->open) + if (NULL == idx_class->idx_class.data_class.open) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin open callback not defined"); - if (NULL == (idx_handle = idx_class->open(dset_id, xapl_id, metadata_size, metadata))) + if (NULL == (idx_handle = idx_class->idx_class.data_class.open(dset_id, xapl_id, metadata_size, metadata))) HGOTO_ERROR(H5E_INDEX, H5E_CANTOPENOBJ, FAIL, "cannot open index"); dset->shared->idx_handle = idx_handle; @@ -3285,9 +3285,9 @@ H5D_close_index(H5D_t *dset) HDassert(dset); idx_class = dset->shared->idx_class; - if (NULL == (idx_class->close)) + if (NULL == (idx_class->idx_class.data_class.close)) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin close callback not defined"); - if (FAIL == idx_class->close(dset->shared->idx_handle)) + if (FAIL == idx_class->idx_class.data_class.close(dset->shared->idx_handle)) HGOTO_ERROR(H5E_INDEX, H5E_CANTCLOSEOBJ, FAIL, "cannot close index"); dset->shared->idx_handle = NULL; @@ -3357,11 +3357,11 @@ herr_t H5D_get_index_size(H5D_t *dset, hsize_t *idx_size) idx_class = dset->shared->idx_class; if (!idx_class) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "index class not defined"); - if (NULL == (idx_class->get_size)) + if (NULL == (idx_class->idx_class.data_class.get_size)) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin get size callback not defined"); if (!dset->shared->idx_handle && (FAIL == H5D_open_index(dset, xapl_id))) HGOTO_ERROR(H5E_INDEX, H5E_CANTOPENOBJ, FAIL, "cannot open index"); - if (FAIL == idx_class->get_size(dset->shared->idx_handle, &actual_size)) + if (FAIL == idx_class->idx_class.data_class.get_size(dset->shared->idx_handle, &actual_size)) HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "cannot get index size"); *idx_size = actual_size; @@ -3469,7 +3469,7 @@ H5D__query_singleton(H5D_t *dset, const H5S_t *file_space, const H5Q_t *query, if (idx_class) { /* Index associated to dataset so use it */ - if (NULL == idx_class->query) + if (NULL == idx_class->idx_class.data_class.query) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, NULL, "plugin query callback not defined"); /* Open index if not opened yet */ @@ -3481,7 +3481,7 @@ H5D__query_singleton(H5D_t *dset, const H5S_t *file_space, const H5Q_t *query, HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to register dataspace"); /* Call plugin query */ - if (FAIL == (space_id = idx_class->query(dset->shared->idx_handle, file_space_id, query->query_id, xxpl_id))) + if (FAIL == (space_id = idx_class->idx_class.data_class.query(dset->shared->idx_handle, file_space_id, query->query_id, xxpl_id))) HGOTO_ERROR(H5E_INDEX, H5E_CANTSELECT, NULL, "cannot query index"); if (NULL == (ret_value = (H5S_t *) H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace"); diff --git a/src/H5Dio.c b/src/H5Dio.c index cfbcb9e..4c6e413 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -239,8 +239,8 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, void *idx_handle = dset->shared->idx_handle; hid_t xxpl_id = H5P_INDEX_XFER_DEFAULT; - if (idx_class->pre_update && - (FAIL == idx_class->pre_update(idx_handle, file_space_id, xxpl_id))) + if (idx_class->idx_class.data_class.pre_update && + (FAIL == idx_class->idx_class.data_class.pre_update(idx_handle, file_space_id, xxpl_id))) HGOTO_ERROR(H5E_INDEX, H5E_CANTUPDATE, FAIL, "cannot do an index pre-update"); } @@ -284,19 +284,19 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, void *idx_handle = dset->shared->idx_handle; hid_t xxpl_id = H5P_INDEX_XFER_DEFAULT; - if (idx_class->post_update && - (FAIL == idx_class->post_update(idx_handle, buf, file_space_id, xxpl_id))) + if (idx_class->idx_class.data_class.post_update && + (FAIL == idx_class->idx_class.data_class.post_update(idx_handle, buf, file_space_id, xxpl_id))) HGOTO_ERROR(H5E_INDEX, H5E_CANTUPDATE, FAIL, "cannot do an index post-update"); /* Calling post_update rebuilds the index and index metadata may need * to be refreshed. */ - if (idx_class->refresh) { + if (idx_class->idx_class.data_class.refresh) { H5O_idxinfo_t idx_info; void *metadata; size_t metadata_size; - if (FAIL == idx_class->refresh(idx_handle, &metadata_size, &metadata)) + if (FAIL == idx_class->idx_class.data_class.refresh(idx_handle, &metadata_size, &metadata)) HGOTO_ERROR(H5E_INDEX, H5E_CANTUPDATE, FAIL, "cannot do an index refresh"); /* Write the index header message */ diff --git a/src/H5Oidxinfo.c b/src/H5Oidxinfo.c index e1bf2eb..fafb31a 100644 --- a/src/H5Oidxinfo.c +++ b/src/H5Oidxinfo.c @@ -317,9 +317,9 @@ H5O_idxinfo_delete(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t *open_oh, void /* call plugin index remove callback */ if (NULL == (idx_class = H5X_registered(mesg->plugin_id))) HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, FAIL, "can't get index plugin class"); - if (NULL == idx_class->remove) + if (NULL == idx_class->idx_class.data_class.remove) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin remove callback is not defined"); - if (FAIL == idx_class->remove(file_id, mesg->metadata_size, mesg->metadata)) + if (FAIL == idx_class->idx_class.data_class.remove(file_id, mesg->metadata_size, mesg->metadata)) HGOTO_ERROR(H5E_INDEX, H5E_CANTCREATE, FAIL, "cannot remove index"); done: diff --git a/src/H5X.c b/src/H5X.c index a56496e..f35e22f 100644 --- a/src/H5X.c +++ b/src/H5X.c @@ -503,9 +503,9 @@ H5X_create(hid_t dset_id, unsigned plugin_id, hid_t xcpl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); /* Call create of the plugin */ - if (NULL == idx_class->create) + if (NULL == idx_class->idx_class.data_class.create) HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin create callback is not defined"); - if (NULL == (idx_handle = idx_class->create(dset_id, xcpl_id, xapl_id, + if (NULL == (idx_handle = idx_class->idx_class.data_class.create(dset_id, xcpl_id, xapl_id, &metadata_size, &metadata))) HGOTO_ERROR(H5E_INDEX, H5E_CANTCREATE, FAIL, "cannot create new plugin index"); diff --git a/src/H5Xdummy.c b/src/H5Xdummy.c index 3f9a682..4b22c74 100644 --- a/src/H5Xdummy.c +++ b/src/H5Xdummy.c @@ -119,7 +119,8 @@ const H5X_class_t H5X_DUMMY[1] = {{ H5X_CLASS_T_VERS, /* (From the H5Xpublic.h header file) */ H5X_PLUGIN_DUMMY, /* (Or whatever number is assigned) */ "dummy index plugin", /* Whatever name desired */ - H5X_TYPE_DATA_ELEM, /* This plugin operates on dataset elements */ + H5X_TYPE_DATA, /* This plugin operates on dataset elements */ + { H5X_dummy_create, /* create */ H5X_dummy_remove, /* remove */ H5X_dummy_open, /* open */ @@ -130,6 +131,7 @@ const H5X_class_t H5X_DUMMY[1] = {{ NULL, /* refresh */ NULL, /* copy */ H5X_dummy_get_size /* get_size */ + } }}; /*------------------------------------------------------------------------- diff --git a/src/H5Xfastbit.c b/src/H5Xfastbit.c index 89ad3d6..9562824 100644 --- a/src/H5Xfastbit.c +++ b/src/H5Xfastbit.c @@ -192,7 +192,8 @@ const H5X_class_t H5X_FASTBIT[1] = {{ H5X_CLASS_T_VERS, /* (From the H5Xpublic.h header file) */ H5X_PLUGIN_FASTBIT, /* (Or whatever number is assigned) */ "FASTBIT index plugin", /* Whatever name desired */ - H5X_TYPE_DATA_ELEM, /* This plugin operates on dataset elements */ + H5X_TYPE_DATA, /* This plugin operates on dataset elements */ + { H5X_fastbit_create, /* create */ H5X_fastbit_remove, /* remove */ H5X_fastbit_open, /* open */ @@ -203,6 +204,7 @@ const H5X_class_t H5X_FASTBIT[1] = {{ H5X_fastbit_refresh, /* refresh */ NULL, /* copy */ H5X_fastbit_get_size /* get_size */ + } }}; /*------------------------------------------------------------------------- diff --git a/src/H5Xpublic.h b/src/H5Xpublic.h index 9b9e495..c85a8cd 100644 --- a/src/H5Xpublic.h +++ b/src/H5Xpublic.h @@ -22,6 +22,8 @@ /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" +#include "H5Qpublic.h" +#include "H5Rpublic.h" /*****************/ /* Public Macros */ @@ -47,10 +49,8 @@ /* Index type */ typedef enum { - H5X_TYPE_LINK_NAME, /* Link name index */ - H5X_TYPE_ATTR_NAME, /* Attribute name index */ - H5X_TYPE_DATA_ELEM, /* Dataset element index */ - H5X_TYPE_MAP_VALUE /* Map value index */ + H5X_TYPE_DATA, /* Data index */ + H5X_TYPE_METADATA /* Metadata index */ } H5X_type_t; typedef struct { @@ -58,30 +58,57 @@ typedef struct { unsigned plugin_id; } H5X_info_t; +/* Data index class */ typedef struct { - unsigned version; /* Version number of the index plugin class struct */ - /* (Should always be set to H5X_CLASS_VERSION, which - * may vary between releases of HDF5 library) */ - unsigned id; /* Index ID (assigned by The HDF Group, for now) */ - const char *idx_name; /* Index name (for debugging only, currently) */ - H5X_type_t type; /* Type of data indexed by this plugin */ - - /* Callbacks, described above */ - void * (*create)(hid_t dataset_id, hid_t xcpl_id /* TODO pass datatype id */, - hid_t xapl_id, size_t *metadata_size, void **metadata); + void *(*create)(hid_t dataset_id, hid_t xcpl_id, hid_t xapl_id, + size_t *metadata_size, void **metadata); /* TODO pass datatype id */ herr_t (*remove)(hid_t file_id, size_t metadata_size, void *metadata); void *(*open)(hid_t dataset_id, hid_t xapl_id, size_t metadata_size, - void *metadata); + void *metadata); herr_t (*close)(void *idx_handle); herr_t (*pre_update)(void *idx_handle, hid_t dataspace_id, hid_t xxpl_id); herr_t (*post_update)(void *idx_handle, const void *buf, hid_t dataspace_id, - hid_t xxpl_id); - hid_t (*query)(void *idx_handle, hid_t dataspace_id, hid_t query_id, hid_t xxpl_id); + hid_t xxpl_id); + hid_t (*query)(void *idx_handle, hid_t dataspace_id, hid_t query_id, + hid_t xxpl_id); herr_t (*refresh)(void *idx_handle, size_t *metadata_size, void **metadata); herr_t (*copy)(hid_t src_file_id, hid_t dest_file_id, hid_t xcpl_id, hid_t xapl_id, size_t src_metadata_size, void *src_metadata, size_t *dest_metadata_size, void **dest_metadata); herr_t (*get_size)(void *idx_handle, hsize_t *idx_size); +} H5X_data_class_t; + +/* Metadata index class */ +typedef struct { + void *(*create)(hid_t loc_id, hid_t xcpl_id, hid_t xapl_id, + size_t *metadata_size, void **metadata); + herr_t (*remove)(hid_t loc_id, size_t metadata_size, void *metadata); + void *(*open)(hid_t loc_id, hid_t xapl_id, size_t metadata_size, + void *metadata); + herr_t (*close)(void *idx_handle); + herr_t (*insert_entry)(void *idx_handle, hid_t obj_id, H5Q_type_t key_type, + const void *key, size_t key_len, hid_t xxpl_id); + herr_t (*remove_entry)(void *idx_handle, hid_t obj_id, H5Q_type_t key_type, + const void *key, size_t key_len, hid_t xxpl_id); + herr_t (*query)(void *idx_handle, hid_t query_id, hid_t xxpl_id, + size_t *ref_count, href_t *refs[]); + herr_t (*get_size)(void *idx_handle, hsize_t *idx_size); +} H5X_metadata_class_t; + +typedef struct { + unsigned version; /* Version number of the index plugin class struct */ + /* (Should always be set to H5X_CLASS_VERSION, which + * may vary between releases of HDF5 library) */ + unsigned id; /* Index ID (assigned by The HDF Group, for now) */ + const char *idx_name; /* Index name (for debugging only, currently) */ + H5X_type_t type; /* Type of data indexed by this plugin */ + + /* Callbacks */ + union { + /* Union of callback index structures */ + H5X_data_class_t data_class; + H5X_metadata_class_t metadata_class; + } idx_class; } H5X_class_t; /********************/ @@ -98,16 +125,11 @@ extern "C" { /* Function prototypes */ H5_DLL herr_t H5Xregister(const H5X_class_t *idx_class); H5_DLL herr_t H5Xunregister(unsigned plugin_id); - -H5_DLL herr_t H5Xcreate(hid_t scope_id, unsigned plugin_id, hid_t xcpl_id); -H5_DLL herr_t H5Xremove(hid_t scope_id, unsigned n /* Index n to be removed */); - -H5_DLL herr_t H5Xget_count(hid_t scope_id, hsize_t *idx_count); -H5_DLL herr_t H5Xget_info(hid_t scope_id, unsigned n, H5X_info_t *info); - -H5_DLL hsize_t H5Xget_size(hid_t scope_id); - - +H5_DLL herr_t H5Xcreate(hid_t loc_id, unsigned plugin_id, hid_t xcpl_id); +H5_DLL herr_t H5Xremove(hid_t loc_id, unsigned idx /* Index n to be removed */); +H5_DLL herr_t H5Xget_count(hid_t loc_id, hsize_t *idx_count); +H5_DLL herr_t H5Xget_info(hid_t loc_id, unsigned idx, H5X_info_t *info); +H5_DLL hsize_t H5Xget_size(hid_t loc_id); /* H5_DLL herr_t H5Xget_type(hid_t object_id, hsize_t index_idx, -- cgit v0.12