summaryrefslogtreecommitdiffstats
path: root/src/H5Gdense.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
commitd2b87ec47ebdb096c331c7b62a195b9cea2f33ae (patch)
treea066f01361afaf5df457cef612bb0bb9fd80fe18 /src/H5Gdense.c
parentee5a1e07350f0dcf3ef07d9443aa2f4c073392f4 (diff)
downloadhdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.zip
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.gz
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.bz2
[svn-r17896] Description:
Bring r17546:17895 from trunk to revise_chunks branch. Changes to fixed and extensible array dataset chunk indexing code to accommodate changes to private APIs in those interfaces. Also, other adjustments to source code and expected output in response to changes on the trunk. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5Gdense.c')
-rw-r--r--src/H5Gdense.c192
1 files changed, 132 insertions, 60 deletions
diff --git a/src/H5Gdense.c b/src/H5Gdense.c
index 322b31b..f935a74 100644
--- a/src/H5Gdense.c
+++ b/src/H5Gdense.c
@@ -267,12 +267,15 @@ typedef struct {
*-------------------------------------------------------------------------
*/
herr_t
-H5G_dense_create(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo)
+H5G_dense_create(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
+ const H5O_pline_t *pline)
{
H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */
- H5HF_t *fheap; /* Fractal heap handle */
+ H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */
+ H5HF_t *fheap = NULL; /* Fractal heap handle */
+ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for names */
+ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order */
size_t fheap_id_len; /* Fractal heap ID length */
- size_t bt2_rrec_size; /* v2 B-tree raw record size */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_dense_create, FAIL)
@@ -293,6 +296,8 @@ H5G_dense_create(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo)
fheap_cparam.managed.start_root_rows = H5G_FHEAP_MAN_START_ROOT_ROWS;
fheap_cparam.checksum_dblocks = H5G_FHEAP_CHECKSUM_DBLOCKS;
fheap_cparam.max_man_size = H5G_FHEAP_MAX_MAN_SIZE;
+ if(pline)
+ fheap_cparam.pline = *pline;
/* Create fractal heap for storing links */
if(NULL == (fheap = H5HF_create(f, dxpl_id, &fheap_cparam)))
@@ -300,7 +305,7 @@ H5G_dense_create(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo)
/* Retrieve the heap's address in the file */
if(H5HF_get_heap_addr(fheap, &(linfo->fheap_addr)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get fractal heap address")
#ifdef QAK
HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr);
#endif /* QAK */
@@ -313,18 +318,20 @@ HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr);
HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len);
#endif /* QAK */
- /* Close the fractal heap */
- if(H5HF_close(fheap, dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
-
/* Create the name index v2 B-tree */
- bt2_rrec_size = 4 + /* Name's hash value */
+ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam));
+ bt2_cparam.cls = H5G_BT2_NAME;
+ bt2_cparam.node_size = (size_t)H5G_NAME_BT2_NODE_SIZE;
+ bt2_cparam.rrec_size = 4 + /* Name's hash value */
fheap_id_len; /* Fractal heap ID */
- if(H5B2_create(f, dxpl_id, H5G_BT2_NAME,
- (size_t)H5G_NAME_BT2_NODE_SIZE, bt2_rrec_size,
- H5G_NAME_BT2_SPLIT_PERC, H5G_NAME_BT2_MERGE_PERC,
- &(linfo->name_bt2_addr)) < 0)
+ bt2_cparam.split_percent = H5G_NAME_BT2_SPLIT_PERC;
+ bt2_cparam.merge_percent = H5G_NAME_BT2_MERGE_PERC;
+ if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index")
+
+ /* Retrieve the v2 B-tree's address in the file */
+ if(H5B2_get_addr(bt2_name, &(linfo->name_bt2_addr)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for name index")
#ifdef QAK
HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr);
#endif /* QAK */
@@ -332,19 +339,33 @@ HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr)
/* Check if we should create a creation order index v2 B-tree */
if(linfo->index_corder) {
/* Create the creation order index v2 B-tree */
- bt2_rrec_size = 8 + /* Creation order value */
+ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam));
+ bt2_cparam.cls = H5G_BT2_CORDER;
+ bt2_cparam.node_size = (size_t)H5G_CORDER_BT2_NODE_SIZE;
+ bt2_cparam.rrec_size = 8 + /* Creation order value */
fheap_id_len; /* Fractal heap ID */
- if(H5B2_create(f, dxpl_id, H5G_BT2_CORDER,
- (size_t)H5G_CORDER_BT2_NODE_SIZE, bt2_rrec_size,
- H5G_CORDER_BT2_SPLIT_PERC, H5G_CORDER_BT2_MERGE_PERC,
- &(linfo->corder_bt2_addr)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index")
+ bt2_cparam.split_percent = H5G_CORDER_BT2_SPLIT_PERC;
+ bt2_cparam.merge_percent = H5G_CORDER_BT2_MERGE_PERC;
+ if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index")
+
+ /* Retrieve the v2 B-tree's address in the file */
+ if(H5B2_get_addr(bt2_corder, &(linfo->corder_bt2_addr)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for creation order index")
#ifdef QAK
HDfprintf(stderr, "%s: linfo->corder_bt2_addr = %a\n", FUNC, linfo->corder_bt2_addr);
#endif /* QAK */
} /* end if */
done:
+ /* Close the open objects */
+ if(fheap && H5HF_close(fheap, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2_name && H5B2_close(bt2_name, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index")
+ if(bt2_corder && H5B2_close(bt2_corder, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_create() */
@@ -368,6 +389,8 @@ H5G_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
{
H5G_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */
H5HF_t *fheap = NULL; /* Fractal heap handle */
+ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */
+ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */
size_t link_size; /* Size of serialized link in the heap */
H5WB_t *wb = NULL; /* Wrapped buffer for link data */
uint8_t link_buf[H5G_LINK_BUF_SIZE]; /* Buffer for serializing link */
@@ -414,6 +437,10 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst
if(H5HF_insert(fheap, dxpl_id, link_size, link_ptr, udata.id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into fractal heap")
+ /* Open the name index v2 B-tree */
+ if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index")
+
/* Create the callback information for v2 B-tree record insertion */
udata.common.f = f;
udata.common.dxpl_id = dxpl_id;
@@ -426,14 +453,18 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst
/* udata.id already set in H5HF_insert() call */
/* Insert link into 'name' tracking v2 B-tree */
- if(H5B2_insert(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, &udata) < 0)
+ if(H5B2_insert(bt2_name, dxpl_id, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree")
/* Check if we should create a creation order index v2 B-tree record */
if(linfo->index_corder) {
- /* Insert the record into the creation order index v2 B-tree */
+ /* Open the creation order index v2 B-tree */
HDassert(H5F_addr_defined(linfo->corder_bt2_addr));
- if(H5B2_insert(f, dxpl_id, H5G_BT2_CORDER, linfo->corder_bt2_addr, &udata) < 0)
+ if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo->corder_bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index")
+
+ /* Insert the record into the creation order index v2 B-tree */
+ if(H5B2_insert(bt2_corder, dxpl_id, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree")
} /* end if */
@@ -441,6 +472,10 @@ done:
/* Release resources */
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2_name && H5B2_close(bt2_name, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index")
+ if(bt2_corder && H5B2_close(bt2_corder, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index")
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer")
@@ -504,6 +539,7 @@ H5G_dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
{
H5G_bt2_ud_common_t udata; /* User data for v2 B-tree link lookup */
H5HF_t *fheap = NULL; /* Fractal heap handle */
+ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */
htri_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_dense_lookup, FAIL)
@@ -520,6 +556,10 @@ H5G_dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ /* Open the name index v2 B-tree */
+ if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index")
+
/* Construct the user data for v2 B-tree callback */
udata.f = f;
udata.dxpl_id = dxpl_id;
@@ -530,13 +570,15 @@ H5G_dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
udata.found_op_data = lnk;
/* Find & copy the named link in the 'name' index */
- if((ret_value = H5B2_find(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, &udata, NULL, NULL)) < 0)
+ if((ret_value = H5B2_find(bt2_name, dxpl_id, &udata, NULL, NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to locate link in name index")
done:
/* Release resources */
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2_name && H5B2_close(bt2_name, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_lookup() */
@@ -641,7 +683,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
{
H5HF_t *fheap = NULL; /* Fractal heap handle */
H5G_link_table_t ltable = {0, NULL}; /* Table of links */
- const H5B2_class_t *bt2_class = NULL; /* Class of v2 B-tree */
+ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */
herr_t ret_value = SUCCEED; /* Return value */
@@ -671,7 +713,6 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
* Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
- bt2_class = H5G_BT2_CORDER;
} /* end else */
/* If the order is native and there's no B-tree for indexing the links,
@@ -680,7 +721,6 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
*/
if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
HDassert(H5F_addr_defined(bt2_addr));
} /* end if */
@@ -692,6 +732,10 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ /* Open the index v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index")
+
/* Construct the user data for v2 B-tree callback */
udata.f = f;
udata.dxpl_id = dxpl_id;
@@ -699,7 +743,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
udata.lnk = lnk;
/* Find & copy the link in the appropriate index */
- if(H5B2_index(f, dxpl_id, bt2_class, bt2_addr, order, n, H5G_dense_lookup_by_idx_bt2_cb, &udata) < 0)
+ if(H5B2_index(bt2, dxpl_id, order, n, H5G_dense_lookup_by_idx_bt2_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to locate link in index")
} /* end if */
else { /* Otherwise, we need to build a table of the links and sort it */
@@ -720,6 +764,8 @@ done:
/* Release resources */
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index")
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table")
@@ -943,7 +989,7 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
{
H5HF_t *fheap = NULL; /* Fractal heap handle */
H5G_link_table_t ltable = {0, NULL}; /* Table of links */
- const H5B2_class_t *bt2_class = NULL; /* Class of v2 B-tree */
+ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */
herr_t ret_value; /* Return value */
@@ -973,7 +1019,6 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
* Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
- bt2_class = H5G_BT2_CORDER;
} /* end else */
/* If the order is native and there's no B-tree for indexing the links,
@@ -983,19 +1028,23 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
HDassert(H5F_addr_defined(linfo->name_bt2_addr));
bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
} /* end if */
/* Check on iteration order */
if(order == H5_ITER_NATIVE) {
H5G_bt2_ud_it_t udata; /* User data for iterator callback */
+ /* Sanity check */
HDassert(H5F_addr_defined(bt2_addr));
/* Open the fractal heap */
if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ /* Open the index v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index")
+
/* Construct the user data for v2 B-tree iterator callback */
udata.f = f;
udata.dxpl_id = dxpl_id;
@@ -1007,7 +1056,7 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
/* Iterate over the records in the v2 B-tree's "native" order */
/* (by hash of name) */
- if((ret_value = H5B2_iterate(f, dxpl_id, bt2_class, bt2_addr, H5G_dense_iterate_bt2_cb, &udata)) < 0)
+ if((ret_value = H5B2_iterate(bt2, dxpl_id, H5G_dense_iterate_bt2_cb, &udata)) < 0)
HERROR(H5E_SYM, H5E_BADITER, "link iteration failed");
/* Update the last link examined, if requested */
@@ -1028,6 +1077,8 @@ done:
/* Release resources */
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index")
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table")
@@ -1142,10 +1193,10 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name,
size_t size)
{
- H5HF_t *fheap = NULL; /* Fractal heap handle */
+ H5HF_t *fheap = NULL; /* Fractal heap handle */
H5G_link_table_t ltable = {0, NULL}; /* Table of links */
- const H5B2_class_t *bt2_class = NULL; /* Class of v2 B-tree */
- haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */
+ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
+ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */
ssize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_dense_get_name_by_idx, FAIL)
@@ -1173,7 +1224,6 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
* Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
- bt2_class = H5G_BT2_CORDER;
} /* end else */
/* If the order is native and there's no B-tree for indexing the links,
@@ -1182,7 +1232,6 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
*/
if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
HDassert(H5F_addr_defined(bt2_addr));
} /* end if */
@@ -1194,6 +1243,10 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ /* Open the index v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index")
+
/* Set up the user data for the v2 B-tree 'record remove' callback */
udata.f = f;
udata.dxpl_id = dxpl_id;
@@ -1202,7 +1255,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
udata.name_size = size;
/* Retrieve the name according to the v2 B-tree's index order */
- if(H5B2_index(f, dxpl_id, bt2_class, bt2_addr, order, n, H5G_dense_get_name_by_idx_bt2_cb, &udata) < 0)
+ if(H5B2_index(bt2, dxpl_id, order, n, H5G_dense_get_name_by_idx_bt2_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "can't locate object in v2 B-tree")
/* Set return value */
@@ -1232,6 +1285,8 @@ done:
/* Release resources */
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index")
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table")
@@ -1257,6 +1312,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata)
{
H5G_fh_ud_rm_t *udata = (H5G_fh_ud_rm_t *)_udata; /* User data for fractal heap 'op' callback */
H5O_link_t *lnk = NULL; /* Pointer to link created from heap object */
+ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_dense_remove_fh_cb)
@@ -1269,13 +1325,16 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata)
if(H5F_addr_defined(udata->corder_bt2_addr)) {
H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */
+ /* Open the creation order index v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(udata->f, udata->dxpl_id, udata->corder_bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index")
+
/* Set up the user data for the v2 B-tree 'record remove' callback */
HDassert(lnk->corder_valid);
bt2_udata.corder = lnk->corder;
/* Remove the record from the name index v2 B-tree */
- if(H5B2_remove(udata->f, udata->dxpl_id, H5G_BT2_CORDER, udata->corder_bt2_addr,
- &bt2_udata, NULL, NULL) < 0)
+ if(H5B2_remove(bt2, udata->dxpl_id, &bt2_udata, NULL, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from creation order index v2 B-tree")
} /* end if */
@@ -1290,7 +1349,9 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link")
done:
- /* Release the space allocated for the link */
+ /* Release resources */
+ if(bt2 && H5B2_close(bt2, udata->dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index")
if(lnk)
H5O_msg_free(H5O_LINK_ID, lnk);
@@ -1361,7 +1422,8 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
H5RS_str_t *grp_full_path_r, const char *name)
{
H5HF_t *fheap = NULL; /* Fractal heap handle */
- H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */
+ H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */
+ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_dense_remove, FAIL)
@@ -1377,6 +1439,10 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ /* Open the name index v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, linfo->name_bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index")
+
/* Set up the user data for the v2 B-tree 'record remove' callback */
udata.common.f = f;
udata.common.dxpl_id = dxpl_id;
@@ -1391,13 +1457,15 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
udata.replace_names = TRUE;
/* Remove the record from the name index v2 B-tree */
- if(H5B2_remove(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, &udata, H5G_dense_remove_bt2_cb, &udata) < 0)
+ if(H5B2_remove(bt2, dxpl_id, &udata, H5G_dense_remove_bt2_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from name index v2 B-tree")
done:
/* Release resources */
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_remove() */
@@ -1453,6 +1521,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata)
{
H5G_bt2_ud_rmbi_t *bt2_udata = (H5G_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */
H5G_fh_ud_rmbi_t fh_udata; /* User data for fractal heap 'op' callback */
+ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
const uint8_t *heap_id; /* Heap ID for link */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1488,22 +1557,15 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata)
/* Check for removing the link from the "other" index (creation order, when name used and vice versa) */
if(H5F_addr_defined(bt2_udata->other_bt2_addr)) {
H5G_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */
- const H5B2_class_t *other_bt2_class; /* Class of "other" v2 B-tree */
/* Determine the index being used */
if(bt2_udata->idx_type == H5_INDEX_NAME) {
- /* Set the class of the "other" index */
- other_bt2_class = H5G_BT2_CORDER;
-
/* Set up the user data for the v2 B-tree 'record remove' callback */
other_bt2_udata.corder = fh_udata.lnk->corder;
} /* end if */
else {
HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER);
- /* Set the class of the "other" index */
- other_bt2_class = H5G_BT2_NAME;
-
/* Set up the user data for the v2 B-tree 'record remove' callback */
other_bt2_udata.f = bt2_udata->f;
other_bt2_udata.dxpl_id = bt2_udata->dxpl_id;
@@ -1514,12 +1576,15 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata)
other_bt2_udata.found_op_data = NULL;
} /* end else */
+ /* Open the index v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for 'other' index")
+
/* Set the common information for the v2 B-tree remove operation */
/* Remove the record from the name index v2 B-tree */
- if(H5B2_remove(bt2_udata->f, bt2_udata->dxpl_id, other_bt2_class, bt2_udata->other_bt2_addr,
- &other_bt2_udata, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove link from creation order index v2 B-tree")
+ if(H5B2_remove(bt2, bt2_udata->dxpl_id, &other_bt2_udata, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove link from 'other' index v2 B-tree")
} /* end if */
/* Replace open objects' names */
@@ -1539,6 +1604,10 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata)
HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from fractal heap")
done:
+ /* Release resources */
+ if(bt2 && H5B2_close(bt2, bt2_udata->dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for 'other' index")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_remove_by_idx_bt2_cb() */
@@ -1564,7 +1633,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
{
H5HF_t *fheap = NULL; /* Fractal heap handle */
H5G_link_table_t ltable = {0, NULL}; /* Table of links */
- const H5B2_class_t *bt2_class = NULL; /* Class of v2 B-tree */
+ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1593,7 +1662,6 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
* Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
- bt2_class = H5G_BT2_CORDER;
} /* end else */
/* If the order is native and there's no B-tree for indexing the links,
@@ -1602,7 +1670,6 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
*/
if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
HDassert(H5F_addr_defined(bt2_addr));
} /* end if */
@@ -1614,6 +1681,10 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ /* Open the index v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index")
+
/* Set up the user data for the v2 B-tree 'remove by index' callback */
udata.f = f;
udata.dxpl_id = dxpl_id;
@@ -1623,8 +1694,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
udata.grp_full_path_r = grp_full_path_r;
/* Remove the record from the name index v2 B-tree */
- if(H5B2_remove_by_idx(f, dxpl_id, bt2_class, bt2_addr,
- order, n, H5G_dense_remove_by_idx_bt2_cb, &udata) < 0)
+ if(H5B2_remove_by_idx(bt2, dxpl_id, order, n, H5G_dense_remove_by_idx_bt2_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from indexed v2 B-tree")
} /* end if */
else { /* Otherwise, we need to build a table of the links and sort it */
@@ -1645,6 +1715,8 @@ done:
/* Release resources */
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
+ if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index")
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table")
@@ -1704,7 +1776,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link)
udata.replace_names = FALSE;
/* Delete the name index, adjusting the ref. count on links removed */
- if(H5B2_delete(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, H5G_dense_remove_bt2_cb, &udata) < 0)
+ if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, H5G_dense_remove_bt2_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index")
/* Close the fractal heap */
@@ -1713,7 +1785,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link)
} /* end if */
else {
/* Delete the name index, without adjusting the ref. count on the links */
- if(H5B2_delete(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, NULL, NULL) < 0)
+ if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index")
} /* end else */
linfo->name_bt2_addr = HADDR_UNDEF;
@@ -1722,7 +1794,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link)
if(linfo->index_corder) {
/* Delete the creation order index, without adjusting the ref. count on the links */
HDassert(H5F_addr_defined(linfo->corder_bt2_addr));
- if(H5B2_delete(f, dxpl_id, H5G_BT2_CORDER, linfo->corder_bt2_addr, NULL, NULL) < 0)
+ if(H5B2_delete(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index")
linfo->corder_bt2_addr = HADDR_UNDEF;
} /* end if */