summaryrefslogtreecommitdiffstats
path: root/src/H5B2stat.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-15 03:51:39 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-15 03:51:39 (GMT)
commit218469b0ac56c6a9910b59d6e6b4ebb7c49120db (patch)
tree5d9cb062b6f108ad9f8f9cc44ac0a9f62e8e0ab0 /src/H5B2stat.c
parentb6e30d9c7951829b16e6b56a0fdc8eacc72b0c48 (diff)
downloadhdf5-218469b0ac56c6a9910b59d6e6b4ebb7c49120db.zip
hdf5-218469b0ac56c6a9910b59d6e6b4ebb7c49120db.tar.gz
hdf5-218469b0ac56c6a9910b59d6e6b4ebb7c49120db.tar.bz2
[svn-r17894] Description:
Bring r17893 from trunk to 1.8 branch: Remove old shim H5B2 routines from refactoring, rename new routines to old routine names and switch all users of the H5B2 interface back to the old routine names now that the switch to using the more current open -> <operation> -> pattern is used for all the H5B2 code. This is the final change before adding a context to the H5B2 client encode/decode callbacks. Tested on: FreeBSD/32 6.3 (duty) in debug mode (h5committested on trunk)
Diffstat (limited to 'src/H5B2stat.c')
-rw-r--r--src/H5B2stat.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/src/H5B2stat.c b/src/H5B2stat.c
index 391d96d..0ee404e 100644
--- a/src/H5B2stat.c
+++ b/src/H5B2stat.c
@@ -71,7 +71,7 @@
/*-------------------------------------------------------------------------
- * Function: H5B2_stat_info_2
+ * Function: H5B2_stat_info
*
* Purpose: Retrieve metadata statistics for a v2 B-tree
*
@@ -84,11 +84,11 @@
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_stat_info_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_stat_t *info)
+H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info)
{
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_stat_info_2)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_stat_info)
/* Check arguments. */
HDassert(info);
@@ -104,49 +104,55 @@ H5B2_stat_info_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_stat_t *info)
info->nrecords = hdr->root.all_nrec;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5B2_stat_info_2() */
+} /* H5B2_stat_info() */
/*-------------------------------------------------------------------------
- * Function: H5B2_stat_info
+ * Function: H5B2_size
*
- * Purpose: Retrieve metadata statistics for a v2 B-tree
+ * Purpose: Iterate over all the records in the B-tree, collecting
+ * storage info.
*
- * Return: Success: non-negative
+ * Return: non-negative on success, negative on error
*
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Monday, March 6, 2006
+ * Programmer: Vailin Choi
+ * June 19 2007
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_stat_info(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5B2_stat_t *info)
+H5B2_size(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size)
{
- H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5B2_stat_info)
+ FUNC_ENTER_NOAPI(H5B2_size, FAIL)
/* Check arguments. */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(info);
+ HDassert(bt2);
+ HDassert(btree_size);
- /* Look up the B-tree header */
- if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, NULL, H5AC_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
+ /* Set the shared v2 B-tree header's file context for this operation */
+ bt2->hdr->f = bt2->f;
- /* Get information about the B-tree */
- info->depth = hdr->depth;
- info->nrecords = hdr->root.all_nrec;
+ /* Get the v2 B-tree header */
+ hdr = bt2->hdr;
-done:
- /* Release B-tree header node */
- if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
+ /* Add size of header to B-tree metadata total */
+ *btree_size += H5B2_HEADER_SIZE(hdr);
+
+ /* Iterate through records */
+ if(hdr->root.node_nrec > 0) {
+ /* Check for root node being a leaf */
+ if(hdr->depth == 0)
+ *btree_size += hdr->node_size;
+ else
+ /* Iterate through nodes */
+ if(H5B2_node_size(hdr, dxpl_id, hdr->depth, &hdr->root, btree_size) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed")
+ } /* end if */
+done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_stat_info() */
+} /* H5B2_size() */