summaryrefslogtreecommitdiffstats
path: root/src/H5B2hdr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-10-24 19:16:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-10-24 19:16:06 (GMT)
commitf985e7d22f389d336894e33b84c0d60427d4ae27 (patch)
treec8faf0cc53e31982de47ff29fccb4f3cbf86f556 /src/H5B2hdr.c
parent1059b742826ca3864be8ee70c76c8ef625d31e46 (diff)
downloadhdf5-f985e7d22f389d336894e33b84c0d60427d4ae27.zip
hdf5-f985e7d22f389d336894e33b84c0d60427d4ae27.tar.gz
hdf5-f985e7d22f389d336894e33b84c0d60427d4ae27.tar.bz2
[svn-r17740] Description:
Refactor v2 B-tree code to take creation parameters to H5B2_create() as a struct (instead of individual arguments), call the client's class "cls" instead of "type" internally, and add client class name to client class struct. 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/H5B2hdr.c')
-rw-r--r--src/H5B2hdr.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c
index 5e577f5..ef57186 100644
--- a/src/H5B2hdr.c
+++ b/src/H5B2hdr.c
@@ -104,9 +104,8 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t);
*-------------------------------------------------------------------------
*/
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)
+H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam,
+ unsigned depth)
{
size_t sz_max_nrec; /* Temporary variable for range checking */
unsigned u_max_nrec_size; /* Temporary variable for range checking */
@@ -115,6 +114,19 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_class_t *type,
FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_init)
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(hdr);
+ HDassert(cparam);
+ HDassert(cparam->cls);
+ HDassert(cparam->node_size > 0);
+ HDassert(cparam->rrec_size > 0);
+ HDassert(cparam->merge_percent > 0 && cparam->merge_percent <= 100);
+ HDassert(cparam->split_percent > 0 && cparam->split_percent <= 100);
+ HDassert(cparam->merge_percent < (cparam->split_percent / 2));
+
/* Initialize basic information */
hdr->f = f;
hdr->rc = 0;
@@ -124,13 +136,13 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_class_t *type,
hdr->depth = depth;
/* Assign user's information */
- hdr->split_percent = split_percent;
- hdr->merge_percent = merge_percent;
- hdr->node_size = node_size;
- hdr->rrec_size = rrec_size;
+ hdr->split_percent = cparam->split_percent;
+ hdr->merge_percent = cparam->merge_percent;
+ hdr->node_size = cparam->node_size;
+ hdr->rrec_size = cparam->rrec_size;
/* Assign common type information */
- hdr->type = type;
+ hdr->cls = cparam->cls;
/* Allocate "page" for node I/O */
if(NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size)))
@@ -150,7 +162,7 @@ HDmemset(hdr->page, 0, hdr->node_size);
hdr->node_info[0].merge_nrec = (hdr->node_info[0].max_nrec * hdr->merge_percent) / 100;
hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec;
hdr->node_info[0].cum_max_nrec_size = 0;
- if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(type->nrec_size * hdr->node_info[0].max_nrec)))
+ if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory")
hdr->node_info[0].node_ptr_fac = NULL;
@@ -162,7 +174,7 @@ HDmemset(hdr->page, 0, hdr->node_size);
/* Initialize offsets in native key block */
/* (uses leaf # of records because its the largest) */
for(u = 0; u < hdr->node_info[0].max_nrec; u++)
- hdr->nat_off[u] = type->nrec_size * u;
+ hdr->nat_off[u] = hdr->cls->nrec_size * u;
/* Compute size to store # of records in each node */
/* (uses leaf # of records because its the largest) */
@@ -185,7 +197,7 @@ HDmemset(hdr->page, 0, hdr->node_size);
u_max_nrec_size = H5V_limit_enc_size((uint64_t)hdr->node_info[u].cum_max_nrec);
H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t)
- if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->type->nrec_size * hdr->node_info[u].max_nrec)))
+ if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory")
if(NULL == (hdr->node_info[u].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory")