summaryrefslogtreecommitdiffstats
path: root/src/H5HF.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-09-11 17:25:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-09-11 17:25:26 (GMT)
commite5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe (patch)
tree0a33a38538477c1705f93a0b92a2ba84828ff6f4 /src/H5HF.c
parent9e158b781668387bf82fbab9d60ece304f0e9729 (diff)
downloadhdf5-e5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe.zip
hdf5-e5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe.tar.gz
hdf5-e5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe.tar.bz2
[svn-r12655] Description:
Add "op" routine to perform operation on heap object "in situ", to allow for faster operations on dense links during B-tree traversal & lookup. Refactor the "read" routine to use the internal version of the "op" routine, to keep the code duplication as low as possible. Tested on: Mac OS X.4/PPC (amazon) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5HF.c')
-rw-r--r--src/H5HF.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/H5HF.c b/src/H5HF.c
index a457f52..338512ae 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -83,6 +83,31 @@ H5FL_DEFINE_STATIC(H5HF_t);
/*-------------------------------------------------------------------------
+ * Function: H5HF_op_memcpy
+ *
+ * Purpose: Performs a 'memcpy' operation for a heap 'op' callback
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Sep 11 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_op_memcpy(const void *obj, size_t obj_len, void *op_data)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_op_memcpy)
+
+ /* Perform memcpy() */
+ HDmemcpy(op_data, obj, obj_len);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5HF_op_memcpy() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_create
*
* Purpose: Creates a new empty fractal heap in the file.
@@ -496,6 +521,69 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5HF_op
+ *
+ * Purpose: Perform an operation directly on a heap object
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Sept 11 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_op(H5HF_t *fh, hid_t dxpl_id, const void *_id, H5HF_operator_t op,
+ void *op_data)
+{
+ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
+ uint8_t id_flags; /* Heap ID flag bits */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5HF_op, FAIL)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(fh);
+ HDassert(id);
+ HDassert(op);
+
+ /* Get the ID flags */
+ id_flags = *id;
+
+ /* Check for correct heap ID version */
+ if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
+ HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
+
+ /* Check type of object in heap */
+ if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
+ /* Operate on object from managed heap blocks */
+ if(H5HF_man_op(fh->hdr, dxpl_id, id, op, op_data) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on object from fractal heap")
+ } /* end if */
+ else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
+ /* Operate on 'huge' object from file */
+ if(H5HF_huge_op(fh->hdr, dxpl_id, id, op, op_data) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'huge' object from fractal heap")
+ } /* end if */
+ else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
+ /* Operate on 'tiny' object from file */
+ if(H5HF_tiny_op(fh->hdr, id, op, op_data) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'tiny' object from fractal heap")
+ } /* end if */
+ else {
+HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_op() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_remove
*
* Purpose: Remove an object from a fractal heap