From 5b6bd7c922d81bb6d1877c03e4b012823f03f88a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 13 Aug 2019 01:36:42 -0700 Subject: Added the map (H5M) API --- CMakeLists.txt | 6 + MANIFEST | 7 + bin/trace | 1 + config/cmake/H5pubconf.h.in | 3 + configure.ac | 26 ++ release_docs/RELEASE.txt | 5 + src/CMakeLists.txt | 16 + src/H5.c | 3 + src/H5Fint.c | 6 + src/H5Gdeprec.c | 3 + src/H5Gloc.c | 3 + src/H5Gname.c | 6 + src/H5Gtest.c | 3 + src/H5I.c | 5 + src/H5Ipublic.h | 1 + src/H5M.c | 1032 +++++++++++++++++++++++++++++++++++++++++ src/H5Mmodule.h | 31 ++ src/H5Mpkg.h | 51 ++ src/H5Mprivate.h | 80 ++++ src/H5Mpublic.h | 126 +++++ src/H5O.c | 1 + src/H5Oflush.c | 3 + src/H5Oint.c | 3 + src/H5Opublic.h | 1 + src/H5Pencdec.c | 2 +- src/H5Pint.c | 34 +- src/H5Pmapl.c | 217 +++++++++ src/H5Pmcpl.c | 115 +++++ src/H5Pprivate.h | 5 + src/H5Ppublic.h | 14 + src/H5Rint.c | 3 + src/H5T.c | 1 + src/H5VLcallback.c | 111 +++++ src/H5VLconnector.h | 2 +- src/H5VLint.c | 4 +- src/H5VLprivate.h | 3 + src/H5err.txt | 1 + src/H5private.h | 3 + src/H5trace.c | 14 +- src/Makefile.am | 8 +- src/hdf5.h | 1 + test/links.c | 6 + test/objcopy.c | 11 +- test/tfile.c | 3 + tools/lib/h5tools_str.c | 1 + tools/lib/h5tools_utils.c | 1 + tools/lib/h5trav.c | 4 + tools/src/h5dump/h5dump_ddl.c | 3 + tools/src/h5dump/h5dump_xml.c | 1 + tools/src/h5stat/h5stat.c | 1 + 50 files changed, 1978 insertions(+), 13 deletions(-) create mode 100644 src/H5M.c create mode 100644 src/H5Mmodule.h create mode 100644 src/H5Mpkg.h create mode 100644 src/H5Mprivate.h create mode 100644 src/H5Mpublic.h create mode 100644 src/H5Pmapl.c create mode 100644 src/H5Pmcpl.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 374e15e..e6474aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -705,6 +705,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) endif () endif () endif () + #----------------------------------------------------------------------------- # Option to use threadsafe #----------------------------------------------------------------------------- @@ -759,6 +760,11 @@ if (HDF5_ENABLE_THREADSAFE) endif () #----------------------------------------------------------------------------- +# Option to build the map API +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_MAP_API "Build the map API" OFF) + +#----------------------------------------------------------------------------- # Add the HDF5 Library Target to the build #----------------------------------------------------------------------------- add_subdirectory (src) diff --git a/MANIFEST b/MANIFEST index 83c03a5..29b34a5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -749,6 +749,11 @@ ./src/H5Lpkg.h ./src/H5Lprivate.h ./src/H5Lpublic.h +./src/H5M.c +./src/H5Mmodule.h +./src/H5Mpkg.h +./src/H5Mprivate.h +./src/H5Mpublic.h ./src/H5MF.c ./src/H5MFaggr.c ./src/H5MFdbg.c @@ -820,6 +825,8 @@ ./src/H5Pint.c ./src/H5Plapl.c ./src/H5Plcpl.c +./src/H5Pmapl.c +./src/H5Pmcpl.c ./src/H5Pmodule.h ./src/H5Pocpl.c ./src/H5Pocpypl.c diff --git a/bin/trace b/bin/trace index 241c69c..54b6f8f 100755 --- a/bin/trace +++ b/bin/trace @@ -150,6 +150,7 @@ $Source = ""; "H5L_class_t" => "x", "H5L_elink_traverse_t" => "x", "H5L_iterate_t" => "x", + "H5M_iterate_t" => 'x', "H5MM_allocate_t" => "x", "H5MM_free_t" => "x", "H5O_info_t" => "x", diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index cb05974..120c023 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -267,6 +267,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_MACH_MACH_TIME_H @H5_HAVE_MACH_MACH_TIME_H@ +/* Define if the map API (H5M) should be compiled */ +#cmakedefine H5_HAVE_MAP_API @H5_HAVE_MAP_API@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_MEMORY_H @H5_HAVE_MEMORY_H@ diff --git a/configure.ac b/configure.ac index 3d6ab10..7f1f0dd 100644 --- a/configure.ac +++ b/configure.ac @@ -2766,6 +2766,32 @@ if test -n "$PARALLEL"; then fi ## ---------------------------------------------------------------------- +## Check if the map API is enabled by --enable-map-api +## +AC_SUBST([MAP_API]) + +## Default is no map API +MAP_API=no + +AC_MSG_CHECKING([if the map API (H5M) is enabled]) + +AC_ARG_ENABLE([map-api], + [AS_HELP_STRING([--enable-map-api], + [Build the map API (H5M). + This is not yet supported in the native file format + and requires a VOL connector that supports it. + [default=no]])], + [MAP_API=$enableval], [MAP_API=no]) + +if test "X$MAP_API" = "Xyes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_MAP_API], [1], + [Define if the map API (H5M) should be compiled]) +else + AC_MSG_RESULT([no]) +fi + +## ---------------------------------------------------------------------- ## Check if Direct I/O driver is enabled by --enable-direct-vfd ## AC_SUBST([DIRECT_VFD]) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 8fa5ed7..094a81f 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -191,6 +191,11 @@ New Features Library: -------- + - Add new API H5M for map objects. Currently not supported by native + library, can be supported by VOL connectors. + + (NAF - 2019/03/01) + - Improved the performance of virtual dataset I/O Refactored the internal dataspace routines used by the virtual dataset diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b693bd..17fd949 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -393,6 +393,15 @@ set (H5L_HDRS IDE_GENERATED_PROPERTIES ("H5L" "${H5L_HDRS}" "${H5L_SOURCES}" ) +set (H5M_SOURCES + ${HDF5_SRC_DIR}/H5M.c +) +set (H5M_HDRS + ${HDF5_SRC_DIR}/H5Mpublic.h +) +IDE_GENERATED_PROPERTIES ("H5M" "${H5M_HDRS}" "${H5M_SOURCES}") + + set (H5MF_SOURCES ${HDF5_SRC_DIR}/H5MF.c ${HDF5_SRC_DIR}/H5MFaggr.c @@ -483,6 +492,8 @@ set (H5P_SOURCES ${HDF5_SRC_DIR}/H5Pint.c ${HDF5_SRC_DIR}/H5Plapl.c ${HDF5_SRC_DIR}/H5Plcpl.c + ${HDF5_SRC_DIR}/H5Pmapl.c + ${HDF5_SRC_DIR}/H5Pmcpl.c ${HDF5_SRC_DIR}/H5Pocpl.c ${HDF5_SRC_DIR}/H5Pocpypl.c ${HDF5_SRC_DIR}/H5Pstrcpl.c @@ -716,6 +727,7 @@ set (common_SRCS ${H5HP_SOURCES} ${H5I_SOURCES} ${H5L_SOURCES} + ${H5M_SOURCES} ${H5MF_SOURCES} ${H5MM_SOURCES} ${H5MP_SOURCES} @@ -759,6 +771,7 @@ set (H5_PUBLIC_HEADERS ${H5HL_HDRS} ${H5I_HDRS} ${H5L_HDRS} + ${H5M_HDRS} ${H5MF_HDRS} ${H5MM_HDRS} ${H5MP_HDRS} @@ -845,6 +858,9 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5Lpkg.h ${HDF5_SRC_DIR}/H5Lprivate.h + ${HDF5_SRC_DIR}/H5Mpkg.h + ${HDF5_SRC_DIR}/H5Mprivate.h + ${HDF5_SRC_DIR}/H5MFprivate.h ${HDF5_SRC_DIR}/H5MMprivate.h diff --git a/src/H5.c b/src/H5.c index 104c9fd..16c12cb 100644 --- a/src/H5.c +++ b/src/H5.c @@ -166,6 +166,7 @@ H5_init_library(void) H5_debug_g.pkg[H5_PKG_HG].name = "hg"; H5_debug_g.pkg[H5_PKG_HL].name = "hl"; H5_debug_g.pkg[H5_PKG_I].name = "i"; + H5_debug_g.pkg[H5_PKG_M].name = "m"; H5_debug_g.pkg[H5_PKG_MF].name = "mf"; H5_debug_g.pkg[H5_PKG_MM].name = "mm"; H5_debug_g.pkg[H5_PKG_O].name = "o"; @@ -312,6 +313,7 @@ H5_term_library(void) pending += DOWN(A_top); pending += DOWN(D_top); pending += DOWN(G_top); + pending += DOWN(M_top); pending += DOWN(R_top); pending += DOWN(S_top); pending += DOWN(T_top); @@ -337,6 +339,7 @@ H5_term_library(void) pending += DOWN(A); pending += DOWN(D); pending += DOWN(G); + pending += DOWN(M); pending += DOWN(R); pending += DOWN(S); pending += DOWN(T); diff --git a/src/H5Fint.c b/src/H5Fint.c index 7ed3ca8..c9c6658 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -498,6 +498,9 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) oloc = NULL; break; + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: @@ -3600,6 +3603,9 @@ H5F__get_file(void *obj, H5I_type_t type) oloc = H5A_oloc((H5A_t *)obj); break; + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_DATASPACE: diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 95627d2..5acb378 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -131,6 +131,9 @@ H5G_map_obj_type(H5O_type_t obj_type) ret_value = H5G_TYPE; break; + case H5O_TYPE_MAP: + /* Maps not supported in native VOL connector */ + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: diff --git a/src/H5Gloc.c b/src/H5Gloc.c index e47d3be..40d56c6 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -213,6 +213,9 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) case H5I_DATASPACE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of dataspace") + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maps not supported in native VOL connector") + case H5I_GENPROP_CLS: case H5I_GENPROP_LST: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of property list") diff --git a/src/H5Gname.c b/src/H5Gname.c index 16c1ca7..86a0c2f 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -816,6 +816,9 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) obj_path = H5T_nameof((H5T_t *)obj_ptr); break; + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: @@ -1112,6 +1115,9 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, search_datatype = TRUE; break; + case H5O_TYPE_MAP: + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: /* Search and replace names through datatype IDs */ diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 0b431b1..f9ab6f2 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -604,6 +604,9 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign obj_path = H5T_nameof((H5T_t *)obj_ptr); break; + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: diff --git a/src/H5I.c b/src/H5I.c index 6b5210d..a2275de 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -2371,6 +2371,11 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) break; } + /* TODO: Maps will have to be added when they are supported in the + * native VOL connector. + */ + case H5I_MAP: + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index def785f..34a408f 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -38,6 +38,7 @@ typedef enum H5I_type_t { H5I_DATATYPE, /* type ID for Datatype objects */ H5I_DATASPACE, /* type ID for Dataspace objects */ H5I_DATASET, /* type ID for Dataset objects */ + H5I_MAP, /* type ID for Map objects */ H5I_ATTR, /* type ID for Attribute objects */ H5I_VFL, /* type ID for virtual file layer */ H5I_VOL, /* type ID for virtual object layer */ diff --git a/src/H5M.c b/src/H5M.c new file mode 100644 index 0000000..3008c40 --- /dev/null +++ b/src/H5M.c @@ -0,0 +1,1032 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Mmodule.h" /* This source code file is part of the H5M module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Mpkg.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5M__close_cb(H5VL_object_t *map_vol_obj); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Map ID class */ +static const H5I_class_t H5I_MAP_CLS[1] = {{ + H5I_MAP, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5M__close_cb /* Callback routine for closing objects of this class */ +}}; + +/* Flag indicating "top" of interface has been initialized */ +static hbool_t H5M_top_package_initialize_s = FALSE; + + + +/*------------------------------------------------------------------------- +NAME + H5M__init_package -- Initialize interface-specific information +USAGE + herr_t H5M__init_package() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. +--------------------------------------------------------------------------- +*/ +herr_t +H5M__init_package(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Initialize the atom group for the map IDs */ + if(H5I_register_type(H5I_MAP_CLS) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, FAIL, "unable to initialize interface") + + /* Mark "top" of interface as initialized, too */ + H5M_top_package_initialize_s = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5M__init_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5M_top_term_package + * + * Purpose: Close the "top" of the interface, releasing IDs, etc. + * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. + *------------------------------------------------------------------------- + */ +int +H5M_top_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(H5M_top_package_initialize_s) { + if(H5I_nmembers(H5I_MAP) > 0) { + (void)H5I_clear_type(H5I_MAP, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + + /* Mark closed */ + if(0 == n) + H5M_top_package_initialize_s = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5M_top_term_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5M_term_package + * + * Purpose: Terminate this interface. + * + * Note: Finishes shutting down the interface, after + * H5M_top_term_package() is called + * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. + *------------------------------------------------------------------------- + */ +int +H5M_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(H5_PKG_INIT_VAR) { + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_MAP)); + HDassert(FALSE == H5M_top_package_initialize_s); + + /* Destroy the dataset object id group */ + n += (H5I_dec_type_ref(H5I_MAP) > 0); + + /* Mark closed */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5M_term_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5M__close_cb + * + * Purpose: Called when the ref count reaches zero on the map's ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5M__close_cb(H5VL_object_t *map_vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(map_vol_obj); + + /* Close the map */ + if(H5VL_optional(map_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_CLOSE) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CLOSEERROR, FAIL, "unable to close map"); + + /* Free the VOL object */ + if(H5VL_free_object(map_vol_obj) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "unable to free VOL object"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5M__close_cb() */ + +#ifdef H5_HAVE_MAP_API + + +/*------------------------------------------------------------------------- + * Function: H5Mcreate + * + * Purpose: Creates a new map object for storing key-value pairs. The + * in-file datatype for keys is defined by KEY_TYPE_ID and + * the in-file datatype for values is defined by VAL_TYPE_ID. + * LOC_ID specifies the location to create the map object and + * NAME specifies the name of the link to the object + * (relative to LOC_ID). Other options can be specified + * through the property lists LCPL_ID, MCPL_ID, and MAPL_ID. + * + * Return: Success: The object ID of the new map. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id, + hid_t lcpl_id, hid_t mcpl_id, hid_t mapl_id) +{ + void *map = NULL; /* New map's info */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE7("i", "i*siiiii", loc_id, name, key_type_id, val_type_id, lcpl_id, + mcpl_id, mapl_id); + + /* Check arguments */ + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") + + /* Get link creation property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + else + if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") + + /* Get map creation property list */ + if(H5P_DEFAULT == mcpl_id) + mcpl_id = H5P_MAP_CREATE_DEFAULT; + else + if(TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "mcpl_id is not a map create property list ID") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Create the map */ + if(H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_CREATE, &loc_params, name, lcpl_id, + key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") + + /* Get an atom for the map */ + if((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize map handle") + +done: + /* Cleanup on failure */ + if(H5I_INVALID_HID == ret_value) + if(map && H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_CLOSE) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + + FUNC_LEAVE_API(ret_value) +} /* end H5Mcreate() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mcreate_anon + * + * Purpose: Creates a new map object for storing key-value pairs. The + * in-file datatype for keys is defined by KEY_TYPE_ID and + * the in-file datatype for values is defined by VAL_TYPE_ID. + * LOC_ID specifies the file to create the map object, but no + * link to the object is created. Other options can be + * specified through the property lists LCPL_ID, MCPL_ID, and + * MAPL_ID. + * + * The resulting ID should be linked into the file with + * H5Olink or it will be deleted when closed. + * + * Return: Success: The object ID of the new map. The map should + * be linked into the group hierarchy before being closed or + * it will be deleted. The dataset should be + * closed when the caller is no longer interested + * in it. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, + hid_t mcpl_id, hid_t mapl_id) +{ + void *map = NULL; /* map token from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE5("i", "iiiii", loc_id, key_type_id, val_type_id, mcpl_id, mapl_id); + + /* Check arguments */ + if(H5P_DEFAULT == mcpl_id) + mcpl_id = H5P_MAP_CREATE_DEFAULT; + else + if(TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not map create property list ID") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Create the map */ + if(H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_CREATE, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, + key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") + + /* Get an atom for the map */ + if((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register map") + +done: + /* Cleanup on failure */ + if(H5I_INVALID_HID == ret_value) + if(map && H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_CLOSE) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + + FUNC_LEAVE_API(ret_value) +} /* end H5Mcreate_anon() */ + + +/*------------------------------------------------------------------------ + * Function: H5Mopen + * + * Purpose: Finds a map named NAME at LOC_ID, opens it, and returns + * its ID. The map should be close when the caller is no + * longer interested in it. + * + * Takes a map access property list + * + * Return: Success: Object ID of the map + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id) +{ + void *map = NULL; /* map token from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("i", "i*si", loc_id, name, mapl_id); + + /* Check args */ + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set the location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Open the map */ + if(H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_OPEN, &loc_params, name, mapl_id, &map) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open map") + + /* Register an atom for the map */ + if((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register map atom") + +done: + /* Cleanup on failure */ + if(H5I_INVALID_HID == ret_value) + if(map && H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_CLOSE) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + + FUNC_LEAVE_API(ret_value) +} /* end H5Mopen() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mclose + * + * Purpose: Closes access to a map and releases resources used by it. + * It is illegal to subsequently use that same map ID in + * calls to other map functions. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mclose(hid_t map_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", map_id); + + /* Check args */ + if(H5I_MAP != H5I_get_type(map_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a map ID") + + /* Decrement the counter on the map. It will be freed if the count + * reaches zero. + */ + if(H5I_dec_app_ref_always_close(map_id) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "can't decrement count on map ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mclose() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mget_key_type + * + * Purpose: Returns a copy of the key datatype for a map. + * + * Return: Success: ID for a copy of the datatype. The data + * type should be released by calling + * H5Tclose(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_key_type(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* get the datatype */ + if(H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET, H5VL_MAP_GET_KEY_TYPE, &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_key_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mget_val_type + * + * Purpose: Returns a copy of the value datatype for a map. + * + * Return: Success: ID for a copy of the datatype. The data + * type should be released by calling + * H5Tclose(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_val_type(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* get the datatype */ + if(H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET, H5VL_MAP_GET_VAL_TYPE, &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_val_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mget_create_plist + * + * Purpose: Returns a copy of the map creation property list. + * + * Return: Success: ID for a copy of the map creation + * property list. The template should be + * released by calling H5P_close(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_create_plist(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* Get the map creation property list */ + if(H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET, H5VL_MAP_GET_MCPL, &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map creation properties") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_create_plist() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mget_access_plist + * + * Purpose: Returns a copy of the map access property list. + * + * Description: H5Mget_access_plist returns the map access property + * list identifier of the specified map. + * + * Return: Success: ID for a copy of the map access + * property list. The template should be + * released by calling H5Pclose(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_access_plist(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* Get the map access property list */ + if(H5VL_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET, H5VL_MAP_GET_MAPL, &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_access_plist() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mget_count + * + * Purpose: Returns the number of key-value pairs stored in the map. + * + * Description: H5Mget_count returns the number of key-value pairs stored + * in the specified map. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mget_count(hid_t map_id, hsize_t *count, hid_t dxpl_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("e", "i*hi", map_id, count, dxpl_id); + + /* Check args */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Get the number of key-value pairs stored in the map */ + if(H5VL_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_GET, H5VL_MAP_GET_COUNT, count) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_count() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mset + * + * Purpose: H5Mset adds a key-value pair to the Map specified by + * MAP_ID, or updates the value for the specified key if one + * was set previously. KEY_MEM_TYPE_ID and VAL_MEM_TYPE_ID + * specify the datatypes for the provided KEY and VALUE + * buffers, and if different from those used to create the + * map object, the key and value will be internally converted + * to the datatypes for the map object. Any further options + * can be specified through the property list DXPL_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mset(hid_t map_id, hid_t key_mem_type_id, const void *key, + hid_t val_mem_type_id, const void *value, hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "ii*xi*xi", map_id, key_mem_type_id, key, val_mem_type_id, value, + dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (val_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set the key/value pair */ + if(H5VL_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_SET, key_mem_type_id, key, val_mem_type_id, value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to set key/value pair") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mset() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mget + * + * Purpose: H5Mget retrieves, from the Map specified by MAP_ID, the + * value associated with the provided key. KEY_MEM_TYPE_ID + * and VAL_MEM_TYPE_ID specify the datatypes for the provided + * KEY and VALUE buffers. If KEY_MEM_TYPE_ID is different + * from that used to create the map object, the key will be + * internally converted to the datatype for the map object + * for the query, and if VAL_MEM_TYPE_ID is different from + * that used to create the map object, the returned value + * will be converted to VAL_MEM_TYPE_ID before the function + * returns. Any further options can be specified through the + * property list DXPL_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, + hid_t val_mem_type_id, void *value, hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "ii*xi*xi", map_id, key_mem_type_id, key, val_mem_type_id, value, + dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (val_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Get the value for the key */ + if(H5VL_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_GET_VAL, key_mem_type_id, key, val_mem_type_id, value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, FAIL, "unable to get value from map") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mexists + * + * Purpose: H5Mexists checks if the provided key is stored in the map + * specified by MAP_ID. If KEY_MEM_TYPE_ID is different from + * that used to create the map object the key will be + * internally converted to the datatype for the map object + * for the query. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, + hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "ii*x*bi", map_id, key_mem_type_id, key, exists, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Check if key exists */ + if((ret_value = H5VL_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_EXISTS, key_mem_type_id, key, exists)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, ret_value, "unable to check if key exists") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mexists() */ + + +/*------------------------------------------------------------------------- + * Function: H5Miterate + * + * Purpose: H5Miterate iterates over all key-value pairs stored in the + * map specified by MAP_ID, making the callback specified by + * OP for each. The IDX parameter is an in/out parameter that + * may be used to restart a previously interrupted iteration. + * At the start of iteration IDX should be set to 0, and to + * restart iteration at the same location on a subsequent + * call to H5Miterate, IDX should be the same value as + * returned by the previous call. + * + * H5M_iterate_t is defined as: + * herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, + * void *ctx) + * + * The KEY parameter is the buffer for the key for this + * iteration, converted to the datatype specified by + * KEY_MEM_TYPE_ID. The OP_DATA parameter is a simple pass + * through of the value passed to H5Miterate, which can be + * used to store application-defined data for iteration. A + * negative return value from this function will cause + * H5Miterate to issue an error, while a positive return + * value will cause H5Miterate to stop iterating and return + * this value without issuing an error. A return value of + * zero allows iteration to continue. + * + * Return: Last value returned by op + * + *------------------------------------------------------------------------- + */ +herr_t +H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, + void *op_data, hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "i*hix*xi", map_id, idx, key_mem_type_id, op, op_data, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(map_id); + + /* Iterate over keys */ + if((ret_value = H5VL_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_SPECIFIC, &loc_params, H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to ierate over keys") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Miterate() */ + + +/*------------------------------------------------------------------------- + * Function: H5Miterate_by_name + * + * Purpose: H5Miterate_by_name iterates over all key-value pairs + * stored in the map specified by MAP_ID, making the callback + * specified by OP for each. The IDX parameter is an in/out + * parameter that may be used to restart a previously + * interrupted iteration. At the start of iteration IDX + * should be set to 0, and to restart iteration at the same + * location on a subsequent call to H5Miterate, IDX should be + * the same value as returned by the previous call. + * + * H5M_iterate_t is defined as: + * herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, + * void *ctx) + * + * The KEY parameter is the buffer for the key for this + * iteration, converted to the datatype specified by + * KEY_MEM_TYPE_ID. The OP_DATA parameter is a simple pass + * through of the value passed to H5Miterate, which can be + * used to store application-defined data for iteration. A + * negative return value from this function will cause + * H5Miterate to issue an error, while a positive return + * value will cause H5Miterate to stop iterating and return + * this value without issuing an error. A return value of + * zero allows iteration to continue. + * + * Return: Last value returned by op + * + *------------------------------------------------------------------------- + */ +herr_t +H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, + hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, hid_t dxpl_id, + hid_t lapl_id) +{ + H5VL_object_t *vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*s*hix*xii", loc_id, map_name, idx, key_mem_type_id, op, + op_data, dxpl_id, lapl_id); + + /* Check arguments */ + if(!map_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "map_name parameter cannot be NULL") + if(!*map_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "map_name parameter cannot be an empty string") + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = map_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Iterate over keys */ + if((ret_value = H5VL_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_SPECIFIC, &loc_params, H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to ierate over keys") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Miterate_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5Mdelete_key + * + * Purpose: H5Mdelete_key deletes a key-value pair from the Map + * specified by MAP_ID. KEY_MEM_TYPE_ID specifies the + * datatype for the provided key buffers, and if different + * from that used to create the Map object, the key will be + * internally converted to the datatype for the map object. + * Any further options can be specified through the property + * list DXPL_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mdelete_key(hid_t map_id, hid_t key_mem_type_id, const void *key, + hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "ii*xi", map_id, key_mem_type_id, key, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(map_id); + + /* Set the key/value pair */ + if(H5VL_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_SPECIFIC, &loc_params, H5VL_MAP_DELETE_KEY, key_mem_type_id, key) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to set key/value pair") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mdelete_key() */ + +#endif /* H5_HAVE_MAP_API */ + diff --git a/src/H5Mmodule.h b/src/H5Mmodule.h new file mode 100644 index 0000000..00a586f --- /dev/null +++ b/src/H5Mmodule.h @@ -0,0 +1,31 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which define macros for the + * H5M package. Including this header means that the source file + * is part of the H5M package. + */ +#ifndef _H5Mmodule_H +#define _H5Mmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5M_MODULE +#define H5_MY_PKG H5M +#define H5_MY_PKG_ERR H5E_MAP +#define H5_MY_PKG_INIT YES + +#endif /* _H5Dmodule_H */ + + diff --git a/src/H5Mpkg.h b/src/H5Mpkg.h new file mode 100644 index 0000000..86ff45c --- /dev/null +++ b/src/H5Mpkg.h @@ -0,0 +1,51 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which are visible only within + * the H5M package. Source files outside the H5M package should + * include H5Mprivate.h instead. + */ +#if !(defined H5M_FRIEND || defined H5M_MODULE) +#error "Do not include this file outside the H5M package!" +#endif + +#ifndef _H5Mpkg_H +#define _H5Mpkg_H + +/* Get package's private header */ +#include "H5Mprivate.h" + +/* Other private headers needed by this file */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ + +#endif /*_H5Dpkg_H*/ + diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h new file mode 100644 index 0000000..c841e75 --- /dev/null +++ b/src/H5Mprivate.h @@ -0,0 +1,80 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * 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 H5M module + */ +#ifndef _H5Mprivate_H +#define _H5Mprivate_H + +/* Include package's public header */ +#include "H5Mpublic.h" + +/* Private headers needed by this file */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ + + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/* + * Feature: Define H5M_DEBUG on the compiler command line if you want to + * debug maps. NDEBUG must not be defined in order for this + * to have any effect. + */ +#ifdef NDEBUG +# undef H5M_DEBUG +#endif + +/* ======== Map creation property names ======== */ + +/* ======== Map access property names ======== */ +#define H5M_ACS_KEY_PREFETCH_SIZE_NAME "key_prefetch_size" /* Number of keys to prefetch during map iteration */ +#define H5M_ACS_KEY_ALLOC_SIZE_NAME "key_alloc_size" /* Initial allocation size for keys prefetched during map iteration */ + +/* Default temporary buffer size */ +#define H5D_TEMP_BUF_SIZE (1024 * 1024) + +/* Default I/O vector size */ +#define H5D_IO_VECTOR_SIZE 1024 + +/* Default VL allocation & free info */ +#define H5D_VLEN_ALLOC NULL +#define H5D_VLEN_ALLOC_INFO NULL +#define H5D_VLEN_FREE NULL +#define H5D_VLEN_FREE_INFO NULL + +/* Default virtual dataset list size */ +#define H5D_VIRTUAL_DEF_LIST_SIZE 8 + + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +#endif /* _H5Mprivate_H */ + diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h new file mode 100644 index 0000000..56c7d87 --- /dev/null +++ b/src/H5Mpublic.h @@ -0,0 +1,126 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5M module. + * + * NOTE: This is an experimental API. Everything in the H5M package + * is subject to revision in a future release. + */ +#ifndef _H5Mpublic_H +#define _H5Mpublic_H + +/* System headers needed by this file */ + +/* Public headers needed by this file */ +#include "H5public.h" +#include "H5Ipublic.h" + + +/*****************/ +/* Public Macros */ +/*****************/ + +/* Macros defining operation IDs for map VOL callbacks (implemented using the + * "optional" VOL callback) */ +#define H5VL_MAP_CREATE 1 +#define H5VL_MAP_OPEN 2 +#define H5VL_MAP_GET_VAL 3 +#define H5VL_MAP_EXISTS 4 +#define H5VL_MAP_SET 5 +#define H5VL_MAP_GET 6 +#define H5VL_MAP_SPECIFIC 7 +#define H5VL_MAP_CLOSE 8 + + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* types for map GET callback */ +typedef enum H5VL_map_get_t { + H5VL_MAP_GET_MAPL, /* map access property list */ + H5VL_MAP_GET_MCPL, /* map creation property list */ + H5VL_MAP_GET_KEY_TYPE, /* key type */ + H5VL_MAP_GET_VAL_TYPE, /* value type */ + H5VL_MAP_GET_COUNT /* key count */ +} H5VL_map_get_t; + +/* types for map SPECIFIC callback */ +typedef enum H5VL_map_specific_t { + H5VL_MAP_ITER, /* H5Miterate */ + H5VL_MAP_DELETE_KEY /* H5Mdelete_key */ +} H5VL_map_specific_t; + +/* Callback for H5Miterate() */ +typedef herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, void *op_data); + + +/********************/ +/* Public Variables */ +/********************/ + + +/*********************/ +/* Public Prototypes */ +/*********************/ +#ifdef __cplusplus +extern "C" { +#endif + +/* The map API is only built when requested since there's no support in + * the native file format at this time. It's only supported in a few VOL + * connectors. + */ +#ifdef H5_HAVE_MAP_API + +H5_DLL hid_t H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, + hid_t val_type_id, hid_t lcpl_id, hid_t mcpl_id, hid_t mapl_id); +H5_DLL hid_t H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, + hid_t mcpl_id, hid_t mapl_id); +H5_DLL hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id); +H5_DLL herr_t H5Mclose(hid_t map_id); +H5_DLL hid_t H5Mget_key_type(hid_t map_id); +H5_DLL hid_t H5Mget_val_type(hid_t map_id); +H5_DLL hid_t H5Mget_create_plist(hid_t map_id); +H5_DLL hid_t H5Mget_access_plist(hid_t map_id); +H5_DLL herr_t H5Mget_count(hid_t map_id, hsize_t *count, hid_t dxpl_id); +H5_DLL herr_t H5Mset(hid_t map_id, hid_t key_mem_type_id, const void *key, + hid_t val_mem_type_id, const void *value, hid_t dxpl_id); +H5_DLL herr_t H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, + hid_t val_mem_type_id, void *value, hid_t dxpl_id); +H5_DLL herr_t H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, + hbool_t *exists, hid_t dxpl_id); +H5_DLL herr_t H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, + H5M_iterate_t op, void *op_data, hid_t dxpl_id); +H5_DLL herr_t H5Miterate_by_name(hid_t loc_id, const char *map_name, + hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, + hid_t dxpl_id, hid_t lapl_id); +H5_DLL herr_t H5Mdelete_key(hid_t map_id, hid_t key_mem_type_id, + const void *key, hid_t dxpl_id); + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +#endif /* H5_HAVE_MAP_API */ + +#ifdef __cplusplus +} +#endif + +#endif /* _H5Mpublic_H */ + diff --git a/src/H5O.c b/src/H5O.c index 093d429..e7351fc 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1084,6 +1084,7 @@ H5Oclose(hid_t object_id) case H5I_GROUP: case H5I_DATATYPE: case H5I_DATASET: + case H5I_MAP: if(H5I_object(object_id) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") if(H5I_dec_app_ref(object_id) < 0) diff --git a/src/H5Oflush.c b/src/H5Oflush.c index f5ede4a..a03cfa1 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -479,6 +479,9 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_connector HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset") break; + case H5I_MAP: + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: diff --git a/src/H5Oint.c b/src/H5Oint.c index 45a8046..e37eea5 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -1836,6 +1836,9 @@ H5O_get_loc(hid_t object_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID") break; + case H5I_MAP: + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: diff --git a/src/H5Opublic.h b/src/H5Opublic.h index c868e72..234f4f0 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -94,6 +94,7 @@ typedef enum H5O_type_t { H5O_TYPE_GROUP, /* Object is a group */ H5O_TYPE_DATASET, /* Object is a dataset */ H5O_TYPE_NAMED_DATATYPE, /* Object is a named data type */ + H5O_TYPE_MAP, /* Object is a map */ H5O_TYPE_NTYPES /* Number of different object types (must be last!) */ } H5O_type_t; diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index 8b9962f..2a07a67 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -722,7 +722,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_MAX_TYPE) 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 5683403..36367d7 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -151,6 +151,10 @@ hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; +hid_t H5P_CLS_MAP_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_MAP_CREATE_g = NULL; +hid_t H5P_CLS_MAP_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_MAP_ACCESS_g = NULL; hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; @@ -180,6 +184,8 @@ hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID; hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_MAP_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_MAP_ACCESS_ID_g = H5I_INVALID_HID; hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID; @@ -314,6 +320,7 @@ H5_DLLVAR const H5P_libclass_t H5P_CLS_STRCRT[1]; /* String create */ H5_DLLVAR const H5P_libclass_t H5P_CLS_GCRT[1]; /* Group create */ H5_DLLVAR const H5P_libclass_t H5P_CLS_FCRT[1]; /* File creation */ H5_DLLVAR const H5P_libclass_t H5P_CLS_DCRT[1]; /* Dataset creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_MCRT[1]; /* Map creation */ 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 */ @@ -352,6 +359,8 @@ static H5P_libclass_t const * const init_class[] = { H5P_CLS_FMNT, /* File mount */ H5P_CLS_TCRT, /* Datatype creation */ H5P_CLS_TACC, /* Datatype access */ + H5P_CLS_MCRT, /* Map creation */ + H5P_CLS_MACC, /* Map access */ H5P_CLS_ACRT, /* Attribute creation */ H5P_CLS_AACC, /* Attribute access */ H5P_CLS_LCRT, /* Link creation */ @@ -431,7 +440,7 @@ H5P__init_package(void) FUNC_ENTER_PACKAGE /* Sanity check */ - HDcompile_assert(H5P_TYPE_VOL_INITIALIZE == (H5P_TYPE_MAX_TYPE - 1)); + HDcompile_assert(H5P_TYPE_MAP_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); /* * Initialize the Generic Property class & object groups. @@ -442,8 +451,8 @@ H5P__init_package(void) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") /* Repeatedly pass over the list of property list classes for the library, - * initializing each class if it's parent class is initialized, until no - * more progress is made. + * initializing each class if its parent class is initialized, until no + * more progress is made. */ tot_init = 0; do { @@ -547,6 +556,8 @@ H5P_term_package(void) H5P_LST_GROUP_ACCESS_ID_g = H5P_LST_DATATYPE_CREATE_ID_g = H5P_LST_DATATYPE_ACCESS_ID_g = + H5P_LST_MAP_CREATE_ID_g = + H5P_LST_MAP_ACCESS_ID_g = H5P_LST_ATTRIBUTE_CREATE_ID_g = H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5P_LST_OBJECT_COPY_ID_g = @@ -574,6 +585,8 @@ H5P_term_package(void) H5P_CLS_GROUP_ACCESS_g = H5P_CLS_DATATYPE_CREATE_g = H5P_CLS_DATATYPE_ACCESS_g = + H5P_CLS_MAP_CREATE_g = + H5P_CLS_MAP_ACCESS_g = H5P_CLS_STRING_CREATE_g = H5P_CLS_ATTRIBUTE_CREATE_g = H5P_CLS_ATTRIBUTE_ACCESS_g = @@ -594,6 +607,8 @@ H5P_term_package(void) H5P_CLS_GROUP_ACCESS_ID_g = H5P_CLS_DATATYPE_CREATE_ID_g = H5P_CLS_DATATYPE_ACCESS_ID_g = + H5P_CLS_MAP_CREATE_ID_g = + H5P_CLS_MAP_ACCESS_ID_g = H5P_CLS_STRING_CREATE_ID_g = H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5P_CLS_ATTRIBUTE_ACCESS_ID_g = @@ -5437,8 +5452,9 @@ H5P__new_plist_of_type(H5P_plist_type_t type) FUNC_ENTER_PACKAGE - /* Sanity check */ - HDassert(type >= H5P_TYPE_USER && type < H5P_TYPE_MAX_TYPE); + /* Sanity checks */ + HDcompile_assert(H5P_TYPE_MAP_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); + HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_MAP_ACCESS); /* Check arguments */ if(type == H5P_TYPE_USER) @@ -5492,6 +5508,14 @@ H5P__new_plist_of_type(H5P_plist_type_t type) class_id = H5P_CLS_DATATYPE_ACCESS_ID_g; break; + case H5P_TYPE_MAP_CREATE: + class_id = H5P_CLS_MAP_CREATE_ID_g; + break; + + case H5P_TYPE_MAP_ACCESS: + class_id = H5P_CLS_MAP_ACCESS_ID_g; + break; + case H5P_TYPE_STRING_CREATE: class_id = H5P_CLS_STRING_CREATE_ID_g; break; diff --git a/src/H5Pmapl.c b/src/H5Pmapl.c new file mode 100644 index 0000000..fe5be0f --- /dev/null +++ b/src/H5Pmapl.c @@ -0,0 +1,217 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Purpose: Map access property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Mprivate.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* ========= Map Access properties ============ */ +/* Definitions for key prefetch size */ +#define H5M_ACS_KEY_PREFETCH_SIZE_SIZE sizeof(size_t) +#define H5M_ACS_KEY_PREFETCH_SIZE_DEF (size_t)(16 * 1024) +#define H5M_ACS_KEY_PREFETCH_SIZE_ENC H5P__encode_size_t +#define H5M_ACS_KEY_PREFETCH_SIZE_DEC H5P__decode_size_t +/* Definition for key prefetch buffer size */ +#define H5M_ACS_KEY_ALLOC_SIZE_SIZE sizeof(size_t) +#define H5M_ACS_KEY_ALLOC_SIZE_DEF (size_t)(1024 * 1024) +#define H5M_ACS_KEY_ALLOC_SIZE_ENC H5P__encode_size_t +#define H5M_ACS_KEY_ALLOC_SIZE_DEC H5P__decode_size_t + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__macc_reg_prop(H5P_genclass_t *pclass); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Map access property list class library initialization object */ +const H5P_libclass_t H5P_CLS_MACC[1] = {{ + "map access", /* Class name for debugging */ + H5P_TYPE_MAP_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_MAP_ACCESS_g, /* Pointer to class */ + &H5P_CLS_MAP_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_MAP_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__macc_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__macc_reg_prop + * + * Purpose: Register the map access property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5P__macc_reg_prop(H5P_genclass_t *pclass) +{ + size_t key_prefetch_size = H5M_ACS_KEY_PREFETCH_SIZE_DEF; /* Default key prefetch size for iteration */ + size_t key_alloc_size = H5M_ACS_KEY_ALLOC_SIZE_DEF; /* Default key prefetch allocation size for iteration */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Register the key prefetch size for iteration */ + if(H5P__register_real(pclass, H5M_ACS_KEY_PREFETCH_SIZE_NAME, H5M_ACS_KEY_PREFETCH_SIZE_SIZE, &key_prefetch_size, + NULL, NULL, NULL, H5M_ACS_KEY_PREFETCH_SIZE_ENC, H5M_ACS_KEY_PREFETCH_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the key prefetch allocation size for iteration */ + if(H5P__register_real(pclass, H5M_ACS_KEY_ALLOC_SIZE_NAME, H5M_ACS_KEY_ALLOC_SIZE_SIZE, &key_alloc_size, + NULL, NULL, NULL, H5M_ACS_KEY_ALLOC_SIZE_ENC, H5M_ACS_KEY_ALLOC_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__macc_reg_prop() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_map_iterate_hints + * + * Purpose: H5Pset_map_iterate_hints adjusts the behavior of + * H5Miterate when prefetching keys for iteration. The + * KEY_PREFETCH_SIZE parameter specifies the number of keys + * to prefetch at a time during iteration. The KEY_ALLOC_SIZE + * parameter specifies the initial size of the buffer + * allocated to hold these prefetched keys. If this buffer is + * too small it will be reallocated to a larger size, though + * this may result in an additional I/O. + * + * Move to DAOS VOL code? DSINC + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_map_iterate_hints(hid_t mapl_id, size_t key_prefetch_size, size_t key_alloc_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "izz", mapl_id, key_prefetch_size, key_alloc_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Set sizes */ + if(H5P_set(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, &key_prefetch_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set key prefetch size"); + if(H5P_set(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, &key_alloc_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set key allocation size"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_map_iterate_hints() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_map_iterate_hints + * + * Purpose: Returns the map iterate hints, KEY_PREFETCH_SIZE and + * KEY_ALLOC_SIZE, as set by H5Pset_map_iterate_hints. + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size, size_t *key_alloc_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*z*z", mapl_id, key_prefetch_size, key_alloc_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Get the properties */ + if(key_prefetch_size) { + if(H5P_get(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, key_prefetch_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get key prefetch size"); + } /* end if */ + if(key_alloc_size) { + if(H5P_get(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, key_alloc_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get key allocation size"); + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_map_iterate_hints() */ + diff --git a/src/H5Pmcpl.c b/src/H5Pmcpl.c new file mode 100644 index 0000000..41a6659 --- /dev/null +++ b/src/H5Pmcpl.c @@ -0,0 +1,115 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Pmcpl.c + * + * Purpose: Map creation property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Mprivate.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__mcrt_reg_prop(H5P_genclass_t *pclass); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Map create property list class library initialization object */ +const H5P_libclass_t H5P_CLS_MCRT[1] = {{ + "map create", /* Class name for debugging */ + H5P_TYPE_MAP_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_MAP_CREATE_g, /* Pointer to class */ + &H5P_CLS_MAP_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_MAP_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__mcrt_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 Private Variables */ +/***************************/ + + + +/*------------------------------------------------------------------------- + * Function: H5P__mcrt_reg_prop + * + * Purpose: Register the map creation property list class's properties + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5P__mcrt_reg_prop(H5P_genclass_t H5_ATTR_UNUSED *pclass) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__mcrt_reg_prop() */ + diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 07910c3..9fc1acc 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -79,6 +79,8 @@ typedef enum H5P_plist_type_t { H5P_TYPE_LINK_ACCESS = 17, H5P_TYPE_ATTRIBUTE_ACCESS = 18, H5P_TYPE_VOL_INITIALIZE = 19, + H5P_TYPE_MAP_CREATE = 20, + H5P_TYPE_MAP_ACCESS = 21, H5P_TYPE_MAX_TYPE } H5P_plist_type_t; @@ -125,6 +127,8 @@ H5_DLLVAR H5P_genclass_t *H5P_CLS_GROUP_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_MAP_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_MAP_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_OBJECT_COPY_g; @@ -139,6 +143,7 @@ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_AACC[1]; /* Attribute access */ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_GACC[1]; /* Group access */ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_TACC[1]; /* Named datatype access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_MACC[1]; /* Map access */ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_FACC[1]; /* File access */ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index cad2071..43e477a 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -62,6 +62,8 @@ #define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) #define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) #define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) +#define H5P_MAP_CREATE (H5OPEN H5P_CLS_MAP_CREATE_ID_g) +#define H5P_MAP_ACCESS (H5OPEN H5P_CLS_MAP_ACCESS_ID_g) #define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) #define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) #define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) @@ -83,6 +85,8 @@ #define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) #define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) #define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) +#define H5P_MAP_CREATE_DEFAULT (H5OPEN H5P_LST_MAP_CREATE_ID_g) +#define H5P_MAP_ACCESS_DEFAULT (H5OPEN H5P_LST_MAP_ACCESS_ID_g) #define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) #define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) #define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) @@ -191,6 +195,8 @@ H5_DLLVAR hid_t H5P_CLS_GROUP_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_GROUP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_DATATYPE_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_DATATYPE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_MAP_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_MAP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_STRING_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g; @@ -211,6 +217,8 @@ H5_DLLVAR hid_t H5P_LST_GROUP_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_GROUP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_DATATYPE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_DATATYPE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_MAP_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_MAP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_ID_g; @@ -491,6 +499,12 @@ H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /* H5_DLL herr_t H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags); H5_DLL herr_t H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /* out */); +/* Map access property list (MAPL) routines */ +#ifdef H5_HAVE_MAP_API +H5_DLL herr_t H5Pset_map_iterate_hints(hid_t mapl_id, size_t key_prefetch_size, size_t key_alloc_size); +H5_DLL herr_t H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size /*out*/, size_t *key_alloc_size /*out*/); +#endif /* H5_HAVE_MAP_API */ + /* String creation property list (STRCPL) routines */ H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding); H5_DLL herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/); diff --git a/src/H5Rint.c b/src/H5Rint.c index 2355ec1..07efae2 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -472,6 +472,9 @@ H5R__dereference(H5F_t *file, hid_t oapl_id, H5R_type_t ref_type, const void *_r break; } + case H5O_TYPE_MAP: + HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, H5I_INVALID_HID, "maps not supported in native VOL connector") + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: diff --git a/src/H5T.c b/src/H5T.c index 8eada62..6ef9478 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1740,6 +1740,7 @@ H5Tcopy(hid_t obj_id) case H5I_GROUP: case H5I_DATASPACE: case H5I_ATTR: + case H5I_MAP: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index 696ccab..0131f0e 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -6562,3 +6562,114 @@ done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLrequest_free() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'optional' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if((ret_value = H5VL__optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, ret_value, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLoptional + * + * Purpose: Performs an optional connector-specific operation + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLoptional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__optional(obj, cls, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLoptional() */ + diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 9de518f..98bc521 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -314,7 +314,7 @@ typedef struct H5VL_group_class_t { /* H5L routines */ typedef struct H5VL_link_class_t { herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list argumenmts); + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req); diff --git a/src/H5VLint.c b/src/H5VLint.c index 884b2f6..f9262f4 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -552,7 +552,8 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t HDassert(vol_connector); /* Make sure type number is valid */ - if(type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE && type != H5I_FILE && type != H5I_GROUP) + if(type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE + && type != H5I_FILE && type != H5I_GROUP && type != H5I_MAP) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, NULL, "invalid type number") /* Create the new VOL object */ @@ -1408,6 +1409,7 @@ H5VL__object(hid_t id, H5I_type_t obj_type) case H5I_DATASET: case H5I_FILE: case H5I_ATTR: + case H5I_MAP: /* get the object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 91fa762..1752b0c 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -193,5 +193,8 @@ H5_DLL herr_t H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_s H5_DLL herr_t H5VL_request_optional(const H5VL_object_t *vol_obj, ...); H5_DLL herr_t H5VL_request_free(const H5VL_object_t *vol_obj); +/* Generic functions */ +H5_DLL herr_t H5VL_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id,void **req, ...); + #endif /* _H5VLprivate_H */ diff --git a/src/H5err.txt b/src/H5err.txt index d4edfba..9fec521 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -78,6 +78,7 @@ MAJOR, H5E_FARRAY, Fixed Array MAJOR, H5E_PLUGIN, Plugin for dynamically loaded library MAJOR, H5E_PAGEBUF, Page Buffering MAJOR, H5E_CONTEXT, API Context +MAJOR, H5E_MAP, Map MAJOR, H5E_NONE_MAJOR, No error # Sections (for grouping minor errors) diff --git a/src/H5private.h b/src/H5private.h index 00b7a07..89e59a0 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1721,6 +1721,7 @@ typedef enum { H5_PKG_HG, /* Global heaps */ H5_PKG_HL, /* Local heaps */ H5_PKG_I, /* IDs */ + H5_PKG_M, /* Maps */ H5_PKG_MF, /* File memory management */ H5_PKG_MM, /* Core memory management */ H5_PKG_O, /* Object headers */ @@ -2637,6 +2638,8 @@ H5_DLL int H5G_term_package(void); H5_DLL int H5G_top_term_package(void); H5_DLL int H5I_term_package(void); H5_DLL int H5L_term_package(void); +H5_DLL int H5M_term_package(void); +H5_DLL int H5M_top_term_package(void); H5_DLL int H5P_term_package(void); H5_DLL int H5PL_term_package(void); H5_DLL int H5R_term_package(void); diff --git a/src/H5trace.c b/src/H5trace.c index c5d14f5..de761f8 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1359,6 +1359,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (attr)", (long)obj); break; + case H5I_MAP: + HDfprintf(out, "%ld (map)", (long)obj); + break; + case H5I_VFL: HDfprintf(out, "%ld (file driver)", (long)obj); break; @@ -1544,6 +1548,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5I_ATTR"); break; + case H5I_MAP: + HDfprintf(out, "H5I_MAP"); + break; + case H5I_VFL: HDfprintf(out, "H5I_VFL"); break; @@ -1799,8 +1807,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5O_TYPE_NAMED_DATATYPE"); break; + case H5O_TYPE_MAP: + HDfprintf(out, "H5O_TYPE_MAP"); + break; + case H5O_TYPE_NTYPES: - HDfprintf(out, "H5O_TYPE_TYPES"); + HDfprintf(out, "H5O_TYPE_NTYPES"); break; default: diff --git a/src/Makefile.am b/src/Makefile.am index f737d5d..1e6578e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -78,6 +78,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5HG.c H5HGcache.c H5HGdbg.c H5HGquery.c \ H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c\ H5HP.c H5I.c H5Itest.c H5L.c H5Lexternal.c H5lib_settings.c \ + H5M.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ H5MM.c H5MP.c H5MPtest.c \ H5O.c H5Odeprec.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ @@ -95,8 +96,9 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \ H5Pdeprec.c H5Pdxpl.c H5Pencdec.c \ H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ - H5Pgcpl.c H5Pint.c \ - H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ + H5Pgcpl.c H5Pint.c H5Plapl.c H5Plcpl.c \ + H5Pmapl.c H5Pmcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c \ + H5Ptest.c \ H5PB.c \ H5PL.c H5PLint.c H5PLpath.c H5PLplugin_cache.c \ H5R.c H5Rint.c H5Rdeprec.c \ @@ -141,7 +143,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5FDfamily.h H5FDhdfs.h H5FDlog.h H5FDmpi.h H5FDmpio.h \ H5FDmulti.h H5FDros3.h H5FDsec2.h H5FDstdio.h H5FDwindows.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ - H5MMpublic.h H5Opublic.h H5Ppublic.h \ + H5Mpublic.h H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h H5PLpublic.h \ H5Rpublic.h H5Spublic.h H5Tpublic.h \ H5VLconnector.h H5VLconnector_passthru.h \ diff --git a/src/hdf5.h b/src/hdf5.h index 2201e9e..8367122 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -29,6 +29,7 @@ #include "H5Gpublic.h" /* Groups */ #include "H5Ipublic.h" /* ID management */ #include "H5Lpublic.h" /* Links */ +#include "H5Mpublic.h" /* Maps */ #include "H5MMpublic.h" /* Memory management */ #include "H5Opublic.h" /* Object headers */ #include "H5Ppublic.h" /* Property lists */ diff --git a/test/links.c b/test/links.c index f8be2b5..26b49d6 100644 --- a/test/links.c +++ b/test/links.c @@ -7108,6 +7108,9 @@ done: ret_value = -1; break; + case H5I_MAP: + /* TODO: Not supported in native file format yet */ + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: @@ -7197,6 +7200,9 @@ done: ret_value = -1; break; + case H5I_MAP: + /* TODO: Not supported in native file format yet */ + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: diff --git a/test/objcopy.c b/test/objcopy.c index 47a1065..489d6dd 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -1080,6 +1080,9 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if(H5Tequal(obj1_id, obj2_id) != TRUE) TEST_ERROR break; + case H5O_TYPE_MAP: + /* Maps not supported in native VOL connector */ + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: @@ -1138,6 +1141,9 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if(H5Tequal(obj1_id, obj2_id) != TRUE) TEST_ERROR break; + case H5O_TYPE_MAP: + /* Maps not supported in native VOL connector */ + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: @@ -1454,10 +1460,13 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR break; + case H5O_TYPE_MAP: + HDassert(0 && "maps not supported in native VOL connector"); + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: -HDassert(0 && "Unknown type of object"); + HDassert(0 && "Unknown type of object"); break; } /* end switch */ diff --git a/test/tfile.c b/test/tfile.c index 9e17c34..0fc391e 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1434,6 +1434,9 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, VERIFY(oid_list[i], did, "H5Fget_obj_ids"); break; + case H5I_MAP: + /* TODO: Not supported in native VOL connector yet */ + case H5I_UNINIT: case H5I_BADID: case H5I_DATATYPE: diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 17e3f18..5921609 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1140,6 +1140,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, H5_TOOLS_DATATYPE); break; + case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index a3cd7d9..e140fff 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -763,6 +763,7 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen } /* end if */ break; + case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 5519437..ee5ac12 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -914,6 +914,10 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo, printf(" %-10s %s", "datatype", path); break; + case H5O_TYPE_MAP: + printf(" %-10s %s", "map", path); + break; + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 5c47abd..821d2c7 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -393,6 +393,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR } break; + case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: @@ -1404,6 +1405,7 @@ obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *al handle_datatypes(handle_data->fid, path, NULL, 0, NULL); break; + case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: @@ -2143,6 +2145,7 @@ dump_extlink(hid_t group, const char *linkname, const char *objname) handle_datatypes(group, linkname, NULL, 0, objname); break; + case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 2fa9fd0..fc56433 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -346,6 +346,7 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ } break; + case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index 5f0452c..dd03f18 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -758,6 +758,7 @@ obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "datatype_stats failed"); break; + case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: -- cgit v0.12