summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-07 13:12:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-07 13:12:06 (GMT)
commite8f31a24797a129fd8ed2c7ec5e2a080d0b5fb88 (patch)
tree41ef126f79131fbafb8c5826a6628ba8b3be1c65 /src
parent401f0c995f4c28d3bf4c15c859f0195bba70bdd3 (diff)
downloadhdf5-e8f31a24797a129fd8ed2c7ec5e2a080d0b5fb88.zip
hdf5-e8f31a24797a129fd8ed2c7ec5e2a080d0b5fb88.tar.gz
hdf5-e8f31a24797a129fd8ed2c7ec5e2a080d0b5fb88.tar.bz2
[svn-r17848] Description:
Further refactoring v2 B-trees so that they can get context to the encode/decode client callbacks: - Switch tests to using refactored routines Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.1 (amazon) in debug mode Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5B2.c44
-rw-r--r--src/H5B2pkg.h4
-rw-r--r--src/H5B2private.h25
-rw-r--r--src/H5B2stat.c37
-rw-r--r--src/H5B2test.c184
5 files changed, 260 insertions, 34 deletions
diff --git a/src/H5B2.c b/src/H5B2.c
index ec9931d..7c613bf 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -61,26 +61,6 @@
/********************/
/* Local Prototypes */
/********************/
-static H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr);
-static herr_t H5B2_insert_2(H5B2_t *bt2, hid_t dxpl_id, void *udata);
-static herr_t H5B2_iterate_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op,
- void *op_data);
-static htri_t H5B2_find_2(H5B2_t *bt2, hid_t dxpl_id, void *udata,
- H5B2_found_t op, void *op_data);
-static herr_t H5B2_index_2(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
- hsize_t idx, H5B2_found_t op, void *op_data);
-static herr_t H5B2_remove_2(H5B2_t *b2, hid_t dxpl_id, void *udata,
- H5B2_remove_t op, void *op_data);
-static herr_t H5B2_remove_by_idx_2(H5B2_t *bt2, hid_t dxpl_id,
- H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, void *op_data);
-static herr_t H5B2_get_nrec_2(const H5B2_t *bt2, hsize_t *nrec);
-static herr_t H5B2_neighbor_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range,
- void *udata, H5B2_found_t op, void *op_data);
-static herr_t H5B2_modify_2(H5B2_t *bt2, hid_t dxpl_id, void *udata,
- H5B2_modify_t op, void *op_data);
-static herr_t H5B2_iterate_size_2(H5B2_t *bt2, hid_t dxpl_id,
- hsize_t *btree_size);
-static herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id);
/*********************/
@@ -258,7 +238,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5B2_t *
+H5B2_t *
H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
@@ -322,7 +302,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_insert_2(H5B2_t *bt2, hid_t dxpl_id, void *udata)
{
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
@@ -464,7 +444,7 @@ H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr_p)
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_iterate_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op, void *op_data)
{
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
@@ -565,7 +545,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static htri_t
+htri_t
H5B2_find_2(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op,
void *op_data)
{
@@ -756,7 +736,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_index_2(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order, hsize_t idx,
H5B2_found_t op, void *op_data)
{
@@ -962,7 +942,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_remove_2(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_remove_t op,
void *op_data)
{
@@ -1079,7 +1059,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_remove_by_idx_2(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
hsize_t idx, H5B2_remove_t op, void *op_data)
{
@@ -1205,7 +1185,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_get_nrec_2(const H5B2_t *bt2, hsize_t *nrec)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_get_nrec_2)
@@ -1291,7 +1271,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_neighbor_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range, void *udata,
H5B2_found_t op, void *op_data)
{
@@ -1406,7 +1386,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_modify_2(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op,
void *op_data)
{
@@ -1614,7 +1594,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_iterate_size_2(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size)
{
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
@@ -1709,7 +1689,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5B2_close(H5B2_t *bt2, hid_t dxpl_id)
{
haddr_t bt2_addr = HADDR_UNDEF; /* Address of v2 B-tree (for deletion) */
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h
index c4f3f55..b8cea53 100644
--- a/src/H5B2pkg.h
+++ b/src/H5B2pkg.h
@@ -333,11 +333,15 @@ H5_DLL herr_t H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
#ifdef H5B2_TESTING
H5_DLL herr_t H5B2_get_root_addr_test(H5F_t *f, hid_t dxpl_id,
const H5B2_class_t *type, haddr_t addr, haddr_t *root_addr);
+H5_DLL herr_t H5B2_get_root_addr_test_2(H5B2_t *bt2, haddr_t *root_addr);
H5_DLL int H5B2_get_node_depth_test(H5F_t *f, hid_t dxpl_id,
const H5B2_class_t *type, haddr_t addr, void *udata);
+H5_DLL int H5B2_get_node_depth_test_2(H5B2_t *bt2, hid_t dxpl_id, void *udata);
H5_DLL herr_t H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id,
const H5B2_class_t *type, haddr_t addr, void *udata,
H5B2_node_info_test_t *ninfo);
+H5_DLL herr_t H5B2_get_node_info_test_2(H5B2_t *bt2, hid_t dxpl_id,
+ void *udata, H5B2_node_info_test_t *ninfo);
#endif /* H5B2_TESTING */
#endif /* _H5B2pkg_H */
diff --git a/src/H5B2private.h b/src/H5B2private.h
index a97e332..ed3447b 100644
--- a/src/H5B2private.h
+++ b/src/H5B2private.h
@@ -131,36 +131,57 @@ typedef struct H5B2_t H5B2_t;
H5_DLL herr_t H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam,
haddr_t *addr_p);
H5_DLL H5B2_t *H5B2_create_2(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam);
+H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr);
H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr/*out*/);
H5_DLL herr_t H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, void *udata);
+H5_DLL herr_t H5B2_insert_2(H5B2_t *bt2, hid_t dxpl_id, void *udata);
H5_DLL herr_t H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, H5B2_operator_t op, void *op_data);
-H5_DLL herr_t H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
- haddr_t addr, hsize_t *op_data);
+H5_DLL herr_t H5B2_iterate_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op,
+ void *op_data);
H5_DLL htri_t H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, void *udata, H5B2_found_t op, void *op_data);
+H5_DLL htri_t H5B2_find_2(H5B2_t *bt2, hid_t dxpl_id, void *udata,
+ H5B2_found_t op, void *op_data);
H5_DLL herr_t H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, H5_iter_order_t order, hsize_t idx, H5B2_found_t op,
void *op_data);
+H5_DLL herr_t H5B2_index_2(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
+ hsize_t idx, H5B2_found_t op, void *op_data);
H5_DLL herr_t H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, H5B2_compare_t comp, void *udata, H5B2_found_t op,
void *op_data);
+H5_DLL herr_t H5B2_neighbor_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range,
+ void *udata, H5B2_found_t op, void *op_data);
H5_DLL herr_t H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, void *udata, H5B2_modify_t op, void *op_data);
+H5_DLL herr_t H5B2_modify_2(H5B2_t *bt2, hid_t dxpl_id, void *udata,
+ H5B2_modify_t op, void *op_data);
H5_DLL herr_t H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, void *udata, H5B2_remove_t op, void *op_data);
+H5_DLL herr_t H5B2_remove_2(H5B2_t *b2, hid_t dxpl_id, void *udata,
+ H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op,
void *op_data);
+H5_DLL herr_t H5B2_remove_by_idx_2(H5B2_t *bt2, hid_t dxpl_id,
+ H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_get_nrec(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, hsize_t *nrec);
+H5_DLL herr_t H5B2_get_nrec_2(const H5B2_t *bt2, hsize_t *nrec);
+H5_DLL herr_t H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
+ haddr_t addr, hsize_t *op_data);
+H5_DLL herr_t H5B2_iterate_size_2(H5B2_t *bt2, hid_t dxpl_id,
+ hsize_t *btree_size);
+H5_DLL herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id);
H5_DLL herr_t H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr,
H5B2_remove_t op, void *op_data);
/* Statistics routines */
H5_DLL herr_t H5B2_stat_info(H5F_t *f, hid_t dxpl_id, haddr_t addr,
H5B2_stat_t *info);
+H5_DLL herr_t H5B2_stat_info_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_stat_t *info);
#endif /* _H5B2private_H */
diff --git a/src/H5B2stat.c b/src/H5B2stat.c
index a5301de..391d96d 100644
--- a/src/H5B2stat.c
+++ b/src/H5B2stat.c
@@ -71,6 +71,43 @@
/*-------------------------------------------------------------------------
+ * Function: H5B2_stat_info_2
+ *
+ * Purpose: Retrieve metadata statistics for a v2 B-tree
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Monday, March 6, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_stat_info_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_stat_t *info)
+{
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_stat_info_2)
+
+ /* Check arguments. */
+ HDassert(info);
+
+ /* Set the shared v2 B-tree header's file context for this operation */
+ bt2->hdr->f = bt2->f;
+
+ /* Get the v2 B-tree header */
+ hdr = bt2->hdr;
+
+ /* Get information about the B-tree */
+ info->depth = hdr->depth;
+ info->nrecords = hdr->root.all_nrec;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5B2_stat_info_2() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_stat_info
*
* Purpose: Retrieve metadata statistics for a v2 B-tree
diff --git a/src/H5B2test.c b/src/H5B2test.c
index 6722c28..28f6dc2 100644
--- a/src/H5B2test.c
+++ b/src/H5B2test.c
@@ -222,6 +222,35 @@ H5B2_test_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id,
/*-------------------------------------------------------------------------
+ * Function: H5B2_get_root_addr_test_2
+ *
+ * Purpose: Retrieve the root node's address
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, February 26, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_get_root_addr_test_2(H5B2_t *bt2, haddr_t *root_addr)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_get_root_addr_test_2)
+
+ /* Check arguments. */
+ HDassert(bt2);
+ HDassert(root_addr);
+
+ /* Get B-tree root addr */
+ *root_addr = bt2->hdr->root.addr;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5B2_get_root_addr_test_2() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_get_root_addr_test
*
* Purpose: Retrieve the root node's address
@@ -267,6 +296,122 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B2_get_node_info_test_2
+ *
+ * Purpose: Determine information about a node holding a record in the B-tree
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 31, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_get_node_info_test_2(H5B2_t *bt2, hid_t dxpl_id, void *udata,
+ H5B2_node_info_test_t *ninfo)
+{
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */
+ unsigned depth; /* Current depth of the tree */
+ int cmp; /* Comparison value of records */
+ unsigned idx; /* Location of record which matches key */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_get_node_info_test_2, FAIL)
+
+ /* Check arguments. */
+ HDassert(bt2);
+
+ /* Set the shared v2 B-tree header's file context for this operation */
+ bt2->hdr->f = bt2->f;
+
+ /* Get the v2 B-tree header */
+ hdr = bt2->hdr;
+
+ /* Make copy of the root node pointer to start search with */
+ curr_node_ptr = hdr->root;
+
+ /* Current depth of the tree */
+ depth = hdr->depth;
+
+ /* Check for empty tree */
+ if(0 == curr_node_ptr.node_nrec)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records")
+
+ /* Walk down B-tree to find record or leaf node where record is located */
+ cmp = -1;
+ while(depth > 0 && cmp != 0) {
+ H5B2_internal_t *internal; /* Pointer to internal node in B-tree */
+ H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
+
+ /* Lock B-tree current node */
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
+
+ /* Locate node pointer for child */
+ cmp = H5B2_locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx);
+ if(cmp > 0)
+ idx++;
+
+ if(cmp != 0) {
+ /* Get node pointer for next node to search */
+ next_node_ptr = internal->node_ptrs[idx];
+
+ /* Unlock current node */
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
+
+ /* Set pointer to next node to load */
+ curr_node_ptr = next_node_ptr;
+ } /* end if */
+ else {
+ /* Unlock current node */
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
+
+ /* Fill in information about the node */
+ ninfo->depth = depth;
+ ninfo->nrec = curr_node_ptr.node_nrec;
+
+ /* Indicate success */
+ HGOTO_DONE(SUCCEED)
+ } /* end else */
+
+ /* Decrement depth we're at in B-tree */
+ depth--;
+ } /* end while */
+
+ {
+ H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */
+
+ /* Lock B-tree leaf node */
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), hdr, H5AC_READ)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
+
+ /* Locate record */
+ cmp = H5B2_locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx);
+
+ /* Unlock current node */
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
+
+ /* Indicate the depth that the record was found */
+ if(cmp != 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record not in B-tree")
+ } /* end block */
+
+ /* Fill in information about the leaf node */
+ ninfo->depth = depth;
+ ninfo->nrec = curr_node_ptr.node_nrec;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_get_node_info_test_2() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_get_node_info_test
*
* Purpose: Determine information about a node holding a record in the B-tree
@@ -390,6 +535,45 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B2_get_node_depth_test_2
+ *
+ * Purpose: Determine the depth of a node holding a record in the B-tree
+ *
+ * Note: Just a simple wrapper around the H5B2_get_node_info_test() routine
+ *
+ * Return: Success: non-negative depth of the node where the record
+ * was found
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, August 26, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5B2_get_node_depth_test_2(H5B2_t *bt2, hid_t dxpl_id, void *udata)
+{
+ H5B2_node_info_test_t ninfo; /* Node information */
+ int ret_value; /* Return information */
+
+ FUNC_ENTER_NOAPI(H5B2_get_node_depth_test_2, FAIL)
+
+ /* Check arguments. */
+ HDassert(bt2);
+
+ /* Get information abou the node */
+ if(H5B2_get_node_info_test_2(bt2, dxpl_id, udata, &ninfo) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "error looking up node info")
+
+ /* Set return value */
+ ret_value = (int)ninfo.depth;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_get_node_depth_test_2() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_get_node_depth_test
*
* Purpose: Determine the depth of a node holding a record in the B-tree