summaryrefslogtreecommitdiffstats
path: root/src/H5VLnative_blob.c
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2019-10-09 20:45:26 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2019-10-09 20:45:26 (GMT)
commit984c1bacd93c2f782c75c02d88d6e5c0362c74d0 (patch)
tree97bf7d8b15caee53eb8fdfd84eb09316b54903f1 /src/H5VLnative_blob.c
parent19c2eb2800a48d0bd5a8af7757e21cc5cd22fa3c (diff)
parent5d2545ee26d4b7013ed363545705f16a67087549 (diff)
downloadhdf5-984c1bacd93c2f782c75c02d88d6e5c0362c74d0.zip
hdf5-984c1bacd93c2f782c75c02d88d6e5c0362c74d0.tar.gz
hdf5-984c1bacd93c2f782c75c02d88d6e5c0362c74d0.tar.bz2
Merge pull request #1990 in HDFFV/hdf5 from ~JSOUMAGNE/hdf5:references_1_12 to hdf5_1_12
* commit '5d2545ee26d4b7013ed363545705f16a67087549': Fix func enter macro in H5T_ref_reclaim() Update RELEASE.txt for reference changes Fix reference type comparison in h5dump Make wrappers, tests and tools use H5Treclaim() instead of H5Dvlen_reclaim() Add new H5R API that abstracts object, region and attribute reference types Remove ability to loc by ref from H5VL layer Add support for retrieving object name by token Add H5VL_OBJECT_GET_TYPE to get object type Add H5VL_MAX_TOKEN_SIZE and H5VL_token_t Adapt Jerome's "file info" H5VL 'get' query to retrieve container token info. Fix H5VL_blob_get to return size of blob Add 'blob' callbacks to VOL, along with a native implementation to store them in the global heap, and changed the VL datatype conversion code to use blobs.
Diffstat (limited to 'src/H5VLnative_blob.c')
-rw-r--r--src/H5VLnative_blob.c237
1 files changed, 237 insertions, 0 deletions
diff --git a/src/H5VLnative_blob.c b/src/H5VLnative_blob.c
new file mode 100644
index 0000000..b16b407
--- /dev/null
+++ b/src/H5VLnative_blob.c
@@ -0,0 +1,237 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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: Blob callbacks for the native VOL connector
+ */
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5HGprivate.h" /* Global Heaps */
+#include "H5VLnative_private.h" /* Native VOL connector */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__native_blob_put
+ *
+ * Purpose: Handles the blob 'put' callback
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Friday, August 15, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id,
+ void H5_ATTR_UNUSED *ctx)
+{
+ H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */
+ uint8_t *id = (uint8_t *)blob_id; /* Pointer to blob ID */
+ H5HG_t hobjid; /* New VL sequence's heap ID */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Check parameters */
+ HDassert(f);
+ HDassert(size == 0 || buf);
+ HDassert(id);
+
+ /* Write the VL information to disk (allocates space also) */
+ if(H5HG_insert(f, size, (void *)buf, &hobjid) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write blob information")
+
+ /* Encode the heap information */
+ H5F_addr_encode(f, &id, hobjid.addr);
+ UINT32ENCODE(id, hobjid.idx);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__native_blob_put() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__native_blob_get
+ *
+ * Purpose: Handles the blob 'get' callback
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Friday, August 15, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t *size,
+ void H5_ATTR_UNUSED *ctx)
+{
+ H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */
+ const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the disk blob ID */
+ H5HG_t hobjid; /* Global heap ID for sequence */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(id);
+ HDassert(buf);
+
+ /* Get the heap information */
+ H5F_addr_decode(f, &id, &hobjid.addr);
+ UINT32DECODE(id, hobjid.idx);
+
+ /* Check if this sequence actually has any data */
+ if(hobjid.addr > 0)
+ /* Read the VL information from disk */
+ if(NULL == H5HG_read(f, &hobjid, buf, size))
+ HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read VL information")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__native_blob_get() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__native_blob_specific
+ *
+ * Purpose: Handles the blob 'specific' callback
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Friday, August 15, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL__native_blob_specific(void *obj, void *blob_id,
+ H5VL_blob_specific_t specific_type, va_list arguments)
+{
+ H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(blob_id);
+
+ switch(specific_type) {
+ case H5VL_BLOB_GETSIZE:
+ {
+ const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */
+ size_t *size = HDva_arg(arguments, size_t *);
+ H5HG_t hobjid; /* blob's heap ID */
+
+ /* Get heap information */
+ H5F_addr_decode(f, &id, &(hobjid.addr));
+ UINT32DECODE(id, hobjid.idx);
+
+ /* Free heap object */
+ if(hobjid.addr > 0) {
+ if(H5HG_get_obj_size(f, &hobjid, size) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object")
+ } /* end if */
+ else
+ *size = 0; /* Return '0' size for 'nil' blob ID */
+
+ break;
+ }
+
+ case H5VL_BLOB_ISNULL:
+ {
+ const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */
+ hbool_t *isnull = HDva_arg(arguments, hbool_t *);
+ haddr_t addr; /* Sequence's heap address */
+
+ /* Get the heap address */
+ H5F_addr_decode(f, &id, &addr);
+
+ /* Check if heap address is 'nil' */
+ *isnull = (addr == 0 ? TRUE : FALSE);
+
+ break;
+ }
+
+ case H5VL_BLOB_SETNULL:
+ {
+ uint8_t *id = (uint8_t *)blob_id; /* Pointer to the blob ID */
+ /* Encode the "nil" heap pointer information */
+ H5F_addr_encode(f, &id, (haddr_t)0);
+ UINT32ENCODE(id, 0);
+
+ break;
+ }
+
+ case H5VL_BLOB_DELETE:
+ {
+ const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */
+ H5HG_t hobjid; /* VL sequence's heap ID */
+
+ /* Get heap information */
+ H5F_addr_decode(f, &id, &hobjid.addr);
+ UINT32DECODE(id, hobjid.idx);
+
+ /* Free heap object */
+ if(hobjid.addr > 0)
+ if(H5HG_remove(f, &hobjid) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object")
+
+ break;
+ }
+
+ default:
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__native_blob_specific() */