summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-07 15:25:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-07 15:25:06 (GMT)
commitbc0b7c478f4d4857023baec12763e0fb5cb45222 (patch)
tree214f769be5409eac0cac65d2d4e5324adcf1d241 /src
parenteb36a96a79dd1cd6514794a18baac5f13ce633ae (diff)
downloadhdf5-bc0b7c478f4d4857023baec12763e0fb5cb45222.zip
hdf5-bc0b7c478f4d4857023baec12763e0fb5cb45222.tar.gz
hdf5-bc0b7c478f4d4857023baec12763e0fb5cb45222.tar.bz2
[svn-r12873] Decription:
Add support for reverse index lookup to v2 B-trees (needed for reverse index lookup of links in groups) Tested on: Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r--src/H5B2.c16
-rw-r--r--src/H5B2private.h3
-rw-r--r--src/H5Gdense.c4
3 files changed, 14 insertions, 9 deletions
diff --git a/src/H5B2.c b/src/H5B2.c
index 8e66aa3..3dd607e 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -490,7 +490,7 @@ done:
*/
herr_t
H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
- hsize_t idx, H5B2_found_t op, void *op_data)
+ H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data)
{
H5B2_t *bt2=NULL; /* Pointer to the B-tree header */
H5RC_t *bt2_shared=NULL; /* Pointer to ref-counter for shared B-tree info */
@@ -540,6 +540,10 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
if(idx >= curr_node_ptr.all_nrec)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree doesn't have that many records")
+ /* Check for reverse indexing and map requested index to appropriate forward index */
+ if(order == H5_ITER_DEC)
+ idx = curr_node_ptr.all_nrec - (idx + 1);
+
/* Walk down B-tree to find record or leaf node where record is located */
while(depth > 0) {
H5B2_internal_t *internal; /* Pointer to internal node in B-tree */
@@ -618,25 +622,25 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */
/* Lock B-tree leaf node */
- if (NULL == (leaf = H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), bt2_shared, H5AC_READ)))
+ if(NULL == (leaf = H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), bt2_shared, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Sanity check index */
HDassert(idx < leaf->nrec);
/* Make callback for correct record */
- if ((op)(H5B2_LEAF_NREC(leaf,shared,idx), op_data) <0) {
+ if((op)(H5B2_LEAF_NREC(leaf,shared,idx), op_data) < 0) {
/* Unlock current node */
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(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")
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
} /* end if */
/* Unlock current node */
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(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")
- }
+ } /* end block */
done:
/* Check if we need to decrement the reference count for the B-tree's shared info */
diff --git a/src/H5B2private.h b/src/H5B2private.h
index 2ed9555..c262056 100644
--- a/src/H5B2private.h
+++ b/src/H5B2private.h
@@ -129,7 +129,8 @@ H5_DLL herr_t H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
H5_DLL herr_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 herr_t H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
- haddr_t addr, hsize_t idx, H5B2_found_t op, void *op_data);
+ haddr_t addr, 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);
diff --git a/src/H5Gdense.c b/src/H5Gdense.c
index 52aa5ce..46ba593 100644
--- a/src/H5Gdense.c
+++ b/src/H5Gdense.c
@@ -971,7 +971,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
/* Retrieve the name according to the v2 B-tree's index order */
/* (XXX: using name index currently) */
- if(H5B2_index(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, idx,
+ if(H5B2_index(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, H5_ITER_INC, idx,
H5G_dense_get_name_by_idx_bt2_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "can't locate object in v2 B-tree")
@@ -1125,7 +1125,7 @@ H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
/* Retrieve the name according to the v2 B-tree's index order */
/* (XXX: using name index currently) */
- if(H5B2_index(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, idx,
+ if(H5B2_index(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, H5_ITER_INC, idx,
H5G_dense_get_type_by_idx_bt2_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "can't locate object in v2 B-tree")