summaryrefslogtreecommitdiffstats
path: root/src/H5B2int.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5B2int.c')
-rw-r--r--src/H5B2int.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/H5B2int.c b/src/H5B2int.c
index 5d71d43..20e4300 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -3304,4 +3304,63 @@ H5B2_assert_internal2(hsize_t parent_all_nrec, H5B2_shared_t *shared, H5B2_inter
return(0);
} /* end H5B2_assert_internal2() */
#endif /* H5B2_DEBUG */
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_info_iterate_node
+ *
+ * Purpose: Iterate over all the records from a B-tree node, collecting
+ * btree storage info.
+ *
+ * Return: non-negative on success, negative on error
+ *
+ * Programmer: Vailin Choi
+ * July 12 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_info_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
+const H5B2_node_ptr_t *curr_node, hsize_t *btree_size)
+{
+ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
+ herr_t ret_value = SUCCEED; /* Iterator return value */
+ H5B2_internal_t *internal = NULL; /* Pointer to internal node */
+ unsigned u; /* Local index */
+
+ FUNC_ENTER_NOAPI(H5B2_info_iterate_node, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(bt2_shared);
+ HDassert(curr_node);
+ HDassert(btree_size);
+
+ /* Get the pointer to the shared B-tree info */
+ shared=(H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared);
+ HDassert(shared);
+
+
+ if(depth > 0) {
+ /* Lock the current B-tree node */
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
+
+ if(depth>1) {
+ /* Descend into children */
+ for(u=0; u<internal->nrec+1; u++)
+ if(H5B2_info_iterate_node(f, dxpl_id, bt2_shared, (depth-1), &(internal->node_ptrs[u]), btree_size) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed")
+ } /* end if */
+ else /* depth is 1: count all the leaf nodes from this node */
+ *btree_size += (internal->nrec + 1) * shared->node_size;
+ } /* end if */
+
+ /* Count this node */
+ *btree_size += shared->node_size;
+done:
+ if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_info_iterate_node() */