diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-07 15:25:06 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-07 15:25:06 (GMT) |
commit | bc0b7c478f4d4857023baec12763e0fb5cb45222 (patch) | |
tree | 214f769be5409eac0cac65d2d4e5324adcf1d241 /src/H5B2.c | |
parent | eb36a96a79dd1cd6514794a18baac5f13ce633ae (diff) | |
download | hdf5-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/H5B2.c')
-rw-r--r-- | src/H5B2.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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 */ |