summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-02-22 12:16:30 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-02-22 12:16:30 (GMT)
commitc07d8036591313caf15cf626122bd7ce4e61be49 (patch)
treede3cfcb2639a3c84254d536d2f4a1ec9239af019 /src
parent179f3b7879e28165869034255b5852b551700ad6 (diff)
parentf634105bdb7c494a5ab39291d64c00676c11b476 (diff)
downloadhdf5-c07d8036591313caf15cf626122bd7ce4e61be49.zip
hdf5-c07d8036591313caf15cf626122bd7ce4e61be49.tar.gz
hdf5-c07d8036591313caf15cf626122bd7ce4e61be49.tar.bz2
[svn-r26274] Merge of r26096 to r26271 from trunk.
Tested on: jam - serial: C++/Fortran parallel: Fortran
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/H5B.c147
-rw-r--r--src/H5B2.c154
-rw-r--r--src/H5B2cache.c67
-rw-r--r--src/H5B2hdr.c46
-rw-r--r--src/H5B2int.c160
-rw-r--r--src/H5B2pkg.h32
-rw-r--r--src/H5B2stat.c25
-rw-r--r--src/H5Dbtree.c12
-rw-r--r--src/H5Dchunk.c126
-rw-r--r--src/H5Dint.c28
-rw-r--r--src/H5Dio.c10
-rw-r--r--src/H5Dmpio.c44
-rw-r--r--src/H5Dpkg.h2
-rw-r--r--src/H5Dpublic.h3
-rw-r--r--src/H5Edeprec.c2
-rw-r--r--src/H5FD.c1
-rw-r--r--src/H5I.c3
-rw-r--r--src/H5Olayout.c6
-rw-r--r--src/H5P.c1
-rw-r--r--src/H5PL.c141
-rw-r--r--src/H5Pdcpl.c2
-rw-r--r--src/H5Pfapl.c1
-rw-r--r--src/H5Tfields.c1
-rw-r--r--src/H5Topaque.c1
-rw-r--r--src/H5VM.c2
-rw-r--r--src/H5private.h2
-rw-r--r--src/H5public.h4
28 files changed, 597 insertions, 432 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3ad51b7..d9e7195 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8.11)
+cmake_minimum_required (VERSION 3.1.0)
PROJECT (HDF5_SRC C CXX)
#-----------------------------------------------------------------------------
@@ -877,8 +877,8 @@ set_target_properties (${HDF5_LIB_TARGET} PROPERTIES
option (HDF5_ENABLE_DEBUG_APIS "Turn on debugging in all packages" OFF)
if (HDF5_ENABLE_DEBUG_APIS)
set_target_properties (${HDF5_LIB_TARGET} PROPERTIES
- COMPILE_DEFINITIONS
- "H5Z_DEBUG;H5VM_DEBUG;H5T_DEBUG;H5S_DEBUG;H5P_DEBUG;H5O_DEBUG;H5MM_DEBUG;H5MF_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5HG_DEBUG;H5G_DEBUG;H5F_DEBUG;H5E_DEBUG;H5D_DEBUG;H5B_DEBUG;H5AC_DEBUG"
+ COMPILE_DEFINITIONS
+ "H5Z_DEBUG;H5VM_DEBUG;H5T_DEBUG;H5S_DEBUG;H5P_DEBUG;H5O_DEBUG;H5MM_DEBUG;H5MF_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5HG_DEBUG;H5G_DEBUG;H5F_DEBUG;H5E_DEBUG;H5D_DEBUG;H5B_DEBUG;H5AC_DEBUG"
)
endif (HDF5_ENABLE_DEBUG_APIS)
diff --git a/src/H5B.c b/src/H5B.c
index 286f09d..621209f 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -510,22 +510,18 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud, unsigned idx,
bt_ud->bt->nchildren = nleft;
/*
- * Update sibling pointers.
+ * Update other sibling pointers.
*/
split_bt_ud->bt->left = bt_ud->addr;
split_bt_ud->bt->right = bt_ud->bt->right;
if(H5F_addr_defined(bt_ud->bt->right)) {
- H5B_t *tmp_bt;
- H5B_cache_ud_t cache_udata2; /* User-data for metadata cache callback */
+ H5B_t *tmp_bt;
- cache_udata2.f = f;
- cache_udata2.type = shared->type;
- cache_udata2.rc_shared = bt_ud->bt->rc_shared;
- if(NULL == (tmp_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt_ud->bt->right, &cache_udata2, H5AC_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load right sibling")
+ if(NULL == (tmp_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt_ud->bt->right, &cache_udata, H5AC_WRITE)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load right sibling")
- tmp_bt->left = split_bt_ud->addr;
+ tmp_bt->left = split_bt_ud->addr;
if(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt_ud->bt->right, tmp_bt, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
@@ -539,6 +535,7 @@ done:
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
split_bt_ud->bt = NULL;
split_bt_ud->addr = HADDR_UNDEF;
+ split_bt_ud->cache_flags = H5AC__NO_FLAGS_SET;
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -559,8 +556,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
- void *udata)
+H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata)
{
/*
* These are defined this way to satisfy alignment constraints.
@@ -609,6 +605,8 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
&lt_key_changed, md_key, udata, rt_key, &rt_key_changed,
&split_bt_ud/*out*/)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key")
+
+ /* Check if the root node split */
if(H5B_INS_NOOP == my_ins) {
HDassert(!split_bt_ud.bt);
HGOTO_DONE(SUCCEED)
@@ -633,7 +631,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
*/
H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t);
if(HADDR_UNDEF == (old_root_addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root")
/*
* Move the node to the new location
@@ -641,7 +639,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
/* Make a copy of the old root information */
if(NULL == (new_root_bt = H5B_copy(bt_ud.bt)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to copy old root");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to copy old root")
/* Unprotect the old root so we can move it. Also force it to be marked
* dirty so it is written to the new location. */
@@ -651,7 +649,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
/* Move the location of the old root on the disk */
if(H5AC_move_entry(f, H5AC_BT, bt_ud.addr, old_root_addr) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node")
bt_ud.addr = old_root_addr;
/* Update the split b-tree's left pointer to point to the new location */
@@ -769,7 +767,7 @@ H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx,
*bt_flags |= H5AC__DIRTIED_FLAG;
FUNC_LEAVE_NOAPI(SUCCEED)
-}
+} /* end H5B_insert_child() */
/*-------------------------------------------------------------------------
@@ -1046,6 +1044,10 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud,
else
HDmemcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
} /* end if */
+
+ /*
+ * Handle changes/additions to children
+ */
if(H5B_INS_CHANGE == my_ins) {
/*
* The insertion simply changed the address for the child.
@@ -1081,7 +1083,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud,
/* Insert the child */
if(H5B_insert_child(tmp_bt, tmp_bt_flags_ptr, idx, new_child_bt_ud.addr, my_ins, md_key) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child")
- }
+ } /* end else-if */
/*
* If this node split, return the mid key (the one that is shared
@@ -1113,7 +1115,7 @@ done:
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect new child")
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5B_insert_helper() */
/*-------------------------------------------------------------------------
@@ -1134,13 +1136,12 @@ static herr_t
H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
H5B_operator_t op, void *udata)
{
- H5B_t *bt = NULL; /* Pointer to current B-tree node */
+ H5B_t *bt = NULL; /* Pointer to current B-tree node */
H5UC_t *rc_shared; /* Ref-counted shared info */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
- uint8_t *native = NULL; /* Array of keys in native format */
- haddr_t *child = NULL; /* Array of child pointers */
- herr_t ret_value; /* Return value */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1155,7 +1156,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -1164,99 +1165,21 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load B-tree node")
-
- if(bt->level > 0) {
- haddr_t left_child = bt->child[0]; /* Address of left-most child in node */
-
- /* Release current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
- bt = NULL;
-
- /* Keep following the left-most child until we reach a leaf node. */
- if((ret_value = H5B_iterate_helper(f, dxpl_id, type, left_child, op, udata)) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, H5_ITER_ERROR, "unable to list B-tree node")
- } /* end if */
- else {
- unsigned nchildren; /* Number of child pointers */
- haddr_t next_addr; /* Address of next node to the right */
-
- /* Allocate space for a copy of the native records & child pointers */
- if(NULL == (native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed for shared B-tree native records")
- if(NULL == (child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed for shared B-tree child addresses")
-
- /* Cache information from this node */
- nchildren = bt->nchildren;
- next_addr = bt->right;
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load B-tree node")
- /* Copy the native keys & child pointers into local arrays */
- HDmemcpy(native, bt->native, shared->sizeof_keys);
- HDmemcpy(child, bt->child, (nchildren * sizeof(haddr_t)));
-
- /* Release current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
- bt = NULL;
-
- /*
- * We've reached the left-most leaf. Now follow the right-sibling
- * pointer from leaf to leaf until we've processed all leaves.
- */
- ret_value = H5_ITER_CONT;
- while(ret_value == H5_ITER_CONT) {
- haddr_t *curr_child; /* Pointer to node's child addresses */
- uint8_t *curr_native; /* Pointer to node's native keys */
- unsigned u; /* Local index variable */
-
- /*
- * Perform the iteration operator, which might invoke an
- * application callback.
- */
- for(u = 0, curr_child = child, curr_native = native; u < nchildren && ret_value == H5_ITER_CONT; u++, curr_child++, curr_native += type->sizeof_nkey) {
- ret_value = (*op)(f, dxpl_id, curr_native, *curr_child, curr_native + type->sizeof_nkey, udata);
- if(ret_value < 0)
- HERROR(H5E_BTREE, H5E_CANTLIST, "iterator function failed");
- } /* end for */
-
- /* Check for continuing iteration */
- if(ret_value == H5_ITER_CONT) {
- /* Check for another node */
- if(H5F_addr_defined(next_addr)) {
- /* Protect the next node to the right */
- addr = next_addr;
- if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "B-tree node")
-
- /* Cache information from this node */
- nchildren = bt->nchildren;
- next_addr = bt->right;
-
- /* Copy the native keys & child pointers into local arrays */
- HDmemcpy(native, bt->native, shared->sizeof_keys);
- HDmemcpy(child, bt->child, nchildren * sizeof(haddr_t));
-
- /* Unprotect node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
- bt = NULL;
- } /* end if */
- else
- /* Exit loop */
- break;
- } /* end if */
- } /* end while */
- } /* end else */
+ /* Iterate over node's children */
+ for(u = 0; u < bt->nchildren && ret_value == H5_ITER_CONT; u++) {
+ if(bt->level > 0)
+ ret_value = H5B_iterate_helper(f, dxpl_id, type, bt->child[u], op, udata);
+ else
+ ret_value = (*op)(f, dxpl_id, H5B_NKEY(bt, shared, u), bt->child[u], H5B_NKEY(bt, shared, u + 1), udata);
+ if(ret_value < 0)
+ HERROR(H5E_BTREE, H5E_BADITER, "B-tree iteration failed");
+ } /* end for */
done:
if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
- if(native)
- native = H5FL_BLK_FREE(native_block, native);
- if(child)
- child = H5FL_SEQ_FREE(haddr_t, child);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_iterate_helper() */
@@ -1715,7 +1638,7 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -1724,7 +1647,7 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node")
/* Iterate over all children in tree, deleting them */
if(bt->level > 0) {
diff --git a/src/H5B2.c b/src/H5B2.c
index a2b218d..7d7345e 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -128,11 +128,11 @@ H5FL_DEFINE_STATIC(H5B2_t);
H5B2_t *
H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udata)
{
- H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
- H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
+ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */
H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
haddr_t hdr_addr; /* B-tree header address */
- H5B2_t *ret_value; /* Return value */
+ H5B2_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -147,7 +147,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat
/* Create shared v2 B-tree header */
if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam, ctx_udata)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header")
/* Create v2 B-tree wrapper */
if(NULL == (bt2 = H5FL_MALLOC(H5B2_t)))
@@ -157,7 +157,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat
cache_udata.f = f;
cache_udata.ctx_udata = ctx_udata;
if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header")
/* Point v2 B-tree wrapper at header and bump it's ref count */
bt2->hdr = hdr;
@@ -166,7 +166,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat
/* Increment # of files using this v2 B-tree header */
if(H5B2_hdr_fuse_incr(bt2->hdr) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header")
/* Set file pointer for this v2 B-tree open context */
bt2->f = f;
@@ -299,11 +299,11 @@ H5B2_insert(H5B2_t *bt2, hid_t dxpl_id, void *udata)
/* Attempt to insert record into B-tree */
if(hdr->depth > 0) {
- if(H5B2_insert_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, udata) < 0)
+ if(H5B2_insert_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node")
} /* end if */
else {
- if(H5B2_insert_leaf(hdr, dxpl_id, &hdr->root, udata) < 0)
+ if(H5B2_insert_leaf(hdr, dxpl_id, &hdr->root, H5B2_POS_ROOT, udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node")
} /* end else */
@@ -420,12 +420,13 @@ htri_t
H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op,
void *op_data)
{
- H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */
unsigned depth; /* Current depth of the tree */
int cmp; /* Comparison value of records */
unsigned idx; /* Location of record which matches key */
- htri_t ret_value = TRUE; /* Return value */
+ H5B2_nodepos_t curr_pos; /* Position of the current node */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -441,16 +442,39 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op,
/* Make copy of the root node pointer to start search with */
curr_node_ptr = hdr->root;
- /* Current depth of the tree */
- depth = hdr->depth;
-
/* Check for empty tree */
if(curr_node_ptr.node_nrec == 0)
HGOTO_DONE(FALSE)
+ /* Check record against min & max records in tree, to attempt to quickly
+ * find candidates or avoid further searching.
+ */
+ if(hdr->min_native_rec != NULL) {
+ if((cmp = (hdr->cls->compare)(udata, hdr->min_native_rec)) < 0)
+ HGOTO_DONE(FALSE) /* Less than the least record--not found */
+ else if(cmp == 0) { /* Record is found */
+ if(op && (op)(hdr->min_native_rec, op_data) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
+ HGOTO_DONE(TRUE)
+ } /* end if */
+ } /* end if */
+ if(hdr->max_native_rec != NULL) {
+ if((cmp = (hdr->cls->compare)(udata, hdr->max_native_rec)) > 0)
+ HGOTO_DONE(FALSE) /* Greater than the greatest record--not found */
+ else if(cmp == 0) { /* Record is found */
+ if(op && (op)(hdr->max_native_rec, op_data) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
+ HGOTO_DONE(TRUE)
+ } /* end if */
+ } /* end if */
+
+ /* Current depth of the tree */
+ depth = hdr->depth;
+
/* Walk down B-tree to find record or leaf node where record is located */
cmp = -1;
- while(depth > 0 && cmp != 0) {
+ curr_pos = H5B2_POS_ROOT;
+ while(depth > 0) {
H5B2_internal_t *internal; /* Pointer to internal node in B-tree */
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
@@ -467,6 +491,24 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op,
/* Get node pointer for next node to search */
next_node_ptr=internal->node_ptrs[idx];
+ /* Set the position of the next node */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ curr_pos = H5B2_POS_LEFT;
+ else
+ curr_pos = H5B2_POS_MIDDLE;
+ } /* end if */
+ else if(idx == internal->nrec) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ curr_pos = H5B2_POS_RIGHT;
+ else
+ curr_pos = H5B2_POS_MIDDLE;
+ } /* end if */
+ else
+ curr_pos = H5B2_POS_MIDDLE;
+ } /* end if */
+
/* Unlock current node */
if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
@@ -523,6 +565,27 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op,
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
} /* end if */
+
+ /* Check for record being the min or max for the tree */
+ /* (Don't use 'else' for the idx check, to allow for root leaf node) */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->min_native_rec == NULL)
+ if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info")
+ HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ } /* end if */
+ } /* end if */
+ if(idx == (unsigned)(leaf->nrec - 1)) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->max_native_rec == NULL)
+ if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info")
+ HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ } /* end if */
+ } /* end if */
+ } /* end if */
} /* end else */
/* Unlock current node */
@@ -577,9 +640,6 @@ H5B2_index(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order, hsize_t idx,
/* Make copy of the root node pointer to start search with */
curr_node_ptr = hdr->root;
- /* Current depth of the tree */
- depth = hdr->depth;
-
/* Check for empty tree */
if(curr_node_ptr.node_nrec == 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records")
@@ -588,6 +648,9 @@ H5B2_index(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order, hsize_t idx,
if(idx >= curr_node_ptr.all_nrec)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree doesn't have that many records")
+ /* Current depth of the tree */
+ depth = hdr->depth;
+
/* 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);
@@ -736,7 +799,7 @@ H5B2_remove(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_remove_t op,
hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */
if(H5B2_remove_internal(hdr, dxpl_id, &depth_decreased, NULL, hdr->depth,
- &(hdr->cache_info), NULL, &hdr->root, udata, op, op_data) < 0)
+ &(hdr->cache_info), NULL, H5B2_POS_ROOT, &hdr->root, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
/* Check for decreasing the depth of the B-tree */
@@ -754,7 +817,7 @@ H5B2_remove(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_remove_t op,
} /* end for */
} /* end if */
else {
- if(H5B2_remove_leaf(hdr, dxpl_id, &hdr->root, udata, op, op_data) < 0)
+ if(H5B2_remove_leaf(hdr, dxpl_id, &hdr->root, H5B2_POS_ROOT, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
@@ -818,7 +881,7 @@ H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */
if(H5B2_remove_internal_by_idx(hdr, dxpl_id, &depth_decreased, NULL, hdr->depth,
- &(hdr->cache_info), NULL, &hdr->root, idx, op, op_data) < 0)
+ &(hdr->cache_info), NULL, &hdr->root, H5B2_POS_ROOT, idx, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
/* Check for decreasing the depth of the B-tree */
@@ -836,7 +899,7 @@ H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
} /* end for */
} /* end if */
else {
- if(H5B2_remove_leaf_by_idx(hdr, dxpl_id, &hdr->root, (unsigned)idx, op, op_data) < 0)
+ if(H5B2_remove_leaf_by_idx(hdr, dxpl_id, &hdr->root, H5B2_POS_ROOT, (unsigned)idx, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
@@ -970,6 +1033,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op,
{
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */
+ H5B2_nodepos_t curr_pos; /* Position of current node */
unsigned depth; /* Current depth of the tree */
int cmp; /* Comparison value of records */
unsigned idx; /* Location of record which matches key */
@@ -990,16 +1054,17 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op,
/* Make copy of the root node pointer to start search with */
curr_node_ptr = hdr->root;
- /* Current depth of the tree */
- depth = hdr->depth;
-
/* Check for empty tree */
if(0 == curr_node_ptr.node_nrec)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records")
+ /* Current depth of the tree */
+ depth = hdr->depth;
+
/* Walk down B-tree to find record or leaf node where record is located */
cmp = -1;
- while(depth > 0 && cmp != 0) {
+ curr_pos = H5B2_POS_ROOT;
+ while(depth > 0) {
unsigned internal_flags = H5AC__NO_FLAGS_SET;
H5B2_internal_t *internal; /* Pointer to internal node in B-tree */
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
@@ -1017,6 +1082,24 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op,
/* Get node pointer for next node to search */
next_node_ptr = internal->node_ptrs[idx];
+ /* Set the position of the next node */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ curr_pos = H5B2_POS_LEFT;
+ else
+ curr_pos = H5B2_POS_MIDDLE;
+ } /* end if */
+ else if(idx == internal->nrec) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ curr_pos = H5B2_POS_RIGHT;
+ else
+ curr_pos = H5B2_POS_MIDDLE;
+ } /* end if */
+ else
+ curr_pos = H5B2_POS_MIDDLE;
+ } /* end if */
+
/* Unlock current node */
if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
@@ -1092,6 +1175,27 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op,
HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation")
} /* end if */
+
+ /* Check for modified record being the min or max for the tree */
+ /* (Don't use 'else' for the idx check, to allow for root leaf node) */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->min_native_rec == NULL)
+ if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info")
+ HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ } /* end if */
+ } /* end if */
+ if(idx == (unsigned)(leaf->nrec - 1)) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->max_native_rec == NULL)
+ if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info")
+ HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ } /* end if */
+ } /* end if */
+ } /* end if */
} /* end else */
/* Mark the node as dirty if it changed */
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index 1554501..1e2a6a3 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5B2cache.c
- * Jan 31 2005
- * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Created: H5B2cache.c
+ * Jan 31 2005
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Implement v2 B-tree metadata cache methods.
+ * Purpose: Implement v2 B-tree metadata cache methods.
*
*-------------------------------------------------------------------------
*/
@@ -174,7 +174,7 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Allocate new B-tree header and reset cache info */
if(NULL == (hdr = H5B2_hdr_alloc(udata->f)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "allocation failed for B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "allocation failed for B-tree header")
/* Wrap the local buffer for serialized header info */
if(NULL == (wb = H5WB_wrap(hdr_buf, sizeof(hdr_buf))))
@@ -186,7 +186,7 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Read header from disk */
if(H5F_block_read(f, H5FD_MEM_BTREE, addr, hdr->hdr_size, dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree header")
/* Get temporary pointer to serialized header */
p = buf;
@@ -203,7 +203,7 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* B-tree class */
id = (H5B2_subid_t)*p++;
if(id >= H5B2_NUM_BTREE_ID)
- HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
+ HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
/* Node size (in bytes) */
UINT32DECODE(p, cparam.node_size);
@@ -234,12 +234,12 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Verify checksum */
if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 B-tree header")
/* Initialize B-tree header info */
cparam.cls = H5B2_client_class_g[id];
if(H5B2_hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info")
/* Set the B-tree header's address */
hdr->addr = addr;
@@ -342,17 +342,17 @@ H5B2__cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Metadata checksum */
UINT32ENCODE(p, metadata_chksum);
- /* Write the B-tree header. */
+ /* Write the B-tree header. */
HDassert((size_t)(p - buf) == hdr->hdr_size);
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, hdr->hdr_size, dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree header to disk")
+ if(H5F_block_write(f, H5FD_MEM_BTREE, addr, hdr->hdr_size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree header to disk")
- hdr->cache_info.is_dirty = FALSE;
+ hdr->cache_info.is_dirty = FALSE;
} /* end if */
if(destroy)
if(H5B2__cache_hdr_dest(f, hdr) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header")
done:
/* Release resources */
@@ -445,17 +445,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2__cache_hdr_size
+ * Function: H5B2__cache_hdr_size
*
- * Purpose: Compute the size in bytes of a B-tree header
- * on disk, and return it in *size_ptr. On failure,
- * the value of *size_ptr is undefined.
+ * Purpose: Compute the size in bytes of a B-tree header
+ * on disk, and return it in *size_ptr. On failure,
+ * the value of *size_ptr is undefined.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 1 2005
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Feb 1 2005
*
*-------------------------------------------------------------------------
*/
@@ -466,6 +466,7 @@ H5B2__cache_hdr_size(const H5F_t UNUSED *f, const H5B2_hdr_t *hdr, size_t *size_
/* check arguments */
HDassert(f);
+ HDassert(hdr);
HDassert(size_ptr);
/* Set size value */
@@ -519,14 +520,14 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Increment ref. count on B-tree header */
if(H5B2_hdr_incr(udata->hdr) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header")
/* Share B-tree information */
internal->hdr = udata->hdr;
/* Read header from disk */
if(H5F_block_read(f, H5FD_MEM_BTREE, addr, udata->hdr->node_size, dxpl_id, udata->hdr->page) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree internal node")
+ HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree internal node")
p = udata->hdr->page;
@@ -541,7 +542,7 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* B-tree type */
if(*p++ != (uint8_t)udata->hdr->cls->id)
- HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
+ HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
/* Allocate space for the native keys in memory */
if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac)))
@@ -593,7 +594,7 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Verify checksum */
if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 internal node")
+ HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 internal node")
/* Set return value */
ret_value = internal;
@@ -853,7 +854,7 @@ H5B2__cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata
/* Allocate new leaf node and reset cache info */
if(NULL == (leaf = H5FL_MALLOC(H5B2_leaf_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
HDmemset(&leaf->cache_info, 0, sizeof(H5AC_info_t));
/* Set the B-tree header's file context for this operation */
@@ -861,33 +862,33 @@ H5B2__cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata
/* Increment ref. count on B-tree header */
if(H5B2_hdr_incr(udata->hdr) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header")
/* Share B-tree header information */
leaf->hdr = udata->hdr;
/* Read header from disk */
if(H5F_block_read(udata->f, H5FD_MEM_BTREE, addr, udata->hdr->node_size, dxpl_id, udata->hdr->page) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree leaf node")
+ HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree leaf node")
p = udata->hdr->page;
/* Magic number */
if(HDmemcmp(p, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node signature")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node signature")
p += H5_SIZEOF_MAGIC;
/* Version */
if(*p++ != H5B2_LEAF_VERSION)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node version")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node version")
/* B-tree type */
if(*p++ != (uint8_t)udata->hdr->cls->id)
- HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
+ HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
/* Allocate space for the native keys in memory */
if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys")
+ HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys")
/* Set the number of records in the leaf */
leaf->nrec = udata->nrec;
diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c
index 443a2e5..452a35d 100644
--- a/src/H5B2hdr.c
+++ b/src/H5B2hdr.c
@@ -166,7 +166,7 @@ HDmemset(hdr->page, 0, hdr->node_size);
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(hdr->cls->nrec_size * hdr->node_info[0].max_nrec)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory")
hdr->node_info[0].node_ptr_fac = NULL;
/* Allocate array of pointers to internal node native keys */
@@ -250,7 +250,7 @@ H5B2_hdr_alloc(H5F_t *f)
/* Allocate space for the shared information */
if(NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree header")
/* Assign non-zero information */
hdr->f = f;
@@ -298,19 +298,19 @@ H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam,
/* Allocate v2 B-tree header */
if(NULL == (hdr = H5B2_hdr_alloc(f)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header")
/* Initialize shared B-tree info */
if(H5B2_hdr_init(hdr, cparam, ctx_udata, (uint16_t)0) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info")
/* Allocate space for the header on disk */
if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)hdr->hdr_size)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for B-tree header")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for B-tree header")
/* Cache the new B-tree node */
if(H5AC_insert_entry(f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, HADDR_UNDEF, "can't add B-tree header to cache")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, HADDR_UNDEF, "can't add B-tree header to cache")
/* Set address of v2 B-tree header to return */
ret_value = hdr->addr;
@@ -398,15 +398,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_hdr_fuse_incr
+ * Function: H5B2_hdr_fuse_incr
*
- * Purpose: Increment file reference count on shared v2 B-tree header
+ * Purpose: Increment file reference count on shared v2 B-tree header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 27 2009
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 27 2009
*
*-------------------------------------------------------------------------
*/
@@ -426,15 +426,15 @@ H5B2_hdr_fuse_incr(H5B2_hdr_t *hdr)
/*-------------------------------------------------------------------------
- * Function: H5B2_hdr_fuse_decr
+ * Function: H5B2_hdr_fuse_decr
*
- * Purpose: Decrement file reference count on shared v2 B-tree header
+ * Purpose: Decrement file reference count on shared v2 B-tree header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: The file's reference count after the decrement. (Can't fail)
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 27 2009
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 27 2009
*
*-------------------------------------------------------------------------
*/
@@ -542,6 +542,16 @@ H5B2_hdr_free(H5B2_hdr_t *hdr)
hdr->node_info = H5FL_SEQ_FREE(H5B2_node_info_t, hdr->node_info);
} /* end if */
+ /* Release the min & max record info, if set */
+ if(hdr->min_native_rec) {
+ HDfree(hdr->min_native_rec);
+ hdr->min_native_rec = NULL;
+ } /* end if */
+ if(hdr->max_native_rec) {
+ HDfree(hdr->max_native_rec);
+ hdr->max_native_rec = NULL;
+ } /* end if */
+
/* Free B-tree header info */
hdr = H5FL_FREE(H5B2_hdr_t, hdr);
diff --git a/src/H5B2int.c b/src/H5B2int.c
index 630ff98..ef83e93 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -172,9 +172,9 @@ H5B2_locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off,
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_ptr,
- unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal,
- unsigned *internal_flags_ptr, unsigned idx)
+H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
+ H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
+ H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
@@ -214,7 +214,7 @@ H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *cur
left_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx + 1].addr;
- /* Protect both leafs */
+ /* Protect both leaves */
if(NULL == (left_int = H5B2_protect_internal(hdr, dxpl_id, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node")
if(NULL == (right_int = H5B2_protect_internal(hdr, dxpl_id, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
@@ -243,7 +243,7 @@ H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *cur
left_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx + 1].addr;
- /* Protect both leafs */
+ /* Protect both leaves */
if(NULL == (left_leaf = H5B2_protect_leaf(hdr, dxpl_id, left_addr, internal->node_ptrs[idx].node_nrec, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node")
if(NULL == (right_leaf = H5B2_protect_leaf(hdr, dxpl_id, right_addr, internal->node_ptrs[idx + 1].node_nrec, H5AC_WRITE)))
@@ -341,7 +341,7 @@ done:
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_split1 */
+} /* end H5B2_split1() */
/*-------------------------------------------------------------------------
@@ -646,7 +646,7 @@ done:
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_redistribute2 */
+} /* end H5B2_redistribute2() */
/*-------------------------------------------------------------------------
@@ -1033,7 +1033,7 @@ done:
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_redistribute3 */
+} /* end H5B2_redistribute3() */
/*-------------------------------------------------------------------------
@@ -1505,7 +1505,7 @@ done:
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_swap_leaf */
+} /* end H5B2_swap_leaf() */
/*-------------------------------------------------------------------------
@@ -1523,7 +1523,7 @@ done:
*/
herr_t
H5B2_insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr,
- void *udata)
+ H5B2_nodepos_t curr_pos, void *udata)
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
int cmp; /* Comparison value of records */
@@ -1574,6 +1574,27 @@ H5B2_insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr,
/* Update record count for current node */
leaf->nrec++;
+ /* Check for new record being the min or max for the tree */
+ /* (Don't use 'else' for the idx check, to allow for root leaf node) */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->min_native_rec == NULL)
+ if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info")
+ HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ } /* end if */
+ } /* end if */
+ if(idx == (unsigned)(leaf->nrec - 1)) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->max_native_rec == NULL)
+ if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info")
+ HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
done:
/* Release the B-tree leaf node (marked as dirty) */
if(leaf && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__DIRTIED_FLAG) < 0)
@@ -1599,11 +1620,12 @@ done:
herr_t
H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr,
- void *udata)
+ H5B2_nodepos_t curr_pos, void *udata)
{
- H5B2_internal_t *internal; /* Pointer to internal node */
+ H5B2_internal_t *internal = NULL; /* Pointer to internal node */
unsigned internal_flags = H5AC__NO_FLAGS_SET;
unsigned idx; /* Location of record which matches key */
+ H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1618,7 +1640,7 @@ H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node")
-/* Split or redistribute child node pointers, if necessary */
+ /* Split or redistribute child node pointers, if necessary */
{
int cmp; /* Comparison value of records */
unsigned retries; /* Number of times to attempt redistribution */
@@ -1691,13 +1713,25 @@ H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
} /* end while */
} /* end block */
+ /* Check if this node is left/right-most */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ next_pos = H5B2_POS_LEFT;
+ } /* end if */
+ else if(idx == internal->nrec) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ next_pos = H5B2_POS_RIGHT;
+ } /* end else */
+ } /* end if */
+
/* Attempt to insert node */
if(depth > 1) {
- if(H5B2_insert_internal(hdr, dxpl_id, (depth - 1), &internal_flags, &internal->node_ptrs[idx], udata) < 0)
+ if(H5B2_insert_internal(hdr, dxpl_id, (depth - 1), &internal_flags, &internal->node_ptrs[idx], next_pos, udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node")
} /* end if */
else {
- if(H5B2_insert_leaf(hdr, dxpl_id, &internal->node_ptrs[idx], udata) < 0)
+ if(H5B2_insert_leaf(hdr, dxpl_id, &internal->node_ptrs[idx], next_pos, udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node")
} /* end else */
@@ -2074,7 +2108,7 @@ done:
*/
herr_t
H5B2_remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr,
- void *udata, H5B2_remove_t op, void *op_data)
+ H5B2_nodepos_t curr_pos, void *udata, H5B2_remove_t op, void *op_data)
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */
@@ -2102,6 +2136,27 @@ H5B2_remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr,
if(H5B2_locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx) != 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record is not in B-tree")
+ /* Check for invalidating the min/max record for the tree */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ /* (Don't use 'else' for the idx check, to allow for root leaf node) */
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->min_native_rec) {
+ HDfree(hdr->min_native_rec);
+ hdr->min_native_rec = NULL;
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ if(idx == (unsigned)(leaf->nrec - 1)) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->max_native_rec) {
+ HDfree(hdr->max_native_rec);
+ hdr->max_native_rec = NULL;
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
/* Make 'remove' callback if there is one */
if(op)
if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0)
@@ -2154,13 +2209,14 @@ done:
herr_t
H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, hbool_t *depth_decreased,
void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info,
- unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr,
- void *udata, H5B2_remove_t op, void *op_data)
+ unsigned *parent_cache_info_flags_ptr, H5B2_nodepos_t curr_pos,
+ H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, void *op_data)
{
H5AC_info_t *new_cache_info; /* Pointer to new cache info */
unsigned *new_cache_info_flags_ptr = NULL;
H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */
H5B2_internal_t *internal; /* Pointer to internal node */
+ H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */
unsigned internal_flags = H5AC__NO_FLAGS_SET;
haddr_t internal_addr; /* Address of internal node */
size_t merge_nrec; /* Number of records to merge node at */
@@ -2211,6 +2267,9 @@ H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, hbool_t *depth_decreased,
/* Set flag to indicate root was collapsed */
collapsed_root = TRUE;
+
+ /* Indicate position of next node */
+ next_pos = H5B2_POS_ROOT;
} /* end if */
/* Merge or redistribute child node pointers, if necessary */
else {
@@ -2306,16 +2365,28 @@ H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, hbool_t *depth_decreased,
new_cache_info_flags_ptr = &internal_flags;
new_cache_info = &internal->cache_info;
new_node_ptr = &internal->node_ptrs[idx];
+
+ /* Indicate position of next node */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ next_pos = H5B2_POS_LEFT;
+ } /* end if */
+ else if(idx == internal->nrec) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ next_pos = H5B2_POS_RIGHT;
+ } /* end if */
+ } /* end if */
} /* end else */
/* Attempt to remove record from child node */
if(depth > 1) {
if(H5B2_remove_internal(hdr, dxpl_id, depth_decreased, swap_loc, depth - 1,
- new_cache_info, new_cache_info_flags_ptr, new_node_ptr, udata, op, op_data) < 0)
+ new_cache_info, new_cache_info_flags_ptr, next_pos, new_node_ptr, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
} /* end if */
else {
- if(H5B2_remove_leaf(hdr, dxpl_id, new_node_ptr, udata, op, op_data) < 0)
+ if(H5B2_remove_leaf(hdr, dxpl_id, new_node_ptr, next_pos, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
@@ -2355,8 +2426,8 @@ done:
*/
herr_t
H5B2_remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
- H5B2_node_ptr_t *curr_node_ptr, unsigned idx, H5B2_remove_t op,
- void *op_data)
+ H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos,
+ unsigned idx, H5B2_remove_t op, void *op_data)
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */
@@ -2380,6 +2451,27 @@ H5B2_remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
HDassert(leaf->nrec == curr_node_ptr->node_nrec);
HDassert(idx < leaf->nrec);
+ /* Check for invalidating the min/max record for the tree */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ /* (Don't use 'else' for the idx check, to allow for root leaf node) */
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->min_native_rec) {
+ HDfree(hdr->min_native_rec);
+ hdr->min_native_rec = NULL;
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ if(idx == (unsigned)(leaf->nrec - 1)) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) {
+ if(hdr->max_native_rec) {
+ HDfree(hdr->max_native_rec);
+ hdr->max_native_rec = NULL;
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
/* Make 'remove' callback if there is one */
if(op)
if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0)
@@ -2434,13 +2526,14 @@ herr_t
H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
hbool_t *depth_decreased, void *swap_loc, unsigned depth,
H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
- H5B2_node_ptr_t *curr_node_ptr, hsize_t n, H5B2_remove_t op,
- void *op_data)
+ H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n,
+ H5B2_remove_t op, void *op_data)
{
H5AC_info_t *new_cache_info; /* Pointer to new cache info */
unsigned *new_cache_info_flags_ptr = NULL;
H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */
H5B2_internal_t *internal; /* Pointer to internal node */
+ H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */
unsigned internal_flags = H5AC__NO_FLAGS_SET;
haddr_t internal_addr; /* Address of internal node */
size_t merge_nrec; /* Number of records to merge node at */
@@ -2494,6 +2587,9 @@ H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
/* Set flag to indicate root was collapsed */
collapsed_root = TRUE;
+
+ /* Indicate position of next node */
+ next_pos = H5B2_POS_ROOT;
} /* end if */
/* Merge or redistribute child node pointers, if necessary */
else {
@@ -2641,16 +2737,28 @@ H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
new_cache_info_flags_ptr = &internal_flags;
new_cache_info = &internal->cache_info;
new_node_ptr = &internal->node_ptrs[idx];
+
+ /* Indicate position of next node */
+ if(H5B2_POS_MIDDLE != curr_pos) {
+ if(idx == 0) {
+ if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ next_pos = H5B2_POS_LEFT;
+ } /* end if */
+ else if(idx == internal->nrec) {
+ if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos)
+ next_pos = H5B2_POS_RIGHT;
+ } /* end if */
+ } /* end if */
} /* end else */
/* Attempt to remove record from child node */
if(depth > 1) {
if(H5B2_remove_internal_by_idx(hdr, dxpl_id, depth_decreased, swap_loc, depth - 1,
- new_cache_info, new_cache_info_flags_ptr, new_node_ptr, n, op, op_data) < 0)
+ new_cache_info, new_cache_info_flags_ptr, new_node_ptr, next_pos, n, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
} /* end if */
else {
- if(H5B2_remove_leaf_by_idx(hdr, dxpl_id, new_node_ptr, (unsigned)n, op, op_data) < 0)
+ if(H5B2_remove_leaf_by_idx(hdr, dxpl_id, new_node_ptr, next_pos, (unsigned)n, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h
index b820853..7a538bd 100644
--- a/src/H5B2pkg.h
+++ b/src/H5B2pkg.h
@@ -172,6 +172,8 @@ typedef struct H5B2_hdr_t {
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 */
+ uint8_t *min_native_rec; /* Pointer to minimum native record */
+ uint8_t *max_native_rec; /* Pointer to maximum native record */
/* Client information (not stored) */
const H5B2_class_t *cls; /* Class of B-tree client */
@@ -208,6 +210,14 @@ struct H5B2_t {
H5F_t *f; /* Pointer to file for v2 B-tree */
};
+/* Node position, for min/max determination */
+typedef enum H5B2_nodepos_t {
+ H5B2_POS_ROOT, /* Node is root (i.e. both right & left-most in tree) */
+ H5B2_POS_RIGHT, /* Node is right-most in tree, at a given depth */
+ H5B2_POS_LEFT, /* Node is left-most in tree, at a given depth */
+ H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */
+} H5B2_nodepos_t;
+
/* Callback info for loading a free space header into the cache */
typedef struct H5B2_hdr_cache_ud_t {
H5F_t *f; /* File that v2 b-tree header is within */
@@ -304,9 +314,9 @@ H5_DLL herr_t H5B2_internal_free(H5B2_internal_t *i);
/* Routines for inserting records */
H5_DLL herr_t H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
unsigned depth, unsigned *parent_cache_info_flags_ptr,
- H5B2_node_ptr_t *curr_node_ptr, void *udata);
+ H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata);
H5_DLL herr_t H5B2_insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
- H5B2_node_ptr_t *curr_node_ptr, void *udata);
+ H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata);
/* Routines for iterating over nodes/records */
H5_DLL herr_t H5B2_iterate_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
@@ -326,19 +336,21 @@ H5_DLL herr_t H5B2_neighbor_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
/* Routines for removing records */
H5_DLL herr_t H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
- 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,
+ hbool_t *depth_decreased, void *swap_loc, unsigned depth,
+ H5AC_info_t *parent_cache_info, hbool_t * parent_cache_info_dirtied_ptr,
+ H5B2_nodepos_t curr_pos, H5B2_node_ptr_t *curr_node_ptr, void *udata,
H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
- H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op,
- void *op_data);
+ H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos,
+ void *udata, H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
- 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,
+ 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, H5B2_nodepos_t curr_pos, hsize_t idx,
H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
- H5B2_node_ptr_t *curr_node_ptr, unsigned idx, H5B2_remove_t op,
- void *op_data);
+ H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos,
+ unsigned idx, H5B2_remove_t op, void *op_data);
/* Routines for deleting nodes */
H5_DLL herr_t H5B2_delete_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
diff --git a/src/H5B2stat.c b/src/H5B2stat.c
index 5e48a6f..5d159ed 100644
--- a/src/H5B2stat.c
+++ b/src/H5B2stat.c
@@ -13,10 +13,10 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+/* Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Monday, March 6, 2006
*
- * Purpose: v2 B-tree metadata statistics functions.
+ * Purpose: v2 B-tree metadata statistics functions.
*
*/
@@ -24,15 +24,15 @@
/* Module Setup */
/****************/
-#define H5B2_PACKAGE /*suppress error about including H5B2pkg */
+#define H5B2_PACKAGE /* Suppress error about including H5B2pkg */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5B2pkg.h" /* v2 B-trees */
-#include "H5Eprivate.h" /* Error handling */
+#include "H5private.h" /* Generic Functions */
+#include "H5B2pkg.h" /* v2 B-trees */
+#include "H5Eprivate.h" /* Error handling */
/****************/
@@ -71,14 +71,13 @@
/*-------------------------------------------------------------------------
- * Function: H5B2_stat_info
+ * Function: H5B2_stat_info
*
- * Purpose: Retrieve metadata statistics for a v2 B-tree
+ * Purpose: Retrieve metadata statistics for a v2 B-tree
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, March 6, 2006
*
*-------------------------------------------------------------------------
@@ -105,7 +104,7 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info)
* Purpose: Iterate over all the records in the B-tree, collecting
* storage info.
*
- * Return: non-negative on success, negative on error
+ * Return: SUCCEED/FAIL
*
* Programmer: Vailin Choi
* June 19 2007
@@ -115,7 +114,7 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info)
herr_t
H5B2_size(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size)
{
- H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c
index 039ebdc..35c2afa 100644
--- a/src/H5Dbtree.c
+++ b/src/H5Dbtree.c
@@ -195,7 +195,7 @@ H5B_class_t H5B_BTREE[1] = {{
H5D__btree_remove, /*remove */
H5D__btree_decode_key, /*decode */
H5D__btree_encode_key, /*encode */
- H5D__btree_debug_key, /*debug */
+ H5D__btree_debug_key /*debug */
}};
@@ -228,7 +228,7 @@ H5D__btree_get_shared(const H5F_t UNUSED *f, const void *_udata)
HDassert(udata);
HDassert(udata->storage);
- HDassert(udata->storage->idx_type == H5D_CHUNK_BTREE);
+ HDassert(udata->storage->idx_type == H5D_CHUNK_IDX_BTREE);
HDassert(udata->storage->u.btree.shared);
/* Return the pointer to the ref-count object */
@@ -868,7 +868,7 @@ done:
static herr_t
H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info)
{
- H5D_chunk_common_ud_t udata; /* User data for B-tree callback */
+ H5D_chunk_common_ud_t udata; /* User data for B-tree callback */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -939,7 +939,7 @@ H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage)
static herr_t
H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1111,7 +1111,7 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info,
static herr_t
H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1453,7 +1453,7 @@ H5D_btree_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent
/* Reset "fake" storage info */
HDmemset(&storage, 0, sizeof(storage));
- storage.idx_type = H5D_CHUNK_BTREE;
+ storage.idx_type = H5D_CHUNK_IDX_BTREE;
/* Allocate the shared structure */
if(H5D__btree_shared_create(f, &storage, ndims) < 0)
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 46f0a4f..9f2a020 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -318,24 +318,22 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz
uint32_t data_size, const void *buf)
{
const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */
- H5D_chunk_ud_t udata; /* User data for querying chunk info */
+ H5D_chunk_ud_t udata; /* User data for querying chunk info */
hsize_t chunk_idx;
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */
int space_ndims; /* Dataset's space rank */
hsize_t space_dim[H5O_LAYOUT_NDIMS]; /* Dataset's dataspace dimensions */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL)
/* Allocate data space and initialize it if it hasn't been. */
- if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) {
+ if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage))
/* Allocate storage */
if(H5D__alloc_storage(dset, dxpl_id, H5D_ALLOC_WRITE, FALSE, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage")
- } /* end if */
-
/* Retrieve the dataset dimensions */
if((space_ndims = H5S_get_simple_extent_dims(dset->shared->space, space_dim, NULL)) < 0)
@@ -385,11 +383,9 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz
/* Evict the entry from the cache if present, but do not flush
* it to disk */
- if(UINT_MAX != udata.idx_hint) {
- if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache,
- rdcc->slot[udata.idx_hint], FALSE) < 0)
+ if(UINT_MAX != udata.idx_hint)
+ if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, rdcc->slot[udata.idx_hint], FALSE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk")
- } /* end if */
/* Write the data to the file */
if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, data_size, dxpl_id, buf) < 0)
@@ -1317,13 +1313,12 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
new_chunk_info->mspace_shared = FALSE;
/* Copy the chunk's coordinates */
- for(u=0; u<fm->f_ndims; u++)
- new_chunk_info->coords[u]=coords[u];
- new_chunk_info->coords[fm->f_ndims]=0;
+ HDmemcpy(new_chunk_info->coords, coords, sizeof(hsize_t) * fm->f_ndims);
+ new_chunk_info->coords[fm->f_ndims] = 0;
/* Insert the new chunk into the skip list */
if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) {
- H5D__free_chunk_info(new_chunk_info, NULL, NULL);
+ H5D__free_chunk_info(new_chunk_info, NULL, NULL);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list")
} /* end if */
@@ -1508,7 +1503,7 @@ H5D__chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, unsigned ndims, cons
H5D_chunk_file_iter_ud_t *udata = (H5D_chunk_file_iter_ud_t *)_udata; /* User data for operation */
H5D_chunk_map_t *fm = udata->fm; /* File<->memory chunk mapping info */
H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */
- hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */
+ hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */
hsize_t chunk_index; /* Chunk index */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2238,8 +2233,6 @@ H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last)
static herr_t
H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *udata)
{
- unsigned u; /* Local index variable */
-
FUNC_ENTER_STATIC_NOERR
/* Sanity check */
@@ -2250,8 +2243,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud
HDassert(udata->common.offset);
/* Stored the information to cache */
- for(u = 0; u < udata->common.layout->ndims; u++)
- last->offset[u] = udata->common.offset[u];
+ HDmemcpy(last->offset, udata->common.offset, sizeof(hsize_t) * udata->common.layout->ndims);
last->nbytes = udata->nbytes;
last->filter_mask = udata->filter_mask;
last->addr = udata->addr;
@@ -2820,7 +2812,6 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
haddr_t chunk_addr = HADDR_UNDEF; /* Address of chunk on disk */
size_t chunk_size; /*size of a chunk */
void *chunk = NULL; /*the file chunk */
- unsigned u; /*counters */
void *ret_value; /*return value */
FUNC_ENTER_PACKAGE
@@ -2846,9 +2837,13 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
ent = rdcc->slot[udata->idx_hint];
#ifndef NDEBUG
+{
+ unsigned u; /*counters */
+
/* Make sure this is the right chunk */
for(u = 0; u < layout->u.chunk.ndims; u++)
HDassert(io_info->store->chunk.offset[u] == ent->offset[u]);
+}
#endif /* NDEBUG */
/*
@@ -2990,15 +2985,12 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache")
/* Create a new entry */
- if(NULL == (ent = H5FL_MALLOC(H5D_rdcc_ent_t)))
+ if(NULL == (ent = H5FL_CALLOC(H5D_rdcc_ent_t)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate raw data chunk entry")
- ent->locked = 0;
- ent->dirty = FALSE;
- ent->deleted = FALSE;
+ /* Initialize the new entry */
ent->chunk_addr = chunk_addr;
- for(u = 0; u < layout->u.chunk.ndims; u++)
- ent->offset[u] = io_info->store->chunk.offset[u];
+ HDmemcpy(ent->offset, io_info->store->chunk.offset, sizeof(hsize_t) * layout->u.chunk.ndims);
H5_ASSIGN_OVERFLOW(ent->rd_count, chunk_size, size_t, uint32_t);
H5_ASSIGN_OVERFLOW(ent->wr_count, chunk_size, size_t, uint32_t);
ent->chunk = (uint8_t *)chunk;
@@ -3011,16 +3003,13 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
rdcc->nused++;
/* Add it to the linked list */
- ent->next = NULL;
if(rdcc->tail) {
rdcc->tail->next = ent;
ent->prev = rdcc->tail;
rdcc->tail = ent;
} /* end if */
- else {
+ else
rdcc->head = rdcc->tail = ent;
- ent->prev = NULL;
- } /* end else */
} /* end if */
else
/* We did not add the chunk to cache */
@@ -3413,8 +3402,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite,
continue;
else {
/* Reset the chunk offset indices */
- HDmemset(chunk_offset, 0, ((unsigned)space_ndims
- * sizeof(chunk_offset[0])));
+ HDmemset(chunk_offset, 0, ((unsigned)space_ndims * sizeof(chunk_offset[0])));
chunk_offset[op_dim] = min_unalloc[op_dim];
carry = FALSE;
@@ -3444,10 +3432,12 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite,
/* Make sure the chunk is really in the dataset and outside the
* original dimensions */
{
+ unsigned u; /* Local index variable */
hbool_t outside_orig = FALSE;
- for(i=0; i<space_ndims; i++) {
- HDassert(chunk_offset[i] < space_dim[i]);
- if(chunk_offset[i] >= old_dim[i])
+
+ for(u = 0; u < (unsigned)space_ndims; u++) {
+ HDassert(chunk_offset[u] < space_dim[u]);
+ if(chunk_offset[u] >= old_dim[u])
outside_orig = TRUE;
} /* end for */
HDassert(outside_orig);
@@ -3546,13 +3536,14 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite,
/* Increment indices */
carry = TRUE;
- for(i = (int)(space_ndims - 1); i >= 0; --i) {
+ for(i = ((int)space_ndims - 1); i >= 0; --i) {
chunk_offset[i] += chunk_dim[i];
- if(chunk_offset[i] > max_unalloc[i])
+ if(chunk_offset[i] > max_unalloc[i]) {
if(i == op_dim)
chunk_offset[i] = min_unalloc[i];
else
chunk_offset[i] = 0;
+ } /* end if */
else {
carry = FALSE;
break;
@@ -4006,7 +3997,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
hsize_t hyper_start[H5O_LAYOUT_NDIMS]; /* Starting location of hyperslab */
uint32_t elmts_per_chunk; /* Elements in chunk */
hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */
- int i; /* Local index variable */
+ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -4043,15 +4034,14 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
/* (also copy the chunk dimensions into 'hsize_t' array for creating dataspace) */
/* (also compute the dimensions which have been shrunk) */
elmts_per_chunk = 1;
- for(i = 0; i < space_ndims; i++) {
- elmts_per_chunk *= layout->u.chunk.dim[i];
- chunk_dim[i] = layout->u.chunk.dim[i];
- shrunk_dim[i] = space_dim[i] < old_dim[i];
+ for(u = 0; u < (unsigned)space_ndims; u++) {
+ elmts_per_chunk *= layout->u.chunk.dim[u];
+ chunk_dim[u] = layout->u.chunk.dim[u];
+ shrunk_dim[u] = space_dim[u] < old_dim[u];
} /* end for */
/* Create a dataspace for a chunk & set the extent */
- if(NULL == (chunk_space = H5S_create_simple((unsigned)space_ndims,
- chunk_dim, NULL)))
+ if(NULL == (chunk_space = H5S_create_simple((unsigned)space_ndims, chunk_dim, NULL)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
/* Reset hyperslab start array */
@@ -4118,8 +4108,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
/ chunk_dim[op_dim]);
/* Determine if we need to fill chunks in this dimension */
- if((hssize_t)min_mod_chunk_off[op_dim]
- == max_fill_chunk_off[op_dim]) {
+ if((hssize_t)min_mod_chunk_off[op_dim] == max_fill_chunk_off[op_dim]) {
fill_dim[op_dim] = TRUE;
has_fill = TRUE;
} /* end if */
@@ -4136,8 +4125,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
if(has_fill)
for(ent = rdcc->head; ent; ent = ent->next)
/* Check for chunk offset outside of new dimensions */
- for(i = 0; i<space_ndims; i++)
- if((hsize_t)ent->offset[i] >= space_dim[i]) {
+ for(u = 0; u < (unsigned)space_ndims; u++)
+ if((hsize_t)ent->offset[u] >= space_dim[u]) {
/* Mark the entry as "deleted" */
ent->deleted = TRUE;
break;
@@ -4149,28 +4138,28 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
if(!shrunk_dim[op_dim])
continue;
else {
- HDassert((hsize_t) max_mod_chunk_off[op_dim]
- >= min_mod_chunk_off[op_dim]);
+ HDassert((hsize_t) max_mod_chunk_off[op_dim] >= min_mod_chunk_off[op_dim]);
/* Reset the chunk offset indices */
- HDmemset(chunk_offset, 0, ((unsigned)space_ndims
- * sizeof(chunk_offset[0])));
+ HDmemset(chunk_offset, 0, ((unsigned)space_ndims * sizeof(chunk_offset[0])));
chunk_offset[op_dim] = min_mod_chunk_off[op_dim];
/* Initialize "dims_outside_fill" array */
ndims_outside_fill = 0;
- for(i=0; i<space_ndims; i++)
- if((hssize_t)chunk_offset[i] > max_fill_chunk_off[i]) {
- dims_outside_fill[i] = TRUE;
+ for(u = 0; u < (unsigned)space_ndims; u++)
+ if((hssize_t)chunk_offset[u] > max_fill_chunk_off[u]) {
+ dims_outside_fill[u] = TRUE;
ndims_outside_fill++;
} /* end if */
else
- dims_outside_fill[i] = FALSE;
+ dims_outside_fill[u] = FALSE;
carry = FALSE;
} /* end if */
while(!carry) {
+ int i; /* Local index variable */
+
/* Calculate the index of this chunk */
if(H5VM_chunk_index((unsigned)space_ndims, chunk_offset,
layout->u.chunk.dim, layout->u.chunk.down_chunks,
@@ -4191,8 +4180,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
{
hbool_t outside_dim = FALSE;
- for(i=0; i<space_ndims; i++)
- if(chunk_offset[i] >= space_dim[i]){
+ for(u = 0; u < (unsigned)space_ndims; u++)
+ if(chunk_offset[u] >= space_dim[u]) {
outside_dim = TRUE;
break;
} /* end if */
@@ -4206,11 +4195,9 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
/* Evict the entry from the cache if present, but do not flush
* it to disk */
- if(UINT_MAX != chk_udata.idx_hint) {
- if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache,
- rdcc->slot[chk_udata.idx_hint], FALSE) < 0)
+ if(UINT_MAX != chk_udata.idx_hint)
+ if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, rdcc->slot[chk_udata.idx_hint], FALSE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk")
- } /* end if */
/* Remove the chunk from disk, if present */
if(H5F_addr_defined(chk_udata.addr)) {
@@ -4218,8 +4205,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
idx_udata.offset = chunk_offset;
/* Remove the chunk from disk */
- if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata)
- < 0)
+ if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry from index")
} /* end if */
} /* end else */
@@ -4248,8 +4234,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
} /* end if */
else {
/* Check if we just went outside the fill dimension */
- if(!dims_outside_fill[i] && (hssize_t)chunk_offset[i]
- > max_fill_chunk_off[i]) {
+ if(!dims_outside_fill[i] && (hssize_t)chunk_offset[i] > max_fill_chunk_off[i]) {
dims_outside_fill[i] = TRUE;
ndims_outside_fill++;
} /* end if */
@@ -4267,8 +4252,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
if(min_mod_chunk_off[op_dim] == 0)
break;
else
- max_mod_chunk_off[op_dim] = min_mod_chunk_off[op_dim]
- - chunk_dim[op_dim];
+ max_mod_chunk_off[op_dim] = min_mod_chunk_off[op_dim] - chunk_dim[op_dim];
} /* end for(op_dim=0...) */
/* Reset any cached chunk info for this dataset */
@@ -4278,10 +4262,9 @@ done:
/* Release resources */
if(chunk_space && H5S_close(chunk_space) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
- if(udata_init) {
+ if(udata_init)
if(udata.fb_info_init && H5D__fill_term(&udata.fb_info) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info")
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__chunk_prune_by_extent() */
@@ -4473,7 +4456,7 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id)
H5D_rdcc_ent_t *old_ent; /* Old cache entry */
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
- unsigned rank; /*current # of dimensions */
+ unsigned rank; /* Current # of dimensions */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -5178,7 +5161,8 @@ H5D__chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset)
idx_info.storage = &dset->shared->layout.storage.u.chunk;
/* Free any index structures */
- if((dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0)
+ if(dset->shared->layout.storage.u.chunk.ops->dest &&
+ (dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info")
done:
diff --git a/src/H5Dint.c b/src/H5Dint.c
index ee346f3..8e1fcec 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -478,7 +478,6 @@ done:
herr_t
H5D__get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id)
{
- H5S_t *space; /* Dataset's dataspace */
hsize_t space_allocated; /* The number of bytes allocated for chunks */
hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
hsize_t nelmts; /* Number of elements in dataspace */
@@ -491,11 +490,10 @@ H5D__get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id
HDassert(dset);
/* Get the dataset's dataspace */
- space = dset->shared->space;
- HDassert(space);
+ HDassert(dset->shared->space);
/* Get the total number of elements in dataset's dataspace */
- if((snelmts = H5S_GET_EXTENT_NPOINTS(space)) < 0)
+ if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
nelmts = (hsize_t)snelmts;
@@ -1185,6 +1183,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id, hid_t dxpl_id)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count")
} /* end else */
+ /* Set the dataset to return */
ret_value = dataset;
done:
@@ -1226,6 +1225,7 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id)
H5O_fill_t *fill_prop; /* Pointer to dataset's fill value info */
unsigned alloc_time_state; /* Allocation time state */
htri_t msg_exists; /* Whether a particular type of message exists */
+ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC_TAG(dxpl_id, dataset->oloc.addr, FAIL)
@@ -1263,6 +1263,9 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id)
if(H5D__layout_oh_read(dataset, dxpl_id, dapl_id, plist) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout/pline/efl info")
+ /* Indicate that the layout information was initialized */
+ layout_init = TRUE;
+
/* Point at dataset's copy, to cache it for later */
fill_prop = &dataset->shared->dcpl_cache.fill;
@@ -1338,6 +1341,9 @@ done:
if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc)) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header")
if(dataset->shared) {
+ if(dataset->shared->layout.type == H5D_CHUNKED && layout_init)
+ if(H5D__chunk_dest(dataset->oloc.file, dxpl_id, dataset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache")
if(dataset->shared->space && H5S_close(dataset->shared->space) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
if(dataset->shared->type) {
@@ -2212,6 +2218,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
*/
/* Update the index values for the cached chunks for this dataset */
if(H5D_CHUNKED == dset->shared->layout.type) {
+ /* Update the cached chunk info */
if(H5D__chunk_set_info(dset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to update # of chunks")
if(H5D__chunk_update_cache(dset, dxpl_id) < 0)
@@ -2230,11 +2237,10 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
*-------------------------------------------------------------------------
*/
if(shrink && H5D_CHUNKED == dset->shared->layout.type &&
- (*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) {
+ (*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage))
/* Remove excess chunks */
if(H5D__chunk_prune_by_extent(dset, dxpl_id, curr_dims) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks")
- } /* end if */
/* Mark the dataspace as dirty, for later writing to the file */
if(H5D__mark(dset, dxpl_id, H5D_MARK_SPACE) < 0)
@@ -2667,16 +2673,14 @@ H5D_get_space(H5D_t *dset)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space")
/* Create an atom */
- if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space")
+ if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace")
done:
- if(ret_value < 0) {
- if(space!=NULL) {
+ if(ret_value < 0)
+ if(space != NULL)
if(H5S_close(space) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
- } /* end if */
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_get_space() */
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 096a211..88f75b1 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -305,7 +305,7 @@ H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
int ndims = 0;
hsize_t dims[H5O_LAYOUT_NDIMS];
hsize_t internal_offset[H5O_LAYOUT_NDIMS];
- int i;
+ unsigned u;
/* Get the dataset transfer property list */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
@@ -327,16 +327,16 @@ H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dims, NULL)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims")
- for(i = 0; i < ndims; i++) {
+ for(u = 0; u < ndims; u++) {
/* Make sure the offset doesn't exceed the dataset's dimensions */
- if(direct_offset[i] > dims[i])
+ if(direct_offset[u] > dims[u])
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset")
/* Make sure the offset fall right on a chunk's boundary */
- if(direct_offset[i] % dset->shared->layout.u.chunk.dim[i])
+ if(direct_offset[u] % dset->shared->layout.u.chunk.dim[u])
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary")
- internal_offset[i] = direct_offset[i];
+ internal_offset[u] = direct_offset[u];
} /* end for */
/* Terminate the offset with a zero */
diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c
index 58bcc04..01d2288 100644
--- a/src/H5Dmpio.c
+++ b/src/H5Dmpio.c
@@ -833,39 +833,37 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ
* equivalent of compressed contiguous datasets - QAK]
*/
if(total_chunks == 1) {
- H5D_chunk_ud_t udata; /* User data for querying chunk info */
- hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk in file dataset's dataspace */
H5SL_node_t *chunk_node; /* Pointer to chunk node for selection */
H5S_t *fspace; /* Dataspace describing chunk & selection in it */
H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */
- /* Initialize the chunk coordinates */
- /* (must be all zero, since there's only one chunk) */
- HDmemset(coords, 0, sizeof(coords));
-
- /* Look up address of chunk */
- if(H5D__chunk_lookup(io_info->dset, io_info->dxpl_id, coords,
- io_info->store->chunk.index, &udata) < 0)
- HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list")
- ctg_store.contig.dset_addr = udata.addr;
-
/* Check for this process having selection in this chunk */
chunk_node = H5SL_first(fm->sel_chunks);
if(chunk_node == NULL) {
- /* Set the dataspace info for I/O to NULL, this process doesn't have any I/O to perform */
- fspace = mspace = NULL;
+ /* Set the dataspace info for I/O to NULL, this process doesn't have any I/O to perform */
+ fspace = mspace = NULL;
+
+ /* Initialize chunk address */
+ ctg_store.contig.dset_addr = 0;
} /* end if */
else {
- H5D_chunk_info_t *chunk_info;
-
- /* Get the chunk info, for the selection in the chunk */
- if(NULL == (chunk_info = H5SL_item(chunk_node)))
- HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list")
-
- /* Set the dataspace info for I/O */
- fspace = chunk_info->fspace;
- mspace = chunk_info->mspace;
+ H5D_chunk_ud_t udata; /* User data for querying chunk info */
+ H5D_chunk_info_t *chunk_info; /* Info for chunk in skiplist */
+
+ /* Get the chunk info, for the selection in the chunk */
+ if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node)))
+ HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skip list")
+
+ /* Set the dataspace info for I/O */
+ fspace = chunk_info->fspace;
+ mspace = chunk_info->mspace;
+
+ /* Look up address of chunk */
+ if(H5D__chunk_lookup(io_info->dset, io_info->dxpl_id, chunk_info->coords,
+ chunk_info->index, &udata) < 0)
+ HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk address")
+ ctg_store.contig.dset_addr = udata.addr;
} /* end else */
/* Set up the base storage address for this chunk */
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 5a785a3..6128d7e 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -362,7 +362,7 @@ typedef struct H5D_chunk_map_t {
} H5D_chunk_map_t;
/* Cached information about a particular chunk */
-typedef struct H5D_chunk_cached_t{
+typedef struct H5D_chunk_cached_t {
hbool_t valid; /*whether cache info is valid*/
hsize_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start*/
uint32_t nbytes; /*size of stored data */
diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h
index e7ae3ae..1b5fed7 100644
--- a/src/H5Dpublic.h
+++ b/src/H5Dpublic.h
@@ -56,7 +56,8 @@ typedef enum H5D_layout_t {
/* Types of chunk index data structures */
typedef enum H5D_chunk_index_t {
- H5D_CHUNK_BTREE = 0 /* v1 B-tree index */
+ H5D_CHUNK_IDX_BTREE = 0, /* v1 B-tree index */
+ H5D_CHUNK_IDX_NTYPES /* this one must be last! */
} H5D_chunk_index_t;
/* Values for the space allocation time property */
diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c
index 3e9444b..6a83745 100644
--- a/src/H5Edeprec.c
+++ b/src/H5Edeprec.c
@@ -152,6 +152,7 @@ H5Eget_major(H5E_major_t maj)
char *ret_value; /* Return value */
FUNC_ENTER_API_NOCLEAR(NULL)
+ H5TRACE1("*s", "i", maj);
/* Get the message object */
if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(maj, H5I_ERROR_MSG)))
@@ -204,6 +205,7 @@ H5Eget_minor(H5E_minor_t min)
char *ret_value; /* Return value */
FUNC_ENTER_API_NOCLEAR(NULL)
+ H5TRACE1("*s", "i", min);
/* Get the message object */
if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(min, H5I_ERROR_MSG)))
diff --git a/src/H5FD.c b/src/H5FD.c
index bbadd33..fc6937e 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -886,6 +886,7 @@ H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
H5FD_t *ret_value=NULL;
FUNC_ENTER_API(NULL)
+ H5TRACE4("*x", "*sIuia", name, flags, fapl_id, maxaddr);
/* Check arguments */
if(H5P_DEFAULT == fapl_id)
diff --git a/src/H5I.c b/src/H5I.c
index ba1fef2..54b7ecc 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -883,6 +883,7 @@ H5Iobject_verify(hid_t id, H5I_type_t id_type)
void * ret_value; /* Return value */
FUNC_ENTER_API(NULL)
+ H5TRACE2("*x", "iIt", id, id_type);
if(H5I_IS_LIB_TYPE(id_type))
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type")
@@ -1023,6 +1024,7 @@ H5Iremove_verify(hid_t id, H5I_type_t id_type)
void * ret_value; /* Return value */
FUNC_ENTER_API(NULL)
+ H5TRACE2("*x", "iIt", id, id_type);
if(H5I_IS_LIB_TYPE(id_type))
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type")
@@ -1871,6 +1873,7 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key)
void *ret_value; /* Return value */
FUNC_ENTER_API(NULL)
+ H5TRACE3("*x", "Itx*x", type, func, key);
/* Check arguments */
if(H5I_IS_LIB_TYPE(type))
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 4c43873..816242f 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -147,7 +147,7 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
/* Set the chunk operations */
/* (Only "btree" indexing type currently supported in this version) */
- mesg->storage.u.chunk.idx_type = H5D_CHUNK_BTREE;
+ mesg->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE;
mesg->storage.u.chunk.ops = H5D_COPS_BTREE;
} /* end if */
else {
@@ -234,7 +234,7 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
/* Set the chunk operations */
/* (Only "btree" indexing type supported with v3 of message format) */
- mesg->storage.u.chunk.idx_type = H5D_CHUNK_BTREE;
+ mesg->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE;
mesg->storage.u.chunk.ops = H5D_COPS_BTREE;
/* Set the layout operations */
@@ -715,7 +715,7 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
/* Index information */
switch(mesg->storage.u.chunk.idx_type) {
- case H5D_CHUNK_BTREE:
+ case H5D_CHUNK_IDX_BTREE:
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Index Type:", "v1 B-tree");
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
diff --git a/src/H5P.c b/src/H5P.c
index 113203d..ff230ed 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -1596,6 +1596,7 @@ H5Pget_class_name(hid_t pclass_id)
char *ret_value; /* return value */
FUNC_ENTER_API(NULL)
+ H5TRACE1("*s", "i", pclass_id);
/* Check arguments. */
if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
diff --git a/src/H5PL.c b/src/H5PL.c
index 738db90..1806ea6 100644
--- a/src/H5PL.c
+++ b/src/H5PL.c
@@ -23,11 +23,11 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5PLprivate.h" /* Plugin */
-#include "H5Zprivate.h" /* Filter pipeline */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5PLprivate.h" /* Plugin */
+#include "H5Zprivate.h" /* Filter pipeline */
/****************/
@@ -40,7 +40,19 @@
/* Macros for supporting
* both Windows and Unix */
/****************************/
-/* Windows support */
+/* Windows support
+ *
+ * SPECIAL WINDOWS NOTE
+ *
+ * Some of the Win32 API functions expand to fooA or fooW depending on
+ * whether UNICODE or _UNICODE are defined. You MUST explicitly use
+ * the A version of the functions to force char * behavior until we
+ * work out a scheme for proper Windows Unicode support.
+ *
+ * If you do not do this, people will be unable to incorporate our
+ * source code into their own CMake builds if they define UNICODE.
+ */
+
#ifdef H5_HAVE_WIN32_API
#define H5PL_PATH_SEPARATOR ";"
@@ -49,7 +61,7 @@
#define H5PL_HANDLE HINSTANCE
/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */
-#define H5PL_OPEN_DLIB(S) LoadLibraryEx(TEXT(S), NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
+#define H5PL_OPEN_DLIB(S) LoadLibraryExA(S, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
/* Get the address of a symbol in dynamic library */
#define H5PL_GET_LIB_FUNC(H,N) GetProcAddress(H,N)
@@ -96,9 +108,9 @@ typedef const void *(*H5PL_get_plugin_info_t)(void);
/* Type for the list of info for opened plugin libraries */
typedef struct H5PL_table_t {
- H5PL_type_t pl_type; /* plugin type */
- int pl_id; /* ID for the plugin */
- H5PL_HANDLE handle; /* plugin handle */
+ H5PL_type_t pl_type; /* plugin type */
+ int pl_id; /* ID for the plugin */
+ H5PL_HANDLE handle; /* plugin handle */
} H5PL_table_t;
@@ -128,8 +140,8 @@ static herr_t H5PL__close(H5PL_HANDLE handle);
/*******************/
/* Table for opened plugin libraries */
-static size_t H5PL_table_alloc_g = 0;
-static size_t H5PL_table_used_g = 0;
+static size_t H5PL_table_alloc_g = 0;
+static size_t H5PL_table_used_g = 0;
static H5PL_table_t *H5PL_table_g = NULL;
/* Table of location paths for plugin libraries */
@@ -173,15 +185,15 @@ H5PL__init_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5PL_no_plugin
+ * Function: H5PL_no_plugin
*
- * Purpose: Quick way for filter module to query whether to load plugin
+ * Purpose: Quick way for filter module to query whether to load plugin
*
- * Return: TRUE: No plugin loading during data reading
+ * Return: TRUE: No plugin loading during data reading
*
- * FALSE: Load plugin during data reading
+ * FALSE: Load plugin during data reading
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 20 February 2013
*
*-------------------------------------------------------------------------
@@ -201,18 +213,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5PL_term_interface
+ * Function: H5PL_term_interface
*
- * Purpose: Terminate the H5PL interface: release all memory, reset all
- * global variables to initial values. This only happens if all
- * types have been destroyed from other interfaces.
+ * Purpose: Terminate the H5PL interface: release all memory, reset all
+ * global variables to initial values. This only happens if all
+ * types have been destroyed from other interfaces.
*
- * Return: Success: Positive if any action was taken that might
- * affect some other interface; zero otherwise.
+ * Return: Success: Positive if any action was taken that might
+ * affect some other interface; zero otherwise.
*
- * Failure: Negative.
+ * Failure: Negative.
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 20 February 2013
*
*-------------------------------------------------------------------------
@@ -227,13 +239,13 @@ H5PL_term_interface(void)
if(H5_interface_initialize_g) {
size_t u; /* Local index variable */
- /* Close opened dynamic libraries */
+ /* Close opened dynamic libraries */
for(u = 0; u < H5PL_table_used_g; u++)
H5PL__close((H5PL_table_g[u]).handle);
- /* Free the table of dynamic libraries */
- H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g);
- H5PL_table_used_g = H5PL_table_alloc_g = 0;
+ /* Free the table of dynamic libraries */
+ H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g);
+ H5PL_table_used_g = H5PL_table_alloc_g = 0;
/* Free the table of search paths */
for(u = 0; u < H5PL_num_paths_g; u++)
@@ -242,7 +254,7 @@ H5PL_term_interface(void)
H5PL_num_paths_g = 0;
H5PL_path_found_g = FALSE;
- H5_interface_initialize_g = 0;
+ H5_interface_initialize_g = 0;
i = 1;
} /* end if */
@@ -251,15 +263,15 @@ H5PL_term_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5PL_load
+ * Function: H5PL_load
*
- * Purpose: Given the plugin type and identifier, this function searches
+ * Purpose: Given the plugin type and identifier, this function searches
* and/or loads a dynamic plugin library first among the already
* opened libraries then in the designated location paths.
*
- * Return: Non-NULL on success/NULL on failure
+ * Return: Non-NULL on success/NULL on failure
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 13 February 2013
*
*-------------------------------------------------------------------------
@@ -314,13 +326,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5PL__init_path_table
+ * Function: H5PL__init_path_table
*
- * Purpose: Initialize the path table.
+ * Purpose: Initialize the path table.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* 18 March 2013
*
*-------------------------------------------------------------------------
@@ -369,18 +381,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5PL__find
+ * Function: H5PL__find
*
* Purpose: Given a path, this function opens the directory and envokes
* another function to go through all files to find the right
* plugin library. Two function definitions are for Unix and
* Windows.
*
- * Return: TRUE on success,
+ * Return: TRUE on success,
* FALSE on not found,
* negative on failure
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 13 February 2013
*
*-------------------------------------------------------------------------
@@ -457,17 +469,17 @@ done:
static htri_t
H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info)
{
- WIN32_FIND_DATA fdFile;
- HANDLE hFind;
- char *pathname = NULL;
- char service[2048];
- htri_t ret_value = FALSE;
+ WIN32_FIND_DATAA fdFile;
+ HANDLE hFind;
+ char *pathname = NULL;
+ char service[2048];
+ htri_t ret_value = FALSE;
FUNC_ENTER_STATIC
/* Specify a file mask. *.* = We want everything! */
sprintf(service, "%s\\*.dll", dir);
- if((hFind = FindFirstFile(service, &fdFile)) == INVALID_HANDLE_VALUE)
+ if((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE)
HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory")
do {
@@ -480,7 +492,7 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info)
/* Allocate & initialize the path name */
pathname_len = HDstrlen(dir) + HDstrlen(fdFile.cFileName) + 2;
- if(NULL == (pathname = (char *)H5MM_malloc(pathname_len)))
+ if(NULL == (pathname = (char *)H5MM_malloc(pathname_len)))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
HDsnprintf(pathname, pathname_len, "%s\\%s", dir, fdFile.cFileName);
@@ -495,10 +507,10 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info)
HGOTO_DONE(TRUE)
} /* end if */
else
- HDassert(pathname);
+ HDassert(pathname);
pathname = (char *)H5MM_xfree(pathname);
} /* end if */
- } while(FindNextFile(hFind, &fdFile)); /* Find the next file. */
+ } while(FindNextFileA(hFind, &fdFile)); /* Find the next file. */
done:
if(hFind)
@@ -512,17 +524,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5PL__open
+ * Function: H5PL__open
*
* Purpose: Iterates through all files to find the right plugin library.
* It loads the dynamic plugin library and keeps it on the list
- * of loaded libraries.
+ * of loaded libraries.
*
- * Return: TRUE on success,
+ * Return: TRUE on success,
* FALSE on not found,
* negative on failure
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 13 February 2013
*
*-------------------------------------------------------------------------
@@ -600,16 +612,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5PL__search_table
+ * Function: H5PL__search_table
*
* Purpose: Search in the list of already opened dynamic libraries
* to see if the one we are looking for is already opened.
*
- * Return: TRUE on success,
+ * Return: TRUE on success,
* FALSE on not found,
* Negative on failure
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 13 February 2013
*
*-------------------------------------------------------------------------
@@ -631,12 +643,12 @@ H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info)
const H5Z_class2_t *plugin_info;
if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_table_g[i]).handle, "H5PLget_plugin_info")))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info")
- if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)()))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info")
+ if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)()))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info")
- *info = plugin_info;
+ *info = plugin_info;
HGOTO_DONE(TRUE)
} /* end if */
} /* end for */
@@ -648,13 +660,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5PL__close
+ * Function: H5PL__close
*
* Purpose: Closes the handle for dynamic library
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 13 February 2013
*
*-------------------------------------------------------------------------
@@ -668,4 +680,3 @@ H5PL__close(H5PL_HANDLE handle)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5PL__close() */
-
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index a753209..949cefa 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -53,7 +53,7 @@
/* Define default layout information */
#define H5D_DEF_STORAGE_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL}
#define H5D_DEF_STORAGE_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0}
-#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_BTREE, HADDR_UNDEF, NULL, {{HADDR_UNDEF, NULL}}}
+#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, NULL, {{HADDR_UNDEF, NULL}}}
#define H5D_DEF_LAYOUT_CHUNK_INIT {(unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (uint32_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
#ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER
#define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }}
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 089bfb9..7a44e86 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -920,6 +920,7 @@ H5Pget_driver_info(hid_t plist_id)
void *ret_value; /* Return value */
FUNC_ENTER_API(NULL)
+ H5TRACE1("*x", "i", plist_id);
if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list")
diff --git a/src/H5Tfields.c b/src/H5Tfields.c
index 0e0d4e7..fb186fb 100644
--- a/src/H5Tfields.c
+++ b/src/H5Tfields.c
@@ -163,6 +163,7 @@ H5Tget_member_name(hid_t type_id, unsigned membno)
char *ret_value;
FUNC_ENTER_API(NULL)
+ H5TRACE2("*s", "iIu", type_id, membno);
/* Check args */
if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE)))
diff --git a/src/H5Topaque.c b/src/H5Topaque.c
index d68e659..e93bf65 100644
--- a/src/H5Topaque.c
+++ b/src/H5Topaque.c
@@ -121,6 +121,7 @@ H5Tget_tag(hid_t type_id)
char *ret_value;
FUNC_ENTER_API(NULL)
+ H5TRACE1("*s", "i", type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
diff --git a/src/H5VM.c b/src/H5VM.c
index 6f72c57..a1eafb6 100644
--- a/src/H5VM.c
+++ b/src/H5VM.c
@@ -1089,7 +1089,7 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset)
HDassert(offset);
/* Compute offset in array */
- for (i=(int)(n-1), ret_value=0; i>=0; --i)
+ for(i = (int)(n - 1), ret_value = 0; i >= 0; --i)
ret_value += acc[i] * offset[i];
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5private.h b/src/H5private.h
index f4a67a4..a532c79 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -217,7 +217,7 @@
#define MPE_LOG_VARS \
static int eventa(FUNC) = -1; \
static int eventb(FUNC) = -1; \
- char p_event_start[100];
+ char p_event_start[128];
/* Hardwire the color to "red", since that's what all the routines are using
* now. In the future, if we want to change that color for a given routine,
diff --git a/src/H5public.h b/src/H5public.h
index 51fd0ee..673aa6f 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -94,10 +94,10 @@ extern "C" {
/* Version numbers */
#define H5_VERS_MAJOR 1 /* For major interface/format changes */
#define H5_VERS_MINOR 9 /* For minor interface/format changes */
-#define H5_VERS_RELEASE 213 /* For tweaks, bug-fixes, or development */
+#define H5_VERS_RELEASE 215 /* For tweaks, bug-fixes, or development */
#define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */
/* Empty string for real releases. */
-#define H5_VERS_INFO "HDF5 library version: 1.9.213" /* Full version string */
+#define H5_VERS_INFO "HDF5 library version: 1.9.215" /* Full version string */
#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \
H5_VERS_RELEASE)