From 4f97ad48d31c747dbf7b833532d5961c4db93b8a Mon Sep 17 00:00:00 2001 From: Jerome Soumagne Date: Thu, 13 Mar 2014 13:33:49 -0500 Subject: Add H5X indexing API Add H5X plugin framework and H5Xdummy plugin basis Add support for index create/remove/open/close/pre_update/post_update inside library Add H5Pxapl/xcpl/xxpl property lists for indexing API Modify library to support H5X term / errors / etc --- config/cmake/H5pubconf.h.in | 3 + src/CMakeLists.txt | 14 + src/H5.c | 5 +- src/H5Pencdec.c | 2 +- src/H5Pint.c | 41 ++- src/H5Pprivate.h | 3 + src/H5Ppublic.h | 12 + src/H5Pxapl.c | 114 ++++++++ src/H5Pxcpl.c | 114 ++++++++ src/H5Pxxpl.c | 114 ++++++++ src/H5X.c | 685 ++++++++++++++++++++++++++++++++++++++++++++ src/H5Xdummy.c | 248 ++++++++++++++++ src/H5Xpkg.h | 33 +++ src/H5Xprivate.h | 60 ++++ src/H5Xpublic.h | 118 ++++++++ src/H5err.txt | 1 + test/index.c | 308 ++++++++++++++++++++ 17 files changed, 1870 insertions(+), 5 deletions(-) create mode 100644 src/H5Pxapl.c create mode 100644 src/H5Pxcpl.c create mode 100644 src/H5Pxxpl.c create mode 100644 src/H5X.c create mode 100644 src/H5Xdummy.c create mode 100644 src/H5Xpkg.h create mode 100644 src/H5Xprivate.h create mode 100644 src/H5Xpublic.h create mode 100644 test/index.c diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 5011b03..8fe53bb 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -227,6 +227,9 @@ /* Define if we have parallel support */ #cmakedefine H5_HAVE_PARALLEL @H5_HAVE_PARALLEL@ +/* Define if we have Indexing support */ +#cmakedefine H5_HAVE_INDEXING @H5_HAVE_INDEXING@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_PTHREAD_H @H5_HAVE_PTHREAD_H@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc95899..cc766d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -629,6 +629,17 @@ set (H5WB_HDRS ) IDE_GENERATED_PROPERTIES ("H5WB" "${H5WB_HDRS}" "${H5WB_SRCS}" ) +set (H5X_SRCS + ${HDF5_SRC_DIR}/H5X.c + ${HDF5_SRC_DIR}/H5Xdummy.c + ${HDF5_SRC_DIR}/H5Pxapl.c + ${HDF5_SRC_DIR}/H5Pxcpl.c + ${HDF5_SRC_DIR}/H5Pxxpl.c +) +set (H5X_HDRS + ${HDF5_SRC_DIR}/H5Xpublic.h +) +IDE_GENERATED_PROPERTIES ("H5X" "${H5X_HDRS}" "${H5X_SRCS}" ) set (H5Z_SRCS ${HDF5_SRC_DIR}/H5Z.c @@ -694,6 +705,7 @@ set (common_SRCS ${H5TS_SRCS} ${H5VM_SRCS} ${H5WB_SRCS} + ${H5X_SRCS} ${H5Z_SRCS} ) @@ -728,6 +740,7 @@ set (H5_PUBLIC_HEADERS ${H5S_HDRS} ${H5SM_HDRS} ${H5T_HDRS} + ${H5X_HDRS} ${H5Z_HDRS} ) @@ -774,6 +787,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5TSprivate.h ${HDF5_SRC_DIR}/H5VMprivate.h ${HDF5_SRC_DIR}/H5WBprivate.h + ${HDF5_SRC_DIR}/H5Xprivate.h ${HDF5_SRC_DIR}/H5Zprivate.h ${HDF5_SRC_DIR}/H5win32defs.h ) diff --git a/src/H5.c b/src/H5.c index 8609b7d..5c390b2 100644 --- a/src/H5.c +++ b/src/H5.c @@ -329,7 +329,10 @@ H5_term_library(void) pending += DOWN(R); pending += DOWN(S); pending += DOWN(T); - } /* end if */ + #ifdef H5_HAVE_INDEXING + pending += DOWN(X); +#endif + } /* end if */ /* Don't shut down "low-level" components until "high-level" components * have successfully shut down. This prevents property lists and IDs diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index 1bcd19c..984513b 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -724,7 +724,7 @@ H5P__decode(const void *buf) /* Get the type of the property list */ type = (H5P_plist_type_t)*p++; - if(type <= H5P_TYPE_USER || type > H5P_TYPE_LINK_ACCESS) + if(type <= H5P_TYPE_USER || type > H5P_TYPE_INDEX_XFER) HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "bad type of encoded information: %u", (unsigned)type) /* Create new property list of the specified type */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 26431eb..ee17289 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -147,6 +147,12 @@ hid_t H5P_CLS_LINK_ACCESS_ID_g = FAIL; H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; hid_t H5P_CLS_STRING_CREATE_ID_g = FAIL; H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; +hid_t H5P_CLS_INDEX_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_INDEX_CREATE_g = NULL; +hid_t H5P_CLS_INDEX_ACCESS_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_INDEX_ACCESS_g = NULL; +hid_t H5P_CLS_INDEX_XFER_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_INDEX_XFER_g = NULL; /* * Predefined property lists for each predefined class. These are initialized @@ -166,6 +172,9 @@ hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = FAIL; hid_t H5P_LST_OBJECT_COPY_ID_g = FAIL; hid_t H5P_LST_LINK_CREATE_ID_g = FAIL; hid_t H5P_LST_LINK_ACCESS_ID_g = FAIL; +hid_t H5P_LST_INDEX_CREATE_ID_g = FAIL; +hid_t H5P_LST_INDEX_ACCESS_ID_g = FAIL; +hid_t H5P_LST_INDEX_XFER_ID_g = FAIL; /* Root property list class library initialization object */ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ @@ -261,7 +270,9 @@ H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */ H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */ H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */ H5_DLLVAR const H5P_libclass_t H5P_CLS_LCRT[1]; /* Link creation */ - +H5_DLLVAR const H5P_libclass_t H5P_CLS_XCRT[1]; /* Index creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_XACC[1]; /* Index access */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_XXFR[1]; /* Index transfer */ /*****************************/ /* Library Private Variables */ @@ -297,6 +308,9 @@ static H5P_libclass_t const * const init_class[] = { H5P_CLS_TCRT, /* Datatype creation */ H5P_CLS_TACC, /* Datatype access */ H5P_CLS_ACRT, /* Attribute creation */ + H5P_CLS_XCRT, /* Index creation */ + H5P_CLS_XACC, /* Index access */ + H5P_CLS_XXFR, /* Index transfer */ H5P_CLS_LCRT /* Link creation */ }; @@ -490,6 +504,9 @@ H5P_term_package(void) H5P_LST_OBJECT_COPY_ID_g = H5P_LST_LINK_CREATE_ID_g = H5P_LST_LINK_ACCESS_ID_g = + H5P_LST_INDEX_CREATE_ID_g = + H5P_LST_INDEX_ACCESS_ID_g = + H5P_LST_INDEX_XFER_ID_g = H5P_LST_FILE_MOUNT_ID_g = (-1); } /* end if */ } /* end if */ @@ -516,6 +533,9 @@ H5P_term_package(void) H5P_CLS_OBJECT_COPY_g = H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = + H5P_CLS_INDEX_CREATE_g = + H5P_CLS_INDEX_ACCESS_g = + H5P_CLS_INDEX_XFER_g = H5P_CLS_FILE_MOUNT_g = NULL; H5P_CLS_ROOT_ID_g = @@ -534,6 +554,9 @@ H5P_term_package(void) H5P_CLS_OBJECT_COPY_ID_g = H5P_CLS_LINK_CREATE_ID_g = H5P_CLS_LINK_ACCESS_ID_g = + H5P_CLS_INDEX_CREATE_ID_g = + H5P_CLS_INDEX_ACCESS_ID_g = + H5P_CLS_INDEX_XFER_ID_g = H5P_CLS_FILE_MOUNT_ID_g = (-1); } /* end if */ } /* end if */ @@ -5253,8 +5276,8 @@ H5P__new_plist_of_type(H5P_plist_type_t type) FUNC_ENTER_PACKAGE /* Sanity checks */ - HDcompile_assert(H5P_TYPE_LINK_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); - HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_LINK_ACCESS); + HDcompile_assert(H5P_TYPE_INDEX_XFER == (H5P_TYPE_MAX_TYPE - 1)); + HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_INDEX_XFER); /* Check arguments */ if(type == H5P_TYPE_USER) @@ -5328,6 +5351,18 @@ H5P__new_plist_of_type(H5P_plist_type_t type) class_id = H5P_CLS_LINK_ACCESS_ID_g; break; + case H5P_TYPE_INDEX_CREATE: + class_id = H5P_CLS_INDEX_CREATE_ID_g; + break; + + case H5P_TYPE_INDEX_ACCESS: + class_id = H5P_CLS_INDEX_ACCESS_ID_g; + break; + + case H5P_TYPE_INDEX_XFER: + class_id = H5P_CLS_INDEX_XFER_ID_g; + break; + case H5P_TYPE_USER: /* shut compiler warnings up */ case H5P_TYPE_ROOT: case H5P_TYPE_MAX_TYPE: diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 05830d1..0b5ca45 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -73,6 +73,9 @@ typedef enum H5P_plist_type_t { H5P_TYPE_OBJECT_COPY = 15, H5P_TYPE_LINK_CREATE = 16, H5P_TYPE_LINK_ACCESS = 17, + H5P_TYPE_INDEX_CREATE = 18, + H5P_TYPE_INDEX_ACCESS = 19, + H5P_TYPE_INDEX_XFER = 20, H5P_TYPE_MAX_TYPE } H5P_plist_type_t; diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 4929621..8babc16 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -69,6 +69,9 @@ #define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) #define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) #define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) +#define H5P_INDEX_CREATE (H5OPEN H5P_CLS_INDEX_CREATE_ID_g) +#define H5P_INDEX_ACCESS (H5OPEN H5P_CLS_INDEX_ACCESS_ID_g) +#define H5P_INDEX_XFER (H5OPEN H5P_CLS_INDEX_XFER_ID_g) /* * The library's default property lists @@ -87,6 +90,9 @@ #define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) #define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) #define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) +#define H5P_INDEX_CREATE_DEFAULT (H5OPEN H5P_LST_INDEX_CREATE_ID_g) +#define H5P_INDEX_ACCESS_DEFAULT (H5OPEN H5P_LST_INDEX_ACCESS_ID_g) +#define H5P_INDEX_XFER_DEFAULT (H5OPEN H5P_LST_INDEX_XFER_ID_g) /* Common creation order flags (for links in groups and attributes on objects) */ #define H5P_CRT_ORDER_TRACKED 0x0001 @@ -192,6 +198,9 @@ H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_ID_g; H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_INDEX_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_INDEX_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_INDEX_XFER_ID_g; /* Default roperty list IDs */ /* (Internal to library, do not use! Use macros above) */ @@ -209,6 +218,9 @@ H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_ID_g; H5_DLLVAR hid_t H5P_LST_LINK_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_INDEX_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_INDEX_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_INDEX_XFER_ID_g; /*********************/ /* Public Prototypes */ diff --git a/src/H5Pxapl.c b/src/H5Pxapl.c new file mode 100644 index 0000000..e899545 --- /dev/null +++ b/src/H5Pxapl.c @@ -0,0 +1,114 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Pxapl.c + * February 2014 + * + * Purpose: Index access property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Xprivate.h" /* Index */ +#include "H5Ppkg.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* ======== Index access properties ======== */ + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__xacc_reg_prop(H5P_genclass_t *pclass); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Index access property list class library initialization object */ +const H5P_libclass_t H5P_CLS_XACC[1] = {{ + "index access", /* Class name for debugging */ + H5P_TYPE_INDEX_ACCESS, /* Class type */ + &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ + &H5P_CLS_INDEX_ACCESS_g, /* Pointer to class ID */ + &H5P_LST_INDEX_ACCESS_g, /* Pointer to default property list ID */ + H5P__xacc_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + +/*------------------------------------------------------------------------- + * Function: H5P__xacc_reg_prop + * + * Purpose: Register the index access property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5P__xacc_reg_prop(H5P_genclass_t *pclass) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__xacc_reg_prop() */ diff --git a/src/H5Pxcpl.c b/src/H5Pxcpl.c new file mode 100644 index 0000000..7281b36 --- /dev/null +++ b/src/H5Pxcpl.c @@ -0,0 +1,114 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Pxcpl.c + * February 2014 + * + * Purpose: Index creation property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Xprivate.h" /* Index */ +#include "H5Ppkg.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* ======== Index creation properties ======== */ + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__xcrt_reg_prop(H5P_genclass_t *pclass); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Index creation property list class library initialization object */ +const H5P_libclass_t H5P_CLS_XCRT[1] = {{ + "index create", /* Class name for debugging */ + H5P_TYPE_INDEX_CREATE, /* Class type */ + &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */ + &H5P_CLS_INDEX_CREATE_g, /* Pointer to class ID */ + &H5P_LST_INDEX_CREATE_g, /* Pointer to default property list ID */ + H5P__xcrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + +/*------------------------------------------------------------------------- + * Function: H5P__xcrt_reg_prop + * + * Purpose: Register the index creation property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5P__xcrt_reg_prop(H5P_genclass_t *pclass) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__xcrt_reg_prop() */ diff --git a/src/H5Pxxpl.c b/src/H5Pxxpl.c new file mode 100644 index 0000000..2fea732 --- /dev/null +++ b/src/H5Pxxpl.c @@ -0,0 +1,114 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Pxxpl.c + * February 2014 + * + * Purpose: Index transfer property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Xprivate.h" /* Index */ +#include "H5Ppkg.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* ======== Index transfer properties ======== */ + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__xxfr_reg_prop(H5P_genclass_t *pclass); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Index access property list class library initialization object */ +const H5P_libclass_t H5P_CLS_XXFR[1] = {{ + "index transfer", /* Class name for debugging */ + H5P_TYPE_INDEX_XFER, /* Class type */ + &H5P_CLS_ROOT_g, /* Parent class ID */ + &H5P_CLS_INDEX_XFER_g, /* Pointer to class ID */ + &H5P_LST_INDEX_XFER_g, /* Pointer to default property list ID */ + H5P__xxfr_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + +/*------------------------------------------------------------------------- + * Function: H5P__xxfr_reg_prop + * + * Purpose: Register the index transfer property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5P__xxfr_reg_prop(H5P_genclass_t *pclass) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__xxfr_reg_prop() */ diff --git a/src/H5X.c b/src/H5X.c new file mode 100644 index 0000000..9ca9289 --- /dev/null +++ b/src/H5X.c @@ -0,0 +1,685 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Index routines. + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5X_PACKAGE /* Suppress error about including H5Xpkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5X_init_interface + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL plugins */ +#include "H5ESprivate.h" + +#include "H5FFprivate.h" /* FF */ +#include "H5Xpkg.h" /* Index plugins */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ +static size_t H5X_table_alloc_g = 0; +static size_t H5X_table_used_g = 0; +static H5X_class_t *H5X_table_g = NULL; + + +static H5_inline hbool_t +H5X__registered(unsigned plugin_id, size_t *index) +{ + size_t plugin_index; + hbool_t registered = FALSE; + + /* Is the filter already registered? */ + for (plugin_index = 0; plugin_index < H5X_table_used_g; plugin_index++) { + if (H5X_table_g[plugin_index].id == plugin_id) { + registered = TRUE; + if (index) *index = plugin_index; + break; + } + } + + return registered; +} + +/*------------------------------------------------------------------------- + * Function: H5X_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5X_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_init() */ + +/*-------------------------------------------------------------------------- +NAME + H5X_init_interface -- Initialize interface-specific information +USAGE + herr_t H5X_init_interface() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. + +--------------------------------------------------------------------------*/ +static herr_t +H5X_init_interface(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + +//#ifdef H5_HAVE_INDEX_PLUGIN_DUMMY + if (H5X_register(H5X_DUMMY) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register dummy index plugin") +//#endif /* H5_HAVE_INDEX_PLUGIN_DUMMY */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_init_interface() */ + +/*-------------------------------------------------------------------------- + NAME + H5X_term_interface + PURPOSE + Terminate various H5X objects + USAGE + void H5X_term_interface() + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Release the atom group and any other resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int +H5X_term_interface(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_interface_initialize_g) { + /* Free the table of filters */ + H5X_table_g = (H5X_class_t *) H5MM_xfree(H5X_table_g); + H5X_table_used_g = H5X_table_alloc_g = 0; + + /* Shut down interface */ + H5_interface_initialize_g = 0; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5X_term_interface() */ + +/*------------------------------------------------------------------------- + * Function: H5X_registered + * + * Purpose: Get registered plugin index class from plugin ID. + * + * Return: Success: pointer to registered index class + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5X_class_t * +H5X_registered(unsigned plugin_id) +{ + H5X_class_t *ret_value = NULL; + size_t plugin_index; + + FUNC_ENTER_NOAPI_NOINIT + + if (H5X__registered(plugin_id, &plugin_index)) { + ret_value = &H5X_table_g[plugin_index]; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + +/*------------------------------------------------------------------------- + * Function: H5Xregister + * + * Purpose: This function registers new index classes. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xregister(const H5X_class_t *index_class) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if (!index_class) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index plugin class"); + if (index_class->version != H5X_CLASS_T_VERS) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index plugin version number"); + if ((index_class->id < 0) || (index_class->id > H5X_PLUGIN_MAX)) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index plugin identification number"); + if (index_class->id < H5X_PLUGIN_RESERVED) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined index plugins"); + + /* Do or do not. There is no try. */ + if (H5X_register(index_class) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register index") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xregister() */ + +/*------------------------------------------------------------------------- + * Function: H5X_register + * + * Purpose: Same as the public version except this one allows plugins + * to be set for predefined method numbers < H5X_INDEX_RESERVED + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5X_register(const H5X_class_t *index_class) +{ + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(index_class); + HDassert(index_class->id >= 0 && index_class->id <= H5X_PLUGIN_MAX); + + /* Is the index class already registered? */ + for (i = 0; i < H5X_table_used_g; i++) + if (H5X_table_g[i].id == index_class->id) + break; + + /* Filter not already registered */ + if (i >= H5X_table_used_g) { + if (H5X_table_used_g >= H5X_table_alloc_g) { + size_t n = MAX(H5X_MAX_NPLUGINS, 2 * H5X_table_alloc_g); + H5X_class_t *table = (H5X_class_t *) H5MM_realloc(H5X_table_g, + n * sizeof(H5X_class_t)); + if(!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend index plugin table"); + H5X_table_g = table; + H5X_table_alloc_g = n; + } /* end if */ + + /* Initialize */ + i = H5X_table_used_g++; + HDmemcpy(H5X_table_g + i, index_class, sizeof(H5X_class_t)); + } /* end if */ + else { /* Filter already registered */ + /* Replace old contents */ + HDmemcpy(H5X_table_g + i, index_class, sizeof(H5X_class_t)); + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_register() */ + +/*------------------------------------------------------------------------- + * Function: H5Xunregister + * + * Purpose: This function unregisters an index class. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xunregister(unsigned plugin_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if ((plugin_id < 0) || (plugin_id > H5X_PLUGIN_MAX)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number"); + if (plugin_id < H5X_PLUGIN_RESERVED) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined index plugins"); + + /* Do it */ + if (H5X_unregister(plugin_id) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister index plugin"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xunregister() */ + +/*------------------------------------------------------------------------- + * Function: H5X_unregister + * + * Purpose: Same as the public version except this one allows plugins + * to be unset for predefined method numbers < H5X_PLUGIN_RESERVED + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5X_unregister(unsigned plugin_id) +{ + size_t plugin_index; /* Local index variable for filter */ +// H5X_object_t object; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert((plugin_id >= 0) && (plugin_id <= H5X_PLUGIN_MAX)); + + /* Is the plugin already registered? */ + if (FALSE == H5X__registered(plugin_id, &plugin_index)) + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "plugin is not registered") + + /* Initialize the structure object for iteration */ +// object.plugin_id = plugin_id; +// object.found = FALSE; + + /* Iterate through all opened datasets, returns a failure if any of them uses the filter */ +// if(H5I_iterate(H5I_DATASET, H5Z__check_unregister_dset_cb, &object, FALSE) < 0) +// HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") + +// if(object.found) +// HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister plugin because a dataset is still using it") + + /* Iterate through all opened groups, returns a failure if any of them uses the filter */ +// if(H5I_iterate(H5I_GROUP, H5Z__check_unregister_group_cb, &object, FALSE) < 0) +// HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") + +// if(object.found) +// HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister plugin because a group is still using it") + + /* Iterate through all opened files and flush them */ +// if(H5I_iterate(H5I_FILE, H5Z__flush_file_cb, NULL, FALSE) < 0) +// HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") + + /* Remove filter from table */ + /* Don't worry about shrinking table size (for now) */ + HDmemmove(&H5X_table_g[plugin_index], &H5X_table_g[plugin_index + 1], + sizeof(H5X_class_t) * ((H5X_table_used_g - 1) - plugin_index)); + + H5X_table_used_g--; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_unregister() */ + +/*------------------------------------------------------------------------- + * Function: H5Xcreate + * + * Purpose: Create a new index in a container. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xcreate(hid_t file_id, unsigned plugin_id, hid_t scope_id, hid_t xcpl_id) +{ + void *file = NULL, *obj = NULL; + H5VL_t *vol_plugin = NULL; /* VOL plugin information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if ((plugin_id < 0) || (plugin_id > H5X_PLUGIN_MAX)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid plugin identification number"); + if (NULL == (file = (void *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID"); + if (NULL == (obj = (void *) H5VL_get_object(scope_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object/file identifier"); + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information"); + + /* TODO */ + /* Call H5VL layer */ +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xcreate() */ + +/*------------------------------------------------------------------------- + * Function: H5Xcreate_ff + * + * Purpose: Create a new index in a container. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xcreate_ff(hid_t file_id, unsigned plugin_id, hid_t scope_id, hid_t xcpl_id, + hid_t trans_id, hid_t estack_id) +{ + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (NULL if VOL plugin does not support async) */ + void *idx_handle = NULL; /* pointer to index object created */ + void *file = NULL, *dset = NULL; + H5VL_t *vol_plugin = NULL; /* VOL plugin information */ + size_t plugin_index; + H5P_genplist_t *plist; + hid_t dataset_id = scope_id; /* TODO for now */ + hid_t xapl_id = H5P_INDEX_ACCESS_DEFAULT; /* TODO for now */ + size_t metadata_size; /* size of metadata created by plugin */ + void *metadata; /* metadata created by plugin that needs to be stored */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if ((plugin_id < 0) || (plugin_id > H5X_PLUGIN_MAX)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid plugin identification number"); + if (NULL == (file = (void *) H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID"); + if (NULL == H5I_object_verify(scope_id, H5I_DATASET)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scope_id is restricted to dataset ID"); + if (NULL == (dset = (void *) H5VL_get_object(scope_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object/file identifier"); + if (NULL == (vol_plugin = (H5VL_t *) H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information"); + + /* Is the plugin already registered */ + if (FALSE == H5X__registered(plugin_id, &plugin_index)) + HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin is not registered"); + + /* Get correct property list */ + if (H5P_DEFAULT == xcpl_id) + xcpl_id = H5P_INDEX_CREATE_DEFAULT; + else + if (TRUE != H5P_isa_class(xcpl_id, H5P_INDEX_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not index creation property list"); + + if (estack_id != H5_EVENT_STACK_NULL) { + /* create the private request */ + if (NULL == (request = (H5_priv_request_t *) H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + vol_plugin->nrefs ++; + } + + /* 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") + 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") + + /* Call create of the plugin */ + 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"); + + /* Add idx_handle to dataset */ + if (FAIL == H5VL_iod_dataset_set_index(dset, idx_handle)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTSET, FAIL, "cannot set index to dataset"); + if (FAIL == H5VL_iod_dataset_set_index_info(dset, plugin_id, + metadata_size, metadata, trans_id, req)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTSET, FAIL, "cannot set index info to dataset"); + + if (request && *req) { + if(H5ES_insert(estack_id, request) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xcreate_ff() */ + +/*------------------------------------------------------------------------- + * Function: H5Xremove + * + * Purpose: Remove an index from objects in a container. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xremove(hid_t file_id, unsigned plugin_id, hid_t scope_id) +{ + void *file = NULL, *obj = NULL; + H5VL_t *vol_plugin = NULL; /* VOL plugin information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if ((plugin_id < 0) || (plugin_id > H5X_PLUGIN_MAX)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid plugin identification number"); + if (NULL == (file = (void *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID"); + if (NULL == (obj = (void *) H5VL_get_object(scope_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object/file identifier"); + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information"); + + /* Call H5VL layer */ +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xremove() */ + +/*------------------------------------------------------------------------- + * Function: H5Xremove_ff + * + * Purpose: Remove an index from objects in a container. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xremove_ff(hid_t file_id, unsigned plugin_id, hid_t scope_id, hid_t trans_id, + hid_t estack_id) +{ + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (NULL if VOL plugin does not support async) */ + void *file = NULL, *dset = NULL; + H5VL_t *vol_plugin = NULL; /* VOL plugin information */ + size_t plugin_index; + H5P_genplist_t *plist; + hid_t dataset_id = scope_id; /* TODO for now */ + hid_t xapl_id = H5P_INDEX_ACCESS_DEFAULT; /* TODO for now */ + size_t metadata_size; /* size of metadata created by plugin */ + void *metadata; /* metadata created by plugin that needs to be stored */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if ((plugin_id < 0) || (plugin_id > H5X_PLUGIN_MAX)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid plugin identification number"); + if (NULL == (file = (void *) H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID"); + if (NULL == H5I_object_verify(scope_id, H5I_DATASET)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scope_id is restricted to dataset ID"); + if (NULL == (dset = (void *) H5VL_get_object(scope_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object/file identifier"); + if (NULL == (vol_plugin = (H5VL_t *) H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information"); + + /* Is the plugin already registered */ + if (FALSE == H5X__registered(plugin_id, &plugin_index)) + HGOTO_ERROR(H5E_INDEX, H5E_BADVALUE, FAIL, "plugin is not registered"); + + if (estack_id != H5_EVENT_STACK_NULL) { + /* create the private request */ + if (NULL == (request = (H5_priv_request_t *) H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + vol_plugin->nrefs ++; + } + + /* Get idx_handle from dataset */ + if (FAIL == H5VL_iod_dataset_get_index_info(dset, &plugin_id, + &metadata_size, &metadata, NULL)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTSET, FAIL, "cannot get index from dataset"); + + /* 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") + 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") + + /* Call remove of the plugin */ + 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"); + + /* Remove idx_handle from dataset */ + if (FAIL == H5VL_iod_dataset_set_index(dset, NULL)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTSET, FAIL, "cannot reset index handle"); + if (FAIL == H5VL_iod_dataset_remove_index_info(dset, trans_id, req)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTSET, FAIL, "cannot remove index from dataset"); + + if (request && *req) { + if(H5ES_insert(estack_id, request) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xremove_ff() */ + +/*------------------------------------------------------------------------- + * Function: H5Xget_count + * + * Purpose: Determine the number of index objects on an object. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xget_count(hid_t scope_id, hsize_t *idx_count) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* TODO if necessary */ +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xget_count() */ + +/*------------------------------------------------------------------------- + * Function: H5Xget_count_ff + * + * Purpose: Determine the number of index objects on an object. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Xget_count_ff(hid_t scope_id, hsize_t *idx_count, hid_t rcxt_id, + hid_t estack_id) +{ + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (NULL if VOL plugin does not support async) */ + void *dset; + H5VL_t *vol_plugin = NULL; /* VOL plugin information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + if (NULL == H5I_object_verify(scope_id, H5I_DATASET)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scope_id is restricted to dataset ID"); + if (NULL == (dset = (void *) H5VL_get_object(scope_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object/file identifier"); + if (!idx_count) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_count is NULL"); + + if (estack_id != H5_EVENT_STACK_NULL) { + /* create the private request */ + if (NULL == (request = (H5_priv_request_t *) H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + vol_plugin->nrefs ++; + } + + if (FAIL == H5VL_iod_dataset_get_index_info(dset, idx_count, NULL, + NULL, NULL, req)) + HGOTO_ERROR(H5E_INDEX, H5E_CANTSET, FAIL, "cannot get indexing info from dataset"); + + if (request && *req) { + if(H5ES_insert(estack_id, request) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Xget_count_ff() */ diff --git a/src/H5Xdummy.c b/src/H5Xdummy.c new file mode 100644 index 0000000..0ad2573 --- /dev/null +++ b/src/H5Xdummy.c @@ -0,0 +1,248 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Dummy index routines. + */ + +/****************/ +/* Module Setup */ +/****************/ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Xprivate.h" /* Index */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* 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); + +static herr_t +H5X_dummy_remove(hid_t fid, const char *dataset_name, size_t metadata_size, + void *metadata); + +static void * +H5X_dummy_open(hid_t fid, const char *dataset_name, hid_t iapl_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); + +static herr_t +H5X_dummy_post_update(void *idx_handle, const void *buffer, hid_t buffer_dataspace, + hid_t ixpl_id); + +static herr_t +H5X_dummy_query(void *idx_handle, hid_t query_id, hid_t idxpl_id, + hid_t *dataspace_selection_id); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Dummy index class */ +const H5X_class_t H5X_DUMMY[1] = { + H5X_CLASS_T_VERS, /* (From the H5Xpublic.h header file) */ + 1, /* (Or whatever number is assigned) */ + "dummy index plugin", /* Whatever name desired */ + H5X_TYPE_DATA_ELEM, /* This plugin operates on dataset elements */ + H5X_dummy_create, /* create */ + H5X_dummy_remove, /* remove */ + H5X_dummy_open, /* open */ + H5X_dummy_close, /* close */ + H5X_dummy_pre_update, /* pre_update */ + H5X_dummy_post_update, /* post_update */ + H5X_dummy_query /* query */ +}; + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_create + * + * Purpose: This function creates a new instance of a dummy plugin index. + * + * Return: Success: Pointer to the new index + * Failure: NULL + * + *------------------------------------------------------------------------ + */ +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) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* H5Dcreate_anon_ff + H5Oincr_refcount() */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_create() */ + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_remove + * + * Purpose: This function removes the dummy plugin index from the file. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5X_dummy_remove(hid_t fid, const char *dataset_name, size_t metadata_size, + void *metadata) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_remove() */ + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_open + * + * Purpose: This function open an already existing dummy index from a file. + * + * Return: Success: Pointer to the index + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5X_dummy_open(hid_t fid, const char *dataset_name, hid_t iapl_id, + size_t metadata_size, void *metadata) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* H5Oget_info */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_open() */ + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_close + * + * Purpose: This function unregisters an index class. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5X_dummy_close(void *idx_handle) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_close() */ + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_pre_update + * + * Purpose: This function unregisters an index class. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5X_dummy_pre_update(void *idx_handle, hid_t buffer_dataspace, hid_t ixpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_pre_update() */ + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_post_update + * + * Purpose: This function unregisters an index class. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5X_dummy_post_update(void *idx_handle, const void *buffer, hid_t buffer_dataspace, + hid_t ixpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Update index elements */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_post_update() */ + +/*------------------------------------------------------------------------- + * Function: H5X_dummy_query + * + * Purpose: This function unregisters an index class. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5X_dummy_query(void *idx_handle, hid_t query_id, hid_t idxpl_id, + hid_t *dataspace_selection_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5X_dummy_query() */ diff --git a/src/H5Xpkg.h b/src/H5Xpkg.h new file mode 100644 index 0000000..eab963e --- /dev/null +++ b/src/H5Xpkg.h @@ -0,0 +1,33 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef H5X_PACKAGE +#error "Do not include this file outside the H5X package!" +#endif + +#ifndef _H5Xpkg_H +#define _H5Xpkg_H + +/* Include private header file */ +#include "H5Xprivate.h" /* Plugin functions */ + +//#ifdef H5_HAVE_INDEX_DUMMY +/* + * Dummy plugin + */ +H5_DLLVAR const H5X_class_t H5X_DUMMY[1]; +//#endif /* H5_HAVE_INDEX_DUMMY */ + +#endif /* _H5Xpkg_H */ + diff --git a/src/H5Xprivate.h b/src/H5Xprivate.h new file mode 100644 index 0000000..2cedab1 --- /dev/null +++ b/src/H5Xprivate.h @@ -0,0 +1,60 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains private information about the H5X module + */ +#ifndef _H5Xprivate_H +#define _H5Xprivate_H + +/* Include package's public header */ +#include "H5Xpublic.h" + +/* Private headers needed by this file */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ +H5_DLL herr_t H5X_init(void); + +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 intex_type); + +H5_DLL herr_t H5X_create(hid_t file_id, unsigned plugin_id, hid_t scope_id, + hid_t xcpl_id); +H5_DLL herr_t H5X_create_ff(hid_t file_id, unsigned plugin_id, + hid_t scope_id, hid_t xcpl_id, hid_t trans_id, hid_t estack_id); + +H5_DLL herr_t H5X_remove(hid_t file_id, unsigned plugin_id, hid_t scope_id); +H5_DLL herr_t H5X_remove_ff(hid_t file_id, unsigned plugin_id, hid_t scope_id, + hid_t trans_id, hid_t estack_id); + +H5_DLL herr_t H5X_get_count(hid_t scope_id, hsize_t *idx_count); +H5_DLL herr_t H5X_get_count_ff(hid_t scope_id, hsize_t *idx_count, hid_t rcxt_id, + hid_t estack_id); + +#endif /* _H5Xprivate_H */ diff --git a/src/H5Xpublic.h b/src/H5Xpublic.h new file mode 100644 index 0000000..559ba99 --- /dev/null +++ b/src/H5Xpublic.h @@ -0,0 +1,118 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains function prototypes for each exported function in the + * H5X module. + */ +#ifndef _H5Xpublic_H +#define _H5Xpublic_H + +/* Public headers needed by this file */ +#include "H5public.h" +#include "H5Ipublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +#define H5X_CLASS_T_VERS (1) + +/* Plugin IDs */ +#define H5X_PLUGIN_ERROR (-1) /* no plugin */ +#define H5X_PLUGIN_NONE 0 /* reserved indefinitely */ +#define H5X_PLUGIN_DUMMY 1 /* dummy */ +#define H5X_PLUGIN_FASTBIT 2 /* fastbit */ +#define H5X_PLUGIN_ALACRIT 3 /* alacrity */ + +#define H5X_PLUGIN_RESERVED 64 /* plugin ids below this value reserved */ + +#define H5X_PLUGIN_MAX 256 /* maximum plugin id */ +#define H5X_MAX_NPLUGINS 16 /* Maximum number of plugins allowed in a pipeline */ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* 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_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, described above */ + void *(*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 (*remove)(hid_t file_id, hid_t dataset_id, size_t metadata_size, + void *metadata); + void *(*open)(hid_t file_id, hid_t dataset_id, hid_t xapl_id, + size_t metadata_size, 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); + herr_t (*query)(void *idx_handle, hid_t query_id, hid_t xxpl_id, + hid_t *dataspace_id); +} H5X_class_t; + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ +#ifdef __cplusplus +extern "C" { +#endif + +/* 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 file_id, unsigned plugin_id, hid_t scope_id, + hid_t xcpl_id); +H5_DLL herr_t H5Xcreate_ff(hid_t file_id, unsigned plugin_id, hid_t scope_id, + hid_t xcpl_id, hid_t trans_id, hid_t estack_id); + +H5_DLL herr_t H5Xremove(hid_t file_id, unsigned plugin_id, hid_t scope_id); +H5_DLL herr_t H5Xremove_ff(hid_t file_id, unsigned plugin_id, hid_t scope_id, + hid_t trans_id, hid_t estack_id); + +H5_DLL herr_t H5Xget_count(hid_t scope_id, hsize_t *idx_count); +H5_DLL herr_t H5Xget_count_ff(hid_t scope_id, hsize_t *idx_count, hid_t rcxt_id, + hid_t estack_id); + +/* +H5_DLL herr_t H5Xget_type(hid_t object_id, hsize_t index_idx, + unsigned *plugin_id); +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); +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _H5Xpublic_H */ diff --git a/src/H5err.txt b/src/H5err.txt index e34b352..a1ab9b2 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -78,6 +78,7 @@ MAJOR, H5E_SOHM, Shared Object Header Messages MAJOR, H5E_EARRAY, Extensible Array MAJOR, H5E_FARRAY, Fixed Array MAJOR, H5E_PLUGIN, Plugin for dynamically loaded library +MAJOR, H5E_INDEX, Index MAJOR, H5E_NONE_MAJOR, No error # Sections (for grouping minor errors) diff --git a/test/index.c b/test/index.c new file mode 100644 index 0000000..cd59728 --- /dev/null +++ b/test/index.c @@ -0,0 +1,308 @@ +/* + * h5ff_client_index.c: Client side test for index routines. + */ + +#include + +#include +#include +#include +#include +#include + +#define NTUPLES 256 +static int my_rank = 0, my_size = 1; + +static void +write_dataset(const char *file_name, const char *dataset_name, + hsize_t total, hsize_t ncomponents, hid_t datatype_id, + hsize_t ntuples, hsize_t start, void *buf) +{ + hid_t file_id, dataset_id, view_id; + hid_t file_space_id, mem_space_id; + hid_t tid1, rid1, rid2, trspl_id; + hid_t fapl_id; + hsize_t dims[2] = {total, ncomponents}; + hsize_t offset[2] = {start, 0}; + hsize_t count[2] = {ntuples, ncomponents}; + int rank = (ncomponents == 1) ? 1 : 2; + uint64_t version; + herr_t ret; + void *dset_token1; + size_t token_size1; + double lower_bound1 = 39.1, upper_bound1 = 42.1; + int lower_bound2 = 295, upper_bound2 = 298; + hid_t query_id1, query_id2, query_id3, query_id4, query_id5, query_id6; + hid_t query_id; + MPI_Request mpi_reqs[2]; + + /* Choose the IOD VOL plugin to use with this file. */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_iod(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL); + + /* Open an existing file. */ + file_id = H5Fcreate_ff(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id, + H5_EVENT_STACK_NULL); + + ret = H5Pclose(fapl_id); + assert(0 == ret); + + /* acquire container version 0 - EXACT. */ + version = 0; + rid1 = H5RCacquire(file_id, &version, H5P_DEFAULT, H5_EVENT_STACK_NULL); + assert(0 == version); + + /* create transaction object */ + tid1 = H5TRcreate(file_id, rid1, (uint64_t)1); + assert(tid1); + + trspl_id = H5Pcreate(H5P_TR_START); + ret = H5Pset_trspl_num_peers(trspl_id, (unsigned int) my_size); + assert(0 == ret); + ret = H5TRstart(tid1, trspl_id, H5_EVENT_STACK_NULL); + assert(0 == ret); + ret = H5Pclose(trspl_id); + assert(0 == ret); + + /* Create the data space for the first dataset. */ + file_space_id = H5Screate_simple(rank, dims, NULL); + assert(file_space_id); + + if(0 == my_rank) { + /* Create a dataset. */ + dataset_id = H5Dcreate_ff(file_id, dataset_name, datatype_id, file_space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid1, H5_EVENT_STACK_NULL); + assert(dataset_id); + + /* get the token size of each dset */ + ret = H5Oget_token(dataset_id, NULL, &token_size1); + assert(0 == ret); + + /* allocate buffers for each token */ + dset_token1 = malloc(token_size1); + + /* get the token buffer */ + ret = H5Oget_token(dataset_id, dset_token1, &token_size1); + assert(0 == ret); + + /* bcast the token sizes and the tokens */ + MPI_Ibcast(&token_size1, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, + &mpi_reqs[0]); + MPI_Ibcast(dset_token1, token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, + &mpi_reqs[1]); + MPI_Waitall(2, mpi_reqs, MPI_STATUS_IGNORE); + } + else { + /* recieve the token size */ + MPI_Ibcast(&token_size1, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, + &mpi_reqs[0]); + MPI_Waitall(1, mpi_reqs, MPI_STATUS_IGNORE); + + /* allocate buffer for token */ + dset_token1 = malloc(token_size1); + + /* recieve the token */ + MPI_Ibcast(dset_token1, token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, + &mpi_reqs[0]); + MPI_Waitall(1, mpi_reqs, MPI_STATUS_IGNORE); + + dataset_id = H5Oopen_by_token(dset_token1, tid1, H5_EVENT_STACK_NULL); + } + free(dset_token1); + + mem_space_id = H5Screate_simple(rank, count, NULL); + assert(mem_space_id); + + /* write data to datasets */ + ret = H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, + NULL, count, NULL); + assert(0 == ret); + + /* Write the first dataset. */ + ret = H5Dwrite_ff(dataset_id, datatype_id, mem_space_id, file_space_id, + H5P_DEFAULT, buf, tid1, H5_EVENT_STACK_NULL); + assert(0 == ret); + + /* Close the data space for the first dataset. */ + ret = H5Sclose(mem_space_id); + assert(0 == ret); + + /* Finish transaction 1. */ + ret = H5TRfinish(tid1, H5P_DEFAULT, &rid2, H5_EVENT_STACK_NULL); + assert(0 == ret); + + /* release container version 0. */ + ret = H5RCrelease(rid1, H5_EVENT_STACK_NULL); + assert(0 == ret); + + MPI_Barrier(MPI_COMM_WORLD); + + /* Create a simple query */ + /* query = (39.1 < x < 42.1) || (295 < x < 298) */ + query_id1 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_GREATER_THAN, + H5T_NATIVE_DOUBLE, &lower_bound1); + assert(query_id1); + query_id2 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_LESS_THAN, + H5T_NATIVE_DOUBLE, &upper_bound1); + assert(query_id2); + query_id3 = H5Qcombine(query_id1, H5Q_COMBINE_AND, query_id2); + assert(query_id3); + query_id4 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_GREATER_THAN, + H5T_NATIVE_INT, &lower_bound2); + assert(query_id4); + query_id5 = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_LESS_THAN, + H5T_NATIVE_INT, &upper_bound2); + assert(query_id5); + query_id6 = H5Qcombine(query_id4, H5Q_COMBINE_AND, query_id5); + assert(query_id6); + query_id = H5Qcombine(query_id3, H5Q_COMBINE_OR, query_id6); + assert(query_id); + + view_id = H5Vcreate_ff(dataset_id, query_id, H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL); + assert(view_id > 0); + + { + hsize_t attr_count, obj_count, reg_count; + hssize_t num_points; + hid_t region_space; + int r_ndims; + hsize_t r_dims[2]; + + H5Qclose(query_id); + ret = H5Dclose_ff(dataset_id, H5_EVENT_STACK_NULL); + assert(0 == ret); + + ret = H5Vget_location_ff(view_id, &dataset_id, H5_EVENT_STACK_NULL); + assert(0 == ret); + + ret = H5Dclose_ff(dataset_id, H5_EVENT_STACK_NULL); + assert(0 == ret); + + ret = H5Vget_query(view_id, &query_id); + assert(0 == ret); + + ret = H5Vget_counts(view_id, &attr_count, &obj_count, ®_count); + assert(0 == ret); + assert(0 == attr_count); + assert(0 == obj_count); + assert(1 == reg_count); + + ret = H5Vget_elem_regions_ff(view_id, 0, 1, &dataset_id, + ®ion_space, H5_EVENT_STACK_NULL); + assert(0 == ret); + + r_ndims = H5Sget_simple_extent_dims(region_space, r_dims, NULL); + + assert(2 == r_ndims); + assert(total == r_dims[0]); + assert(ncomponents == r_dims[1]); + + num_points = H5Sget_select_elem_npoints(region_space); + assert(9 == num_points); + + ret = H5Sclose(region_space); + assert(0 == ret); + } + + H5Vclose(view_id); + + H5Qclose(query_id); + H5Qclose(query_id6); + H5Qclose(query_id5); + H5Qclose(query_id4); + H5Qclose(query_id3); + H5Qclose(query_id2); + H5Qclose(query_id1); + + /* Close the first dataset. */ + ret = H5Dclose_ff(dataset_id, H5_EVENT_STACK_NULL); + assert(0 == ret); + ret = H5Sclose(file_space_id); + assert(0 == ret); + + /* release container version 1. */ + ret = H5RCrelease(rid2, H5_EVENT_STACK_NULL); + assert(0 == ret); + + ret = H5RCclose(rid1); + assert(0 == ret); + ret = H5RCclose(rid2); + assert(0 == ret); + ret = H5TRclose(tid1); + assert(0 == ret); + + MPI_Barrier(MPI_COMM_WORLD); + + /* Close the file. */ + ret = H5Fclose_ff(file_id, H5_EVENT_STACK_NULL); + assert(0 == ret); +} + +int +main(int argc, char **argv) +{ + const char *file_name="eff_file_view.h5"; + const char *dataset_name="D1"; + hsize_t ntuples = NTUPLES; + hsize_t ncomponents = 3; + hsize_t start, total; + int *data; + hsize_t i, j; + + int provided; + + MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); + if(MPI_THREAD_MULTIPLE != provided) { + fprintf(stderr, "MPI does not have MPI_THREAD_MULTIPLE support\n"); + exit(1); + } + + /* Call EFF_init to initialize the EFF stack. */ + EFF_init(MPI_COMM_WORLD, MPI_INFO_NULL); + + MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); + MPI_Comm_size(MPI_COMM_WORLD, &my_size); + fprintf(stderr, "APP processes = %d, my rank is %d\n", my_size, my_rank); + + start = ntuples * (hsize_t) my_rank; + total = ntuples * (hsize_t) my_size; + + /* Initialize the dataset. */ + data = (int *) malloc(sizeof(int) * ncomponents * ntuples); + for (i = 0; i < ntuples; i++) { + for (j = 0; j < ncomponents; j++) { + data[ncomponents * i + j] = my_rank * ntuples + i; + } + } + + MPI_Barrier(MPI_COMM_WORLD); + + write_dataset(file_name, dataset_name, total, ncomponents, H5T_NATIVE_INT, + ntuples, start, data); + + MPI_Barrier(MPI_COMM_WORLD); + + free(data); + + MPI_Barrier(MPI_COMM_WORLD); + EFF_finalize(); + MPI_Finalize(); + + return 0; +} + +//H5Xregister(&index_plugin_struct); +//dsid = H5Dcreate(fid, "A", ...); +//H5Xcreate(fid, 32, dsid, H5P_DEFAULT); +//H5Dwrite(dsid, ...); +//H5Dclose(dsid); +// +//dsid = H5Dopen(fid, "A", ...); +//int query_val = 15; +//qid = H5Qcreate(H5Q_TYPE_DATA_ELEM, H5Q_MATCH_EQUAL, H5T_NATIVE_INT, &query_val); +//vid = H5Vcreate(dsid, qid, H5P_DEFAULT); +//H5Dclose(dsid); +//H5Xdelete(dsid, 32); + + + -- cgit v0.12