diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-10-23 20:11:11 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-10-23 20:11:11 (GMT) |
commit | 663919aa50f3c1d270239e06794c3fc6fff1ad9f (patch) | |
tree | e216367ffb327004461dd832c46b10044979cd21 /src/H5B2pkg.h | |
parent | 7fcd1375d81540e10f96c39d2ded53e34a3fe474 (diff) | |
download | hdf5-663919aa50f3c1d270239e06794c3fc6fff1ad9f.zip hdf5-663919aa50f3c1d270239e06794c3fc6fff1ad9f.tar.gz hdf5-663919aa50f3c1d270239e06794c3fc6fff1ad9f.tar.bz2 |
[svn-r17738] Description:
Bring revisions 17649, 17657 and 17658 from trunk to 1.8 branch:
17649: Refactor v2 B-trees to pin the B-tree header in the cache instead
of using separate reference counted data structure.
17657: Refactor the v2 B-tree code to use an open & close call
internally, in preparation for making those part of the library
private APIs for dealing with v2 B-trees.
17658: Rename 'H5B2_t' -> 'H5B2_hdr_t' and 'bt2' -> 'hdr' in preparation
for make v2 B-tree open/close routines library private (instead
of static).
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/H5B2pkg.h')
-rw-r--r-- | src/H5B2pkg.h | 106 |
1 files changed, 56 insertions, 50 deletions
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index c5af54f..80e53cd 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -34,7 +34,7 @@ /* Other private headers needed by this file */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5FLprivate.h" /* Free Lists */ -#include "H5RCprivate.h" /* Reference counted object functions */ + /**************************/ /* Package Private Macros */ @@ -98,13 +98,18 @@ ) /* Macro to retrieve pointer to i'th native record for native record buffer */ -#define H5B2_NAT_NREC(b, shared, idx) ((b) + (shared)->nat_off[(idx)]) +#define H5B2_NAT_NREC(b, hdr, idx) ((b) + (hdr)->nat_off[(idx)]) /* Macro to retrieve pointer to i'th native record for internal node */ -#define H5B2_INT_NREC(i, shared, idx) H5B2_NAT_NREC((i)->int_native, (shared), (idx)) +#define H5B2_INT_NREC(i, hdr, idx) H5B2_NAT_NREC((i)->int_native, (hdr), (idx)) /* Macro to retrieve pointer to i'th native record for leaf node */ -#define H5B2_LEAF_NREC(l, shared, idx) H5B2_NAT_NREC((l)->leaf_native, (shared), (idx)) +#define H5B2_LEAF_NREC(l, hdr, idx) H5B2_NAT_NREC((l)->leaf_native, (hdr), (idx)) + +/* Number of records that fit into internal node */ +/* (accounts for extra node pointer by counting it in with the prefix bytes) */ +#define H5B2_NUM_INT_REC(f, s, d) \ + (((s)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(f, s, d))) / ((s)->rrec_size + H5B2_INT_POINTER_SIZE(f, s, d))) /****************************/ @@ -129,15 +134,13 @@ typedef struct { H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */ } H5B2_node_info_t; -/* Each B-tree has certain information that can be shared across all - * the instances of nodes in that B-tree. - */ -typedef struct H5B2_shared_t { - /* Shared internal data structures */ - const H5B2_class_t *type; /* Type of tree */ - uint8_t *page; /* Common disk page for I/O */ - size_t *nat_off; /* Array of offsets of native records */ - H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ +/* The B-tree header information */ +typedef struct H5B2_hdr_t { + /* Information for H5AC cache functions, _must_ be first field in structure */ + H5AC_info_t cache_info; + + /* Internal B-tree information (stored) */ + H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */ /* Information set by user (stored) */ unsigned split_percent; /* Percent full at which to split the node, when inserting */ @@ -148,19 +151,19 @@ typedef struct H5B2_shared_t { /* Dynamic information (stored) */ unsigned depth; /* B-tree's overall depth */ - /* Derived information from user's information */ + /* Derived information from user's information (not stored) */ uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ -} H5B2_shared_t; - -/* The B-tree information */ -typedef struct H5B2_t { - /* Information for H5AC cache functions, _must_ be first field in structure */ - H5AC_info_t cache_info; - /* Internal B-tree information */ - H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */ - H5RC_t *shared; /* Ref-counted shared info */ -} H5B2_t; + /* Shared internal data structures (not stored) */ + H5F_t *f; /* Pointer to the file that the B-tree is in */ + haddr_t addr; /* Address of B-tree header in the file */ + size_t rc; /* Reference count of nodes using this header */ + hbool_t pending_delete; /* B-tree is pending deletion */ + const H5B2_class_t *type; /* Type of tree */ + uint8_t *page; /* Common disk page for I/O */ + size_t *nat_off; /* Array of offsets of native records */ + H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ +} H5B2_hdr_t; /* B-tree leaf node information */ typedef struct H5B2_leaf_t { @@ -168,7 +171,7 @@ typedef struct H5B2_leaf_t { H5AC_info_t cache_info; /* Internal B-tree information */ - H5RC_t *shared; /* Ref-counted shared info */ + H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ uint8_t *leaf_native; /* Pointer to native records */ unsigned nrec; /* Number of records in node */ } H5B2_leaf_t; @@ -179,7 +182,7 @@ typedef struct H5B2_internal_t { H5AC_info_t cache_info; /* Internal B-tree information */ - H5RC_t *shared; /* Ref-counted shared info */ + H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ uint8_t *int_native; /* Pointer to native records */ H5B2_node_ptr_t *node_ptrs; /* Pointer to node pointers */ unsigned nrec; /* Number of records in node */ @@ -188,9 +191,9 @@ typedef struct H5B2_internal_t { /* User data for metadata cache 'load' callback */ typedef struct { - H5RC_t *bt2_shared; /* Ref counter for shared B-tree info */ - unsigned nrec; /* Number of records in node to load */ - unsigned depth; /* Depth of node to load */ + H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ + unsigned nrec; /* Number of records in node to load */ + unsigned depth; /* Depth of node to load */ } H5B2_int_load_ud1_t; #ifdef H5B2_TESTING @@ -215,8 +218,8 @@ H5_DLLVAR const H5AC_class_t H5AC_BT2_INT[1]; /* H5B2 leaf node inherits cache-like properties from H5AC */ H5_DLLVAR const H5AC_class_t H5AC_BT2_LEAF[1]; -/* Declare a free list to manage the H5B2_t struct */ -H5FL_EXTERN(H5B2_t); +/* Declare a free list to manage the H5B2_hdr_t struct */ +H5FL_EXTERN(H5B2_hdr_t); /* Declare a free list to manage the H5B2_internal_t struct */ H5FL_EXTERN(H5B2_internal_t); @@ -234,69 +237,72 @@ H5_DLLVAR const H5B2_class_t H5B2_TEST[1]; /* Package Private Prototypes */ /******************************/ -/* Routines for managing shared B-tree info */ -H5_DLL herr_t H5B2_shared_init(H5F_t *f, H5B2_t *bt2, const H5B2_class_t *type, +/* Routines for managing B-tree header info */ +H5_DLL herr_t H5B2_hdr_incr(H5B2_hdr_t *hdr); +H5_DLL herr_t H5B2_hdr_decr(H5B2_hdr_t *hdr); +H5_DLL herr_t H5B2_hdr_dirty(H5B2_hdr_t *hdr); +H5_DLL herr_t H5B2_hdr_delete(H5B2_hdr_t *hdr); +H5_DLL herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_class_t *type, unsigned depth, size_t node_size, size_t rrec_size, unsigned split_percent, unsigned merge_percent); +H5_DLL herr_t H5B2_hdr_free(H5B2_hdr_t *hdr); /* Routines for operating on internal nodes */ H5_DLL H5B2_internal_t *H5B2_protect_internal(H5F_t *f, hid_t dxpl_id, - H5RC_t *bt2_shared, haddr_t addr, unsigned nrec, unsigned depth, - H5AC_protect_t rw); + H5B2_hdr_t *hdr, haddr_t addr, unsigned nrec, unsigned depth, H5AC_protect_t rw); /* Routines for allocating nodes */ -H5_DLL herr_t H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2, - unsigned *bt2_flags_ptr); -H5_DLL herr_t H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr); +H5_DLL herr_t H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *node_ptr); /* Routines for inserting records */ -H5_DLL herr_t H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth, unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, void *udata); -H5_DLL herr_t H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *udata); /* Routines for iterating over nodes/records */ -H5_DLL herr_t H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data); -H5_DLL herr_t H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *curr_node, hsize_t *op_data); /* Routines for locating records */ H5_DLL int H5B2_locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx); -H5_DLL herr_t H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data); /* Routines for removing records */ -H5_DLL herr_t H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info, hbool_t * parent_cache_info_dirtied_ptr, H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, void *op_data); -H5_DLL herr_t H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, void *op_data); -H5_DLL herr_t H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info, hbool_t * parent_cache_info_dirtied_ptr, H5B2_node_ptr_t *curr_node_ptr, hsize_t idx, H5B2_remove_t op, void *op_data); -H5_DLL herr_t H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, unsigned idx, H5B2_remove_t op, void *op_data); /* Routines for deleting nodes */ -H5_DLL herr_t H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data); /* Metadata cache callbacks */ -H5_DLL herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *b); +H5_DLL herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_hdr_t *b); H5_DLL herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *l); H5_DLL herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *i); |