summaryrefslogtreecommitdiffstats
path: root/src/H5B2hdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5B2hdr.c')
-rw-r--r--src/H5B2hdr.c144
1 files changed, 72 insertions, 72 deletions
diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c
index 04b648c..5e577f5 100644
--- a/src/H5B2hdr.c
+++ b/src/H5B2hdr.c
@@ -104,7 +104,7 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t);
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_hdr_init(H5F_t *f, H5B2_t *bt2, const H5B2_class_t *type,
+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)
{
@@ -116,85 +116,85 @@ H5B2_hdr_init(H5F_t *f, H5B2_t *bt2, const H5B2_class_t *type,
FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_init)
/* Initialize basic information */
- bt2->f = f;
- bt2->rc = 0;
- bt2->pending_delete = FALSE;
+ hdr->f = f;
+ hdr->rc = 0;
+ hdr->pending_delete = FALSE;
/* Assign dynamic information */
- bt2->depth = depth;
+ hdr->depth = depth;
/* Assign user's information */
- bt2->split_percent = split_percent;
- bt2->merge_percent = merge_percent;
- bt2->node_size = node_size;
- bt2->rrec_size = rrec_size;
+ hdr->split_percent = split_percent;
+ hdr->merge_percent = merge_percent;
+ hdr->node_size = node_size;
+ hdr->rrec_size = rrec_size;
/* Assign common type information */
- bt2->type = type;
+ hdr->type = type;
/* Allocate "page" for node I/O */
- if(NULL == (bt2->page = H5FL_BLK_MALLOC(node_page, bt2->node_size)))
+ if(NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
#ifdef H5_CLEAR_MEMORY
-HDmemset(bt2->page, 0, bt2->node_size);
+HDmemset(hdr->page, 0, hdr->node_size);
#endif /* H5_CLEAR_MEMORY */
/* Allocate array of node info structs */
- if(NULL == (bt2->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(bt2->depth + 1))))
+ if(NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize leaf node info */
- sz_max_nrec = H5B2_NUM_LEAF_REC(bt2->node_size, bt2->rrec_size);
- H5_ASSIGN_OVERFLOW(/* To: */ bt2->node_info[0].max_nrec, /* From: */ sz_max_nrec, /* From: */ size_t, /* To: */ unsigned)
- bt2->node_info[0].split_nrec = (bt2->node_info[0].max_nrec * bt2->split_percent) / 100;
- bt2->node_info[0].merge_nrec = (bt2->node_info[0].max_nrec * bt2->merge_percent) / 100;
- bt2->node_info[0].cum_max_nrec = bt2->node_info[0].max_nrec;
- bt2->node_info[0].cum_max_nrec_size = 0;
- if(NULL == (bt2->node_info[0].nat_rec_fac = H5FL_fac_init(type->nrec_size * bt2->node_info[0].max_nrec)))
+ sz_max_nrec = H5B2_NUM_LEAF_REC(hdr->node_size, hdr->rrec_size);
+ H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[0].max_nrec, /* From: */ sz_max_nrec, /* From: */ size_t, /* To: */ unsigned)
+ hdr->node_info[0].split_nrec = (hdr->node_info[0].max_nrec * hdr->split_percent) / 100;
+ 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)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory")
- bt2->node_info[0].node_ptr_fac = NULL;
+ hdr->node_info[0].node_ptr_fac = NULL;
/* Allocate array of pointers to internal node native keys */
/* (uses leaf # of records because its the largest) */
- if(NULL == (bt2->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)bt2->node_info[0].max_nrec)))
+ if(NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize offsets in native key block */
/* (uses leaf # of records because its the largest) */
- for(u = 0; u < bt2->node_info[0].max_nrec; u++)
- bt2->nat_off[u] = type->nrec_size * u;
+ for(u = 0; u < hdr->node_info[0].max_nrec; u++)
+ hdr->nat_off[u] = type->nrec_size * u;
/* Compute size to store # of records in each node */
/* (uses leaf # of records because its the largest) */
- u_max_nrec_size = H5V_limit_enc_size((uint64_t)bt2->node_info[0].max_nrec);
- H5_ASSIGN_OVERFLOW(/* To: */ bt2->max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t)
- HDassert(bt2->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE);
+ u_max_nrec_size = H5V_limit_enc_size((uint64_t)hdr->node_info[0].max_nrec);
+ H5_ASSIGN_OVERFLOW(/* To: */ hdr->max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t)
+ HDassert(hdr->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE);
/* Initialize internal node info */
if(depth > 0) {
for(u = 1; u < (depth + 1); u++) {
- sz_max_nrec = H5B2_NUM_INT_REC(f, bt2, u);
- H5_ASSIGN_OVERFLOW(/* To: */ bt2->node_info[u].max_nrec, /* From: */ sz_max_nrec, /* From: */ size_t, /* To: */ unsigned)
- HDassert(bt2->node_info[u].max_nrec <= bt2->node_info[u - 1].max_nrec);
+ sz_max_nrec = H5B2_NUM_INT_REC(f, hdr, u);
+ H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[u].max_nrec, /* From: */ sz_max_nrec, /* From: */ size_t, /* To: */ unsigned)
+ HDassert(hdr->node_info[u].max_nrec <= hdr->node_info[u - 1].max_nrec);
- bt2->node_info[u].split_nrec = (bt2->node_info[u].max_nrec * bt2->split_percent) / 100;
- bt2->node_info[u].merge_nrec = (bt2->node_info[u].max_nrec * bt2->merge_percent) / 100;
+ hdr->node_info[u].split_nrec = (hdr->node_info[u].max_nrec * hdr->split_percent) / 100;
+ hdr->node_info[u].merge_nrec = (hdr->node_info[u].max_nrec * hdr->merge_percent) / 100;
- bt2->node_info[u].cum_max_nrec = ((bt2->node_info[u].max_nrec + 1) *
- bt2->node_info[u - 1].cum_max_nrec) + bt2->node_info[u].max_nrec;
- u_max_nrec_size = H5V_limit_enc_size((uint64_t)bt2->node_info[u].cum_max_nrec);
- H5_ASSIGN_OVERFLOW(/* To: */ bt2->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t)
+ hdr->node_info[u].cum_max_nrec = ((hdr->node_info[u].max_nrec + 1) *
+ hdr->node_info[u - 1].cum_max_nrec) + hdr->node_info[u].max_nrec;
+ 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 == (bt2->node_info[u].nat_rec_fac = H5FL_fac_init(bt2->type->nrec_size * bt2->node_info[u].max_nrec)))
+ if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->type->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 == (bt2->node_info[u].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (bt2->node_info[u].max_nrec + 1))))
+ 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")
} /* end for */
} /* end if */
done:
if(ret_value < 0)
- if(H5B2_hdr_free(bt2) < 0)
+ if(H5B2_hdr_free(hdr) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free shared v2 B-tree info")
FUNC_LEAVE_NOAPI(ret_value)
@@ -215,39 +215,39 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_hdr_free(H5B2_t *bt2)
+H5B2_hdr_free(H5B2_hdr_t *hdr)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_free)
/* Sanity check */
- HDassert(bt2);
+ HDassert(hdr);
/* Free the B-tree node buffer */
- if(bt2->page)
- (void)H5FL_BLK_FREE(node_page, bt2->page);
+ if(hdr->page)
+ (void)H5FL_BLK_FREE(node_page, hdr->page);
/* Free the array of offsets into the native key block */
- if(bt2->nat_off)
- bt2->nat_off = H5FL_SEQ_FREE(size_t, bt2->nat_off);
+ if(hdr->nat_off)
+ hdr->nat_off = H5FL_SEQ_FREE(size_t, hdr->nat_off);
/* Release the node info */
- if(bt2->node_info) {
+ if(hdr->node_info) {
unsigned u; /* Local index variable */
/* Destroy free list factories */
- for(u = 0; u < (bt2->depth + 1); u++) {
- if(bt2->node_info[u].nat_rec_fac)
- if(H5FL_fac_term(bt2->node_info[u].nat_rec_fac) < 0)
+ for(u = 0; u < (hdr->depth + 1); u++) {
+ if(hdr->node_info[u].nat_rec_fac)
+ if(H5FL_fac_term(hdr->node_info[u].nat_rec_fac) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory")
- if(bt2->node_info[u].node_ptr_fac)
- if(H5FL_fac_term(bt2->node_info[u].node_ptr_fac) < 0)
+ if(hdr->node_info[u].node_ptr_fac)
+ if(H5FL_fac_term(hdr->node_info[u].node_ptr_fac) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory")
} /* end for */
/* Free the array of node info structs */
- bt2->node_info = H5FL_SEQ_FREE(H5B2_node_info_t, bt2->node_info);
+ hdr->node_info = H5FL_SEQ_FREE(H5B2_node_info_t, hdr->node_info);
} /* end if */
done:
@@ -269,23 +269,23 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_hdr_incr(H5B2_t *bt2)
+H5B2_hdr_incr(H5B2_hdr_t *hdr)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_incr)
/* Sanity checks */
- HDassert(bt2);
- HDassert(bt2->f);
+ HDassert(hdr);
+ HDassert(hdr->f);
/* Mark header as un-evictable when a B-tree node is depending on it */
- if(bt2->rc == 0)
- if(H5AC_pin_protected_entry(bt2->f, bt2) < 0)
+ if(hdr->rc == 0)
+ if(H5AC_pin_protected_entry(hdr->f, hdr) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTPIN, FAIL, "unable to pin v2 B-tree header")
/* Increment reference count on B-tree header */
- bt2->rc++;
+ hdr->rc++;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -306,23 +306,23 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_hdr_decr(H5B2_t *bt2)
+H5B2_hdr_decr(H5B2_hdr_t *hdr)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_decr)
/* Sanity check */
- HDassert(bt2);
- HDassert(bt2->f);
- HDassert(bt2->rc > 0);
+ HDassert(hdr);
+ HDassert(hdr->f);
+ HDassert(hdr->rc > 0);
/* Decrement reference count on B-tree header */
- bt2->rc--;
+ hdr->rc--;
/* Mark header as evictable again when no nodes depend on it */
- if(bt2->rc == 0)
- if(H5AC_unpin_entry(bt2->f, bt2) < 0)
+ if(hdr->rc == 0)
+ if(H5AC_unpin_entry(hdr->f, hdr) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin v2 B-tree header")
done:
@@ -344,18 +344,18 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_hdr_dirty(H5B2_t *bt2)
+H5B2_hdr_dirty(H5B2_hdr_t *hdr)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_dirty)
/* Sanity check */
- HDassert(bt2);
- HDassert(bt2->f);
+ HDassert(hdr);
+ HDassert(hdr->f);
/* Mark B-tree header as dirty in cache */
- if(H5AC_mark_pinned_or_protected_entry_dirty(bt2->f, bt2) < 0)
+ if(H5AC_mark_pinned_or_protected_entry_dirty(hdr->f, hdr) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark v2 B-tree header as dirty")
done:
@@ -377,15 +377,15 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_hdr_delete(H5B2_t *bt2)
+H5B2_hdr_delete(H5B2_hdr_t *hdr)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_hdr_delete)
/* Sanity check */
- HDassert(bt2);
+ HDassert(hdr);
/* Mark B-tree header as pending deletion */
- bt2->pending_delete = TRUE;
+ hdr->pending_delete = TRUE;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5B2_hdr_delete() */