mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
[svn-r11968] Purpose:
Incrementtal checkin Description: Revise & update v2 B-tree code to separate the internal package-specific routines from the library-callable "private" routines. Similar updates for the fractal heap code. Platforms tested: FreeBSD 4.11 (sleipnir) Mac OSX (amazon)
This commit is contained in:
parent
3713db1174
commit
658bf4a8fb
2
MANIFEST
2
MANIFEST
@ -406,6 +406,7 @@
|
||||
./src/H5B2.c
|
||||
./src/H5B2cache.c
|
||||
./src/H5B2dbg.c
|
||||
./src/H5B2int.c
|
||||
./src/H5B2pkg.h
|
||||
./src/H5B2private.h
|
||||
./src/H5B2public.h
|
||||
@ -495,6 +496,7 @@
|
||||
./src/H5HF.c
|
||||
./src/H5HFcache.c
|
||||
./src/H5HFdbg.c
|
||||
./src/H5HFint.c
|
||||
./src/H5HFpkg.h
|
||||
./src/H5HFprivate.h
|
||||
./src/H5HFpublic.h
|
||||
|
3321
src/H5B2.c
3321
src/H5B2.c
File diff suppressed because it is too large
Load Diff
150
src/H5B2cache.c
150
src/H5B2cache.c
@ -202,6 +202,7 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo
|
||||
H5F_DECODE_LENGTH(f, p, bt2->root.all_nrec);
|
||||
|
||||
/* Initialize shared B-tree info */
|
||||
HDassert((size_t)(p - buf) == size);
|
||||
if(H5B2_shared_init(f, bt2, type, node_size, rrec_size, split_percent, merge_percent) < 0)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't create shared B-tree info")
|
||||
|
||||
@ -291,7 +292,7 @@ H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B
|
||||
H5F_ENCODE_LENGTH(f, p, bt2->root.all_nrec);
|
||||
|
||||
/* Write the B-tree header. */
|
||||
HDassert((p - buf) == size);
|
||||
HDassert((size_t)(p - buf) == size);
|
||||
if(H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree header to disk")
|
||||
|
||||
@ -431,13 +432,13 @@ static H5B2_leaf_t *
|
||||
H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_bt2_shared)
|
||||
{
|
||||
const unsigned *nrec = (const unsigned *)_nrec;
|
||||
H5RC_t *bt2_shared=(H5RC_t *)_bt2_shared; /* Shared B-tree information */
|
||||
H5RC_t *bt2_shared = (H5RC_t *)_bt2_shared; /* Shared B-tree information */
|
||||
H5B2_shared_t *shared; /* Shared B-tree information */
|
||||
H5B2_leaf_t *leaf = NULL;
|
||||
H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */
|
||||
uint8_t *p; /* Pointer into raw data buffer */
|
||||
uint8_t *native; /* Pointer to native keys */
|
||||
unsigned u; /* Local index variable */
|
||||
H5B2_leaf_t *ret_value;
|
||||
H5B2_leaf_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5B2_cache_leaf_load, NULL)
|
||||
|
||||
@ -446,49 +447,51 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(bt2_shared);
|
||||
|
||||
if (NULL==(leaf = H5FL_MALLOC(H5B2_leaf_t)))
|
||||
if(NULL == (leaf = H5FL_MALLOC(H5B2_leaf_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
HDmemset(&leaf->cache_info,0,sizeof(H5AC_info_t));
|
||||
HDmemset(&leaf->cache_info, 0, sizeof(H5AC_info_t));
|
||||
|
||||
/* Share common B-tree information */
|
||||
leaf->shared = bt2_shared;
|
||||
H5RC_INC(leaf->shared);
|
||||
|
||||
/* Get the pointer to the shared B-tree info */
|
||||
shared=H5RC_GET_OBJ(leaf->shared);
|
||||
shared = H5RC_GET_OBJ(leaf->shared);
|
||||
HDassert(shared);
|
||||
|
||||
/* Read header from disk */
|
||||
if (H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page)<0)
|
||||
if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree leaf node")
|
||||
|
||||
p = shared->page;
|
||||
|
||||
/* magic number */
|
||||
if (HDmemcmp(p, H5B2_LEAF_MAGIC, H5B2_SIZEOF_MAGIC))
|
||||
/* Magic number */
|
||||
if(HDmemcmp(p, H5B2_LEAF_MAGIC, H5B2_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node signature")
|
||||
p += H5B2_SIZEOF_MAGIC;
|
||||
|
||||
/* version */
|
||||
if (*p++ != H5B2_LEAF_VERSION)
|
||||
/* Version */
|
||||
if(*p++ != H5B2_LEAF_VERSION)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node version")
|
||||
|
||||
/* XXX: Add metadata flags & checksum to v2 B-tree metadata (like fractal heap) */
|
||||
|
||||
/* B-tree type */
|
||||
if (*p++ != (uint8_t)shared->type->id)
|
||||
if(*p++ != (uint8_t)shared->type->id)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree type")
|
||||
|
||||
/* Allocate space for the native keys in memory */
|
||||
if((leaf->leaf_native=H5FL_FAC_MALLOC(shared->leaf_fac))==NULL)
|
||||
if((leaf->leaf_native = H5FL_FAC_MALLOC(shared->leaf_fac)) == NULL)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys")
|
||||
|
||||
/* Set the number of records in the leaf */
|
||||
leaf->nrec = *nrec;
|
||||
|
||||
/* Deserialize records for leaf node */
|
||||
native=leaf->leaf_native;
|
||||
for(u=0; u<leaf->nrec; u++) {
|
||||
native = leaf->leaf_native;
|
||||
for(u = 0; u < leaf->nrec; u++) {
|
||||
/* Decode record */
|
||||
if((shared->type->decode)(f,p,native)<0)
|
||||
if((shared->type->decode)(f, p, native) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record")
|
||||
|
||||
/* Move to next record */
|
||||
@ -496,11 +499,14 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
|
||||
native += shared->type->nrec_size;
|
||||
} /* end for */
|
||||
|
||||
/* Sanity check parsing */
|
||||
HDassert((size_t)(p - shared->page) <= shared->node_size);
|
||||
|
||||
/* Set return value */
|
||||
ret_value = leaf;
|
||||
|
||||
done:
|
||||
if (!ret_value && leaf)
|
||||
if(!ret_value && leaf)
|
||||
(void)H5B2_cache_leaf_dest(f,leaf);
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5B2_cache_leaf_load() */ /*lint !e818 Can't make udata a pointer to const */
|
||||
@ -531,14 +537,14 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(leaf);
|
||||
|
||||
if (leaf->cache_info.is_dirty) {
|
||||
if(leaf->cache_info.is_dirty) {
|
||||
H5B2_shared_t *shared; /* Shared B-tree information */
|
||||
uint8_t *p; /* Pointer into raw data buffer */
|
||||
uint8_t *native; /* Pointer to native keys */
|
||||
unsigned u; /* Local index variable */
|
||||
|
||||
/* Get the pointer to the shared B-tree info */
|
||||
shared=H5RC_GET_OBJ(leaf->shared);
|
||||
shared = H5RC_GET_OBJ(leaf->shared);
|
||||
HDassert(shared);
|
||||
|
||||
p = shared->page;
|
||||
@ -554,10 +560,10 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5
|
||||
*p++ = shared->type->id;
|
||||
|
||||
/* Serialize records for leaf node */
|
||||
native=leaf->leaf_native;
|
||||
for(u=0; u<leaf->nrec; u++) {
|
||||
native = leaf->leaf_native;
|
||||
for(u = 0; u < leaf->nrec; u++) {
|
||||
/* Encode record */
|
||||
if((shared->type->encode)(f,p,native)<0)
|
||||
if((shared->type->encode)(f, p, native) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
|
||||
|
||||
/* Move to next record */
|
||||
@ -566,14 +572,15 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5
|
||||
} /* end for */
|
||||
|
||||
/* Write the B-tree leaf node */
|
||||
if (H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
|
||||
HDassert((size_t)(p - shared->page) <= shared->node_size);
|
||||
if(H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree leaf node to disk")
|
||||
|
||||
leaf->cache_info.is_dirty = FALSE;
|
||||
} /* end if */
|
||||
|
||||
if (destroy)
|
||||
if (H5B2_cache_leaf_dest(f,leaf) < 0)
|
||||
if(destroy)
|
||||
if(H5B2_cache_leaf_dest(f, leaf) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node")
|
||||
|
||||
done:
|
||||
@ -608,7 +615,7 @@ H5B2_cache_leaf_dest(H5F_t UNUSED *f, H5B2_leaf_t *leaf)
|
||||
HDassert(leaf);
|
||||
|
||||
/* Get the pointer to the shared B-tree info */
|
||||
shared=H5RC_GET_OBJ(leaf->shared);
|
||||
shared = H5RC_GET_OBJ(leaf->shared);
|
||||
HDassert(shared);
|
||||
|
||||
/* Release leaf's native key buffer */
|
||||
@ -654,8 +661,8 @@ H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *leaf, hbool_t destroy)
|
||||
/* Reset the dirty flag. */
|
||||
leaf->cache_info.is_dirty = FALSE;
|
||||
|
||||
if (destroy)
|
||||
if (H5B2_cache_leaf_dest(f, leaf) < 0)
|
||||
if(destroy)
|
||||
if(H5B2_cache_leaf_dest(f, leaf) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node")
|
||||
|
||||
done:
|
||||
@ -690,7 +697,7 @@ H5B2_cache_leaf_size(const H5F_t UNUSED *f, const H5B2_leaf_t *leaf, size_t *siz
|
||||
HDassert(size_ptr);
|
||||
|
||||
/* Get the pointer to the shared B-tree info */
|
||||
shared=H5RC_GET_OBJ(leaf->shared);
|
||||
shared = H5RC_GET_OBJ(leaf->shared);
|
||||
HDassert(shared);
|
||||
|
||||
/* Set size value */
|
||||
@ -721,12 +728,12 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nre
|
||||
const unsigned *nrec = (const unsigned *)_nrec;
|
||||
H5RC_t *bt2_shared = (H5RC_t *)_bt2_shared; /* Ref counter for shared B-tree info */
|
||||
H5B2_shared_t *shared; /* Shared B-tree information */
|
||||
H5B2_internal_t *internal = NULL;
|
||||
H5B2_internal_t *internal = NULL; /* Internal node read */
|
||||
uint8_t *p; /* Pointer into raw data buffer */
|
||||
uint8_t *native; /* Pointer to native record info */
|
||||
H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */
|
||||
unsigned u; /* Local index variable */
|
||||
H5B2_internal_t *ret_value;
|
||||
H5B2_internal_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5B2_cache_internal_load, NULL)
|
||||
|
||||
@ -735,9 +742,9 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nre
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(bt2_shared);
|
||||
|
||||
if (NULL==(internal = H5FL_MALLOC(H5B2_internal_t)))
|
||||
if(NULL == (internal = H5FL_MALLOC(H5B2_internal_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
HDmemset(&internal->cache_info,0,sizeof(H5AC_info_t));
|
||||
HDmemset(&internal->cache_info, 0, sizeof(H5AC_info_t));
|
||||
|
||||
/* Share common B-tree information */
|
||||
internal->shared = bt2_shared;
|
||||
@ -748,40 +755,42 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nre
|
||||
HDassert(shared);
|
||||
|
||||
/* Read header from disk */
|
||||
if (H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page)<0)
|
||||
if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page)<0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree internal node")
|
||||
|
||||
p = shared->page;
|
||||
|
||||
/* magic number */
|
||||
if (HDmemcmp(p, H5B2_INT_MAGIC, H5B2_SIZEOF_MAGIC))
|
||||
/* Magic number */
|
||||
if(HDmemcmp(p, H5B2_INT_MAGIC, H5B2_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree internal node signature")
|
||||
p += H5B2_SIZEOF_MAGIC;
|
||||
|
||||
/* version */
|
||||
if (*p++ != H5B2_INT_VERSION)
|
||||
/* Version */
|
||||
if(*p++ != H5B2_INT_VERSION)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree internal node version")
|
||||
|
||||
/* XXX: Add metadata flags & checksum to v2 B-tree metadata (like fractal heap) */
|
||||
|
||||
/* B-tree type */
|
||||
if (*p++ != (uint8_t)shared->type->id)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree type")
|
||||
|
||||
/* Allocate space for the native keys in memory */
|
||||
if((internal->int_native=H5FL_FAC_MALLOC(shared->int_fac))==NULL)
|
||||
if((internal->int_native = H5FL_FAC_MALLOC(shared->int_fac)) == NULL)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal native keys")
|
||||
|
||||
/* Allocate space for the node pointers in memory */
|
||||
if((internal->node_ptrs=H5FL_FAC_MALLOC(shared->node_ptr_fac))==NULL)
|
||||
if((internal->node_ptrs = H5FL_FAC_MALLOC(shared->node_ptr_fac)) == NULL)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal node pointers")
|
||||
|
||||
/* Set the number of records in the leaf */
|
||||
internal->nrec = *nrec;
|
||||
|
||||
/* Deserialize records for internal node */
|
||||
native=internal->int_native;
|
||||
for(u=0; u<internal->nrec; u++) {
|
||||
native = internal->int_native;
|
||||
for(u = 0; u < internal->nrec; u++) {
|
||||
/* Decode record */
|
||||
if((shared->type->decode)(f,p,native)<0)
|
||||
if((shared->type->decode)(f, p, native) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record")
|
||||
|
||||
/* Move to next record */
|
||||
@ -790,8 +799,8 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nre
|
||||
} /* end for */
|
||||
|
||||
/* Deserialize node pointers for internal node */
|
||||
int_node_ptr=internal->node_ptrs;
|
||||
for(u=0; u<internal->nrec+1; u++) {
|
||||
int_node_ptr = internal->node_ptrs;
|
||||
for(u = 0; u < internal->nrec + 1; u++) {
|
||||
/* Decode node pointer */
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &(int_node_ptr->addr));
|
||||
UINT16DECODE(p, int_node_ptr->node_nrec);
|
||||
@ -801,12 +810,15 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nre
|
||||
int_node_ptr++;
|
||||
} /* end for */
|
||||
|
||||
/* Sanity check parsing */
|
||||
HDassert((size_t)(p - shared->page) <= shared->node_size);
|
||||
|
||||
/* Set return value */
|
||||
ret_value = internal;
|
||||
|
||||
done:
|
||||
if (!ret_value && internal)
|
||||
(void)H5B2_cache_internal_dest(f,internal);
|
||||
if(!ret_value && internal)
|
||||
(void)H5B2_cache_internal_dest(f, internal);
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5B2_cache_internal_load() */ /*lint !e818 Can't make udata a pointer to const */
|
||||
|
||||
@ -836,7 +848,7 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(internal);
|
||||
|
||||
if (internal->cache_info.is_dirty) {
|
||||
if(internal->cache_info.is_dirty) {
|
||||
H5B2_shared_t *shared; /* Shared B-tree information */
|
||||
uint8_t *p; /* Pointer into raw data buffer */
|
||||
uint8_t *native; /* Pointer to native record info */
|
||||
@ -844,26 +856,26 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr
|
||||
unsigned u; /* Local index variable */
|
||||
|
||||
/* Get the pointer to the shared B-tree info */
|
||||
shared=H5RC_GET_OBJ(internal->shared);
|
||||
shared = H5RC_GET_OBJ(internal->shared);
|
||||
HDassert(shared);
|
||||
|
||||
p = shared->page;
|
||||
|
||||
/* magic number */
|
||||
/* Magic number */
|
||||
HDmemcpy(p, H5B2_INT_MAGIC, H5B2_SIZEOF_MAGIC);
|
||||
p += H5B2_SIZEOF_MAGIC;
|
||||
|
||||
/* version # */
|
||||
/* Version # */
|
||||
*p++ = H5B2_INT_VERSION;
|
||||
|
||||
/* b-tree type */
|
||||
/* B-tree type */
|
||||
*p++ = shared->type->id;
|
||||
|
||||
/* Serialize records for internal node */
|
||||
native=internal->int_native;
|
||||
for(u=0; u<internal->nrec; u++) {
|
||||
native = internal->int_native;
|
||||
for(u = 0; u < internal->nrec; u++) {
|
||||
/* Encode record */
|
||||
if((shared->type->encode)(f,p,native)<0)
|
||||
if((shared->type->encode)(f, p, native) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
|
||||
|
||||
/* Move to next record */
|
||||
@ -872,8 +884,8 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr
|
||||
} /* end for */
|
||||
|
||||
/* Serialize node pointers for internal node */
|
||||
int_node_ptr=internal->node_ptrs;
|
||||
for(u=0; u<internal->nrec+1; u++) {
|
||||
int_node_ptr = internal->node_ptrs;
|
||||
for(u = 0; u < internal->nrec + 1; u++) {
|
||||
/* Encode node pointer */
|
||||
H5F_addr_encode(f, &p, int_node_ptr->addr);
|
||||
UINT16ENCODE(p, int_node_ptr->node_nrec);
|
||||
@ -884,14 +896,15 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr
|
||||
} /* end for */
|
||||
|
||||
/* Write the B-tree internal node */
|
||||
if (H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
|
||||
HDassert((size_t)(p - shared->page) <= shared->node_size);
|
||||
if(H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree internal node to disk")
|
||||
|
||||
internal->cache_info.is_dirty = FALSE;
|
||||
} /* end if */
|
||||
|
||||
if (destroy)
|
||||
if (H5B2_cache_internal_dest(f,internal) < 0)
|
||||
if(destroy)
|
||||
if(H5B2_cache_internal_dest(f, internal) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node")
|
||||
|
||||
done:
|
||||
@ -926,23 +939,23 @@ H5B2_cache_internal_dest(H5F_t UNUSED *f, H5B2_internal_t *internal)
|
||||
HDassert(internal);
|
||||
|
||||
/* Get the pointer to the shared B-tree info */
|
||||
shared=H5RC_GET_OBJ(internal->shared);
|
||||
shared = H5RC_GET_OBJ(internal->shared);
|
||||
HDassert(shared);
|
||||
|
||||
/* Release internal node's native key buffer */
|
||||
if(internal->int_native)
|
||||
H5FL_FAC_FREE(shared->int_fac,internal->int_native);
|
||||
H5FL_FAC_FREE(shared->int_fac, internal->int_native);
|
||||
|
||||
/* Release internal node's node pointer buffer */
|
||||
if(internal->node_ptrs)
|
||||
H5FL_FAC_FREE(shared->node_ptr_fac,internal->node_ptrs);
|
||||
H5FL_FAC_FREE(shared->node_ptr_fac, internal->node_ptrs);
|
||||
|
||||
/* Decrement reference count on shared B-tree info */
|
||||
if(internal->shared)
|
||||
H5RC_DEC(internal->shared);
|
||||
|
||||
/* Free B-tree internal node info */
|
||||
H5FL_FREE(H5B2_internal_t,internal);
|
||||
H5FL_FREE(H5B2_internal_t, internal);
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5B2_cache_internal_dest() */
|
||||
@ -976,8 +989,8 @@ H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *internal, hbool_t destroy)
|
||||
/* Reset the dirty flag. */
|
||||
internal->cache_info.is_dirty = FALSE;
|
||||
|
||||
if (destroy)
|
||||
if (H5B2_cache_internal_dest(f, internal) < 0)
|
||||
if(destroy)
|
||||
if(H5B2_cache_internal_dest(f, internal) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node")
|
||||
|
||||
done:
|
||||
@ -1012,7 +1025,7 @@ H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal,
|
||||
HDassert(size_ptr);
|
||||
|
||||
/* Get the pointer to the shared B-tree info */
|
||||
shared=H5RC_GET_OBJ(internal->shared);
|
||||
shared = H5RC_GET_OBJ(internal->shared);
|
||||
HDassert(shared);
|
||||
|
||||
/* Set size value */
|
||||
@ -1021,4 +1034,3 @@ H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal,
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* H5B2_cache_internal_size() */
|
||||
|
||||
|
||||
|
3357
src/H5B2int.c
Normal file
3357
src/H5B2int.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -184,6 +184,45 @@ H5_DLLVAR const H5B2_class_t H5B2_TEST[1];
|
||||
H5_DLL herr_t H5B2_shared_init(H5F_t *f, H5B2_t *bt2, const H5B2_class_t *type,
|
||||
size_t node_size, size_t rrec_size, unsigned split_percent, unsigned merge_percent);
|
||||
|
||||
/* Routines for allocating nodes */
|
||||
H5_DLL herr_t H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2,
|
||||
unsigned *bt2_flags_ptr, H5RC_t *bt2_shared);
|
||||
H5_DLL herr_t H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
H5B2_node_ptr_t *node_ptr);
|
||||
|
||||
/* Routines for inserting records */
|
||||
H5_DLL herr_t H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
unsigned depth, unsigned *parent_cache_info_flags_ptr,
|
||||
H5B2_node_ptr_t *curr_node_ptr, void *udata);
|
||||
H5_DLL herr_t H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
H5B2_node_ptr_t *curr_node_ptr, void *udata);
|
||||
|
||||
/* Routines for iterating over nodes/records */
|
||||
H5_DLL herr_t H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_operator_t op,
|
||||
void *op_data);
|
||||
|
||||
/* Routines for locating records */
|
||||
H5_DLL int H5B2_locate_record(const H5B2_class_t *type, unsigned nrec,
|
||||
size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx);
|
||||
H5_DLL herr_t H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
unsigned depth, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
|
||||
H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data);
|
||||
H5_DLL herr_t H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
|
||||
H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data);
|
||||
|
||||
/* Routines for removing records */
|
||||
H5_DLL herr_t H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
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);
|
||||
H5_DLL herr_t H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
H5B2_node_ptr_t *curr_node_ptr, void *udata);
|
||||
|
||||
/* Routines for deleting nodes */
|
||||
H5_DLL herr_t H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
|
||||
unsigned depth, const H5B2_node_ptr_t *curr_node);
|
||||
|
||||
/* Metadata cache callbacks */
|
||||
H5_DLL herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *b);
|
||||
H5_DLL herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *l);
|
||||
|
101
src/H5HF.c
101
src/H5HF.c
@ -56,7 +56,6 @@
|
||||
/* Local Prototypes */
|
||||
/********************/
|
||||
|
||||
static herr_t H5HF_shared_free(void *_shared);
|
||||
|
||||
/*********************/
|
||||
/* Package Variables */
|
||||
@ -75,82 +74,6 @@ H5FL_DEFINE(H5HF_t);
|
||||
/* Local Variables */
|
||||
/*******************/
|
||||
|
||||
/* Declare a free list to manage the H5HF_shared_t struct */
|
||||
H5FL_DEFINE_STATIC(H5HF_shared_t);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_shared_init
|
||||
*
|
||||
* Purpose: Allocate & initialize shared fractal heap info
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Feb 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_shared_init(H5F_t *f, H5HF_t *fh, H5HF_type_t type)
|
||||
{
|
||||
H5HF_shared_t *shared = NULL; /* Shared fractal heap information */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_shared_init)
|
||||
|
||||
/* Allocate space for the shared information */
|
||||
if(NULL == (shared = H5FL_CALLOC(H5HF_shared_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap shared information")
|
||||
|
||||
/* Set the type of heap address mapping */
|
||||
shared->type = type;
|
||||
|
||||
/* Make shared B-tree info reference counted */
|
||||
if(NULL == (fh->shared = H5RC_create(shared, H5HF_shared_free)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared fractal heap info")
|
||||
|
||||
done:
|
||||
if(ret_value < 0)
|
||||
if(shared)
|
||||
H5HF_shared_free(shared);
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_shared_init() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_shared_free
|
||||
*
|
||||
* Purpose: Free shared fractal heap info
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Feb 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_shared_free(void *_shared)
|
||||
{
|
||||
H5HF_shared_t *shared = (H5HF_shared_t *)_shared;
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_shared_free)
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(shared);
|
||||
|
||||
/* Free the shared info itself */
|
||||
H5FL_FREE(H5HF_shared_t, shared);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_shared_free() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -168,7 +91,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_type_t type, haddr_t *addr_p)
|
||||
H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam, haddr_t *addr_p)
|
||||
{
|
||||
H5HF_t *fh = NULL; /* The new fractal heap header information */
|
||||
herr_t ret_value = SUCCEED;
|
||||
@ -191,7 +114,7 @@ H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_type_t type, haddr_t *addr_p)
|
||||
HDmemset(&fh->cache_info, 0, sizeof(H5AC_info_t));
|
||||
|
||||
/* Initialize shared fractal heap info */
|
||||
if(H5HF_shared_init(f, fh, type) < 0)
|
||||
if(H5HF_shared_init(fh, cparam) < 0)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create shared fractal heap info")
|
||||
|
||||
/* Allocate space for the header on disk */
|
||||
@ -250,7 +173,7 @@ H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
|
||||
* Load the fractal heap header.
|
||||
*/
|
||||
if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
|
||||
|
||||
/* Get the pointer to the shared fractal heap info */
|
||||
shared = H5RC_GET_OBJ(fh->shared);
|
||||
@ -258,13 +181,29 @@ H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
|
||||
|
||||
/* Check if object is large enough to be standalone */
|
||||
if(size >= shared->standalone_size) {
|
||||
HDfprintf(stderr, "%s: size = %Zu\n", FUNC, size);
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "standalone blocks not supported yet")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Check if we are in "append only" mode, or if there's enough room for the object */
|
||||
if(shared->write_once) {
|
||||
HDfprintf(stderr, "%s: size = %Zu\n", FUNC, size);
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet")
|
||||
} /* end if */
|
||||
else if(size <= shared->total_man_free) {
|
||||
HDfprintf(stderr, "%s: size = %Zu\n", FUNC, size);
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "allocating internal managed blocks not supported yet")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Allocate space at end of heap */
|
||||
if(H5HF_man_alloc_end(shared, size, obj, id) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate space at end of managed blocks")
|
||||
} /* end else */
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, hdr_flags) < 0)
|
||||
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release fractal heap header")
|
||||
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_insert() */
|
||||
|
@ -107,7 +107,7 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud
|
||||
size_t size; /* Header size */
|
||||
uint8_t *buf = NULL; /* Temporary buffer */
|
||||
uint8_t *p; /* Pointer into raw data buffer */
|
||||
H5HF_type_t heap_type; /* Type of heap */
|
||||
H5HF_create_t cparam; /* Creation parameters for heap */
|
||||
uint32_t metadata_chksum; /* Metadata checksum value */
|
||||
H5HF_t *ret_value; /* Return value */
|
||||
|
||||
@ -155,14 +155,21 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud
|
||||
if(metadata_chksum != 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect metadata checksum for fractal heap header")
|
||||
|
||||
/* Fractal heap type */
|
||||
heap_type = *p++;
|
||||
/* Heap address mapping */
|
||||
cparam.addrmap = *p++;
|
||||
HDassert(H5HF_ABSOLUTE == 0);
|
||||
if(heap_type > H5HF_MAPPED)
|
||||
if(cparam.addrmap > H5HF_MAPPED)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect fractal heap type")
|
||||
|
||||
/* Min. size of standalone objects */
|
||||
UINT32DECODE(p, cparam.standalone_size);
|
||||
|
||||
/* Size of fixed-length objects in heap */
|
||||
UINT32DECODE(p, cparam.fixed_len_size);
|
||||
|
||||
/* Initialize shared fractal heap info */
|
||||
if(H5HF_shared_init(f, fh, heap_type) < 0)
|
||||
HDassert((size_t)(p - buf) == size);
|
||||
if(H5HF_shared_init(fh, &cparam) < 0)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't create shared fractal heap info")
|
||||
|
||||
/* Set return value */
|
||||
@ -238,8 +245,14 @@ H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5H
|
||||
HDmemset(p, 0, 4);
|
||||
p += 4;
|
||||
|
||||
/* Fractal heap type */
|
||||
*p++ = shared->type;
|
||||
/* Heap address mapping */
|
||||
*p++ = shared->addrmap;
|
||||
|
||||
/* Min. size of standalone objects */
|
||||
UINT32ENCODE(p, shared->standalone_size);
|
||||
|
||||
/* Size of fixed-length objects in heap */
|
||||
UINT32ENCODE(p, shared->fixed_len_size);
|
||||
|
||||
/* Write the B-tree header. */
|
||||
HDassert((size_t)(p - buf) == size);
|
||||
|
@ -115,10 +115,16 @@ H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
|
||||
* Print the values.
|
||||
*/
|
||||
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
|
||||
"Heap addressing method:",
|
||||
((shared->type) == H5HF_ABSOLUTE ? "Absolute" :
|
||||
((shared->type) == H5HF_MAPPED ? "Mapped" :
|
||||
"Heap address mapping method:",
|
||||
((shared->addrmap) == H5HF_ABSOLUTE ? "Absolute" :
|
||||
((shared->addrmap) == H5HF_MAPPED ? "Mapped" :
|
||||
"Unknown!")));
|
||||
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
|
||||
"Min. size of standalone object:",
|
||||
(unsigned long)shared->standalone_size);
|
||||
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
|
||||
"Fixed length object size:",
|
||||
(unsigned long)shared->fixed_len_size);
|
||||
|
||||
done:
|
||||
if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, H5AC__NO_FLAGS_SET) < 0)
|
||||
|
197
src/H5HFint.c
Normal file
197
src/H5HFint.c
Normal file
@ -0,0 +1,197 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by the Board of Trustees of the University of Illinois. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
||||
* of the source code distribution tree; Copyright.html can be found at the *
|
||||
* root level of an installed copy of the electronic HDF5 document set and *
|
||||
* is linked from the top-level documents page. It can also be found at *
|
||||
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
||||
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* Created: H5HFint.c
|
||||
* Feb 24 2006
|
||||
* Quincey Koziol <koziol@ncsa.uiuc.edu>
|
||||
*
|
||||
* Purpose: "Internal" routines for fractal heaps.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/****************/
|
||||
/* Module Setup */
|
||||
/****************/
|
||||
|
||||
#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
|
||||
|
||||
/***********/
|
||||
/* Headers */
|
||||
/***********/
|
||||
#include "H5private.h" /* Generic Functions */
|
||||
#include "H5HFpkg.h" /* Fractal heaps */
|
||||
#include "H5Eprivate.h" /* Error handling */
|
||||
#include "H5MFprivate.h" /* File memory management */
|
||||
|
||||
/****************/
|
||||
/* Local Macros */
|
||||
/****************/
|
||||
|
||||
|
||||
/******************/
|
||||
/* Local Typedefs */
|
||||
/******************/
|
||||
|
||||
|
||||
/********************/
|
||||
/* Local Prototypes */
|
||||
/********************/
|
||||
|
||||
static herr_t H5HF_shared_free(void *_shared);
|
||||
|
||||
/*********************/
|
||||
/* Package Variables */
|
||||
/*********************/
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Library Private Variables */
|
||||
/*****************************/
|
||||
|
||||
|
||||
/*******************/
|
||||
/* Local Variables */
|
||||
/*******************/
|
||||
|
||||
/* Declare a free list to manage the H5HF_shared_t struct */
|
||||
H5FL_DEFINE_STATIC(H5HF_shared_t);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_shared_init
|
||||
*
|
||||
* Purpose: Allocate & initialize shared fractal heap info
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Feb 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_shared_init(H5HF_t *fh, H5HF_create_t *cparam)
|
||||
{
|
||||
H5HF_shared_t *shared = NULL; /* Shared fractal heap information */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_shared_init)
|
||||
|
||||
/* Allocate space for the shared information */
|
||||
if(NULL == (shared = H5FL_CALLOC(H5HF_shared_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap shared information")
|
||||
|
||||
/* Set the creation parameters for the heap */
|
||||
shared->addrmap = cparam->addrmap;
|
||||
shared->standalone_size = cparam->standalone_size;
|
||||
shared->fixed_len_size = cparam->fixed_len_size;
|
||||
|
||||
/* Make shared B-tree info reference counted */
|
||||
if(NULL == (fh->shared = H5RC_create(shared, H5HF_shared_free)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared fractal heap info")
|
||||
|
||||
done:
|
||||
if(ret_value < 0)
|
||||
if(shared)
|
||||
H5HF_shared_free(shared);
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_shared_init() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_shared_free
|
||||
*
|
||||
* Purpose: Free shared fractal heap info
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Feb 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_shared_free(void *_shared)
|
||||
{
|
||||
H5HF_shared_t *shared = (H5HF_shared_t *)_shared;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_shared_free)
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(shared);
|
||||
|
||||
/* Free the shared info itself */
|
||||
H5FL_FREE(H5HF_shared_t, shared);
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_shared_free() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_alloc_end
|
||||
*
|
||||
* Purpose: Allocate space for an object at the end of the heap
|
||||
*
|
||||
* Return: Non-negative on success (with heap ID of new object
|
||||
* filled in), negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Feb 27 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_alloc_end(H5HF_shared_t *shared, size_t size, const void *obj,
|
||||
void *id/*out*/)
|
||||
{
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_alloc_end)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(shared);
|
||||
HDassert(size > 0);
|
||||
HDassert(obj);
|
||||
HDassert(id);
|
||||
|
||||
/* Check if this is the first object in the heap */
|
||||
if(shared->next_man_block == 0) {
|
||||
if(size /* + H5HF_DIRECT_OVERHEAD */ <= shared->man_dtable_info.start_block_size) {
|
||||
} /* end if */
|
||||
else {
|
||||
} /* end else */
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: size = %Zu\n", FUNC, size);
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "allocating first object not supported yet")
|
||||
#endif /* QAK */
|
||||
} /* end if */
|
||||
else {
|
||||
HDfprintf(stderr, "%s: size = %Zu\n", FUNC, size);
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "allocating objects at end of heap not supported yet")
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_alloc_end() */
|
||||
|
@ -54,7 +54,9 @@
|
||||
+ 4 /* Metadata checksum */ \
|
||||
\
|
||||
/* Fractal heap header specific fields */ \
|
||||
+ 1 /* Heap type */ \
|
||||
+ 1 /* Address mapping */ \
|
||||
+ 4 /* Min. size of standalone object */ \
|
||||
+ 4 /* Length of fixed-size objects */ \
|
||||
)
|
||||
|
||||
/****************************/
|
||||
@ -99,9 +101,9 @@ typedef struct H5HF_shared_t {
|
||||
H5HF_dtable_param_t std_dtable_info; /* Doubling-table info for standalone objects */
|
||||
|
||||
/* Information set by user */
|
||||
H5HF_type_t type; /* Type of address mapping */
|
||||
size_t standalone_size; /* Size of object to store standalone */
|
||||
size_t fixed_len_size; /* Size of objects (only for heaps w/fixed-length objects) */
|
||||
H5HF_addrmap_t addrmap; /* Type of address mapping */
|
||||
uint32_t standalone_size; /* Size of object to store standalone */
|
||||
uint32_t fixed_len_size; /* Size of objects (only for heaps w/fixed-length objects) */
|
||||
|
||||
/* Information derived from user parameters */
|
||||
hbool_t fixed_len_obj; /* Are objects in the heap fixed length? */
|
||||
@ -136,7 +138,11 @@ H5FL_EXTERN(H5HF_t);
|
||||
/******************************/
|
||||
|
||||
/* Routines for managing shared fractal heap info */
|
||||
H5_DLL herr_t H5HF_shared_init(H5F_t *f, H5HF_t *fh, H5HF_type_t type);
|
||||
H5_DLL herr_t H5HF_shared_init(H5HF_t *fh, H5HF_create_t *cparam);
|
||||
|
||||
/* Routines for allocating space */
|
||||
herr_t H5HF_man_alloc_end(H5HF_shared_t *shared, size_t size, const void *obj,
|
||||
void *id/*out*/);
|
||||
|
||||
/* Metadata cache callbacks */
|
||||
H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_t *b);
|
||||
@ -147,8 +153,8 @@ H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
|
||||
|
||||
/* Testing routines */
|
||||
#ifdef H5HF_TESTING
|
||||
H5_DLL herr_t H5HF_get_addrmap_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
|
||||
H5HF_type_t *heap_type);
|
||||
H5_DLL herr_t H5HF_get_cparam_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
|
||||
H5HF_create_t *cparam);
|
||||
#endif /* H5HF_TESTING */
|
||||
|
||||
#endif /* _H5HFpkg_H */
|
||||
|
@ -45,7 +45,16 @@
|
||||
typedef enum {
|
||||
H5HF_ABSOLUTE, /* The heap uses absolute internal addressing */
|
||||
H5HF_MAPPED /* The heap maps internal addresses to allow compaction */
|
||||
} H5HF_type_t;
|
||||
} H5HF_addrmap_t;
|
||||
|
||||
/* Fractal heap creation parameters */
|
||||
typedef struct H5HF_create_t {
|
||||
H5HF_addrmap_t addrmap; /* Type of address mapping for objects in heap */
|
||||
uint32_t standalone_size; /* Size of object to store standalone */
|
||||
/* (i.e. max. size of object to manage) */
|
||||
uint32_t fixed_len_size; /* Size of objects (0 means variable-sized objects) */
|
||||
/* (only for heaps w/fixed-length objects) */
|
||||
} H5HF_create_t;
|
||||
|
||||
|
||||
/*****************************/
|
||||
@ -55,7 +64,7 @@ typedef enum {
|
||||
/***************************************/
|
||||
/* Library-private Function Prototypes */
|
||||
/***************************************/
|
||||
H5_DLL herr_t H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_type_t type,
|
||||
H5_DLL herr_t H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam,
|
||||
haddr_t *addr_p);
|
||||
H5_DLL herr_t H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
|
||||
const void *obj, void *id/*out*/);
|
||||
|
@ -64,9 +64,9 @@
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_get_addrmap_test
|
||||
* Function: H5HF_get_cparam_test
|
||||
*
|
||||
* Purpose: Retrieve the address mapping type
|
||||
* Purpose: Retrieve the parameters used to create the fractal heap
|
||||
*
|
||||
* Return: Success: non-negative
|
||||
*
|
||||
@ -78,18 +78,18 @@
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_get_addrmap_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, H5HF_type_t *heap_type)
|
||||
H5HF_get_cparam_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, H5HF_create_t *cparam)
|
||||
{
|
||||
H5HF_t *fh = NULL; /* Pointer to the B-tree header */
|
||||
H5HF_shared_t *shared; /* Shared fractal heap information */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_get_addrmap_test)
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_get_cparam_test)
|
||||
|
||||
/* Check arguments. */
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(fh_addr));
|
||||
HDassert(heap_type);
|
||||
HDassert(cparam);
|
||||
|
||||
/* Look up the fractal heap header */
|
||||
if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_READ)))
|
||||
@ -99,8 +99,10 @@ H5HF_get_addrmap_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, H5HF_type_t *hea
|
||||
shared = H5RC_GET_OBJ(fh->shared);
|
||||
HDassert(shared);
|
||||
|
||||
/* Get fractal heap address mapping */
|
||||
*heap_type = shared->type;
|
||||
/* Get fractal heap creation parameters */
|
||||
cparam->addrmap = shared->addrmap;
|
||||
cparam->standalone_size = shared->standalone_size;
|
||||
cparam->fixed_len_size = shared->fixed_len_size;
|
||||
|
||||
done:
|
||||
/* Release fractal heap header node */
|
||||
@ -108,5 +110,5 @@ done:
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header info")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5HF_get_addrmap_test() */
|
||||
} /* H5HF_get_cparam_test() */
|
||||
|
||||
|
@ -37,9 +37,8 @@ libhdf5_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_
|
||||
MOSTLYCLEANFILES=H5Tinit.c
|
||||
|
||||
# library sources
|
||||
libhdf5_la_SOURCES= H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \
|
||||
H5B2dbg.c \
|
||||
H5B2test.c \
|
||||
libhdf5_la_SOURCES= H5.c H5A.c H5AC.c H5B.c H5Bcache.c \
|
||||
H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2test.c \
|
||||
H5C.c \
|
||||
H5D.c \
|
||||
H5Dcompact.c \
|
||||
@ -55,7 +54,7 @@ libhdf5_la_SOURCES= H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \
|
||||
H5Gstab.c \
|
||||
H5Gtest.c \
|
||||
H5Gtraverse.c \
|
||||
H5HF.c H5HFcache.c H5HFdbg.c H5HFtest.c \
|
||||
H5HF.c H5HFcache.c H5HFdbg.c H5HFint.c H5HFtest.c \
|
||||
H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c \
|
||||
H5MP.c H5MPtest.c \
|
||||
H5O.c \
|
||||
|
@ -83,7 +83,7 @@ libLTLIBRARIES_INSTALL = $(INSTALL)
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libhdf5_la_LIBADD =
|
||||
am_libhdf5_la_OBJECTS = H5.lo H5A.lo H5AC.lo H5B.lo H5Bcache.lo \
|
||||
H5B2.lo H5B2cache.lo H5B2dbg.lo H5B2test.lo H5C.lo H5D.lo \
|
||||
H5B2.lo H5B2cache.lo H5B2dbg.lo H5B2int.lo H5B2test.lo H5C.lo H5D.lo \
|
||||
H5Dcompact.lo H5Dcontig.lo H5Defl.lo H5Dio.lo H5Distore.lo \
|
||||
H5Dmpio.lo H5Doh.lo H5Dselect.lo H5Dtest.lo H5E.lo H5F.lo \
|
||||
H5Fdbg.lo H5Fmount.lo H5Fsfile.lo H5Fsuper.lo H5FD.lo \
|
||||
@ -93,7 +93,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5A.lo H5AC.lo H5B.lo H5Bcache.lo \
|
||||
H5FPclient.lo H5FPserver.lo H5FS.lo H5G.lo H5Gent.lo \
|
||||
H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo \
|
||||
H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFcache.lo \
|
||||
H5HFdbg.lo H5HFtest.lo H5HG.lo H5HGdbg.lo H5HL.lo H5HLdbg.lo \
|
||||
H5HFdbg.lo H5HFint.lo H5HFtest.lo H5HG.lo H5HGdbg.lo H5HL.lo H5HLdbg.lo \
|
||||
H5HP.lo H5I.lo H5MF.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo \
|
||||
H5Oattr.lo H5Obogus.lo H5Ocache.lo H5Ocont.lo H5Odtype.lo \
|
||||
H5Oefl.lo H5Ofill.lo H5Oginfo.lo H5Olayout.lo H5Olinfo.lo \
|
||||
@ -389,9 +389,8 @@ libhdf5_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT
|
||||
MOSTLYCLEANFILES = H5Tinit.c
|
||||
|
||||
# library sources
|
||||
libhdf5_la_SOURCES = H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \
|
||||
H5B2dbg.c \
|
||||
H5B2test.c \
|
||||
libhdf5_la_SOURCES = H5.c H5A.c H5AC.c H5B.c H5Bcache.c \
|
||||
H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2test.c \
|
||||
H5C.c \
|
||||
H5D.c \
|
||||
H5Dcompact.c \
|
||||
@ -407,7 +406,7 @@ libhdf5_la_SOURCES = H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \
|
||||
H5Gstab.c \
|
||||
H5Gtest.c \
|
||||
H5Gtraverse.c \
|
||||
H5HF.c H5HFcache.c H5HFdbg.c H5HFtest.c \
|
||||
H5HF.c H5HFcache.c H5HFdbg.c H5HFint.c H5HFtest.c \
|
||||
H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c \
|
||||
H5MP.c H5MPtest.c \
|
||||
H5O.c \
|
||||
@ -567,6 +566,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2cache.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2dbg.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2int.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2test.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Bcache.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5C.Plo@am__quote@
|
||||
@ -618,6 +618,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HF.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFcache.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFdbg.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFint.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFtest.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HG.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HGdbg.Plo@am__quote@
|
||||
|
32
test/fheap.c
32
test/fheap.c
@ -54,7 +54,7 @@ test_create(hid_t fapl)
|
||||
hid_t file = -1; /* File ID */
|
||||
char filename[1024]; /* Filename to use */
|
||||
H5F_t *f = NULL; /* Internal file object pointer */
|
||||
H5HF_type_t heap_type, test_heap_type; /* Type of address mapping for fractal heap */
|
||||
H5HF_create_t cparam, test_cparam; /* Creation parameters for heap */
|
||||
haddr_t fh_addr; /* Address of fractal heap created */
|
||||
|
||||
/* Set the filename to use for this test (dependent on fapl) */
|
||||
@ -72,8 +72,10 @@ test_create(hid_t fapl)
|
||||
* Test fractal heap creation (w/absolute address mapping)
|
||||
*/
|
||||
TESTING("Fractal heap creation (w/absolute address mapping)");
|
||||
heap_type = H5HF_ABSOLUTE;
|
||||
if(H5HF_create(f, H5P_DATASET_XFER_DEFAULT, heap_type, &fh_addr/*out*/) < 0)
|
||||
cparam.addrmap = H5HF_ABSOLUTE;
|
||||
cparam.standalone_size = 64 * 1024;
|
||||
cparam.fixed_len_size = 0;
|
||||
if(H5HF_create(f, H5P_DATASET_XFER_DEFAULT, &cparam, &fh_addr/*out*/) < 0)
|
||||
FAIL_STACK_ERROR
|
||||
if(!H5F_addr_defined(fh_addr))
|
||||
FAIL_STACK_ERROR
|
||||
@ -81,10 +83,10 @@ test_create(hid_t fapl)
|
||||
|
||||
/* Query the type of address mapping */
|
||||
TESTING("Query absolute address mapping setting");
|
||||
test_heap_type = H5HF_MAPPED;
|
||||
if(H5HF_get_addrmap_test(f, H5P_DATASET_XFER_DEFAULT, fh_addr, &test_heap_type) < 0)
|
||||
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
|
||||
if(H5HF_get_cparam_test(f, H5P_DATASET_XFER_DEFAULT, fh_addr, &test_cparam) < 0)
|
||||
FAIL_STACK_ERROR
|
||||
if(test_heap_type != heap_type)
|
||||
if(HDmemcmp(&cparam, &test_cparam, sizeof(H5HF_create_t)))
|
||||
FAIL_STACK_ERROR
|
||||
PASSED()
|
||||
|
||||
@ -92,8 +94,10 @@ test_create(hid_t fapl)
|
||||
* Test fractal heap creation (w/mapped address mapping)
|
||||
*/
|
||||
TESTING("Fractal heap creation (w/mapped address mapping)");
|
||||
heap_type = H5HF_MAPPED;
|
||||
if(H5HF_create(f, H5P_DATASET_XFER_DEFAULT, heap_type, &fh_addr/*out*/) < 0)
|
||||
cparam.addrmap = H5HF_MAPPED;
|
||||
cparam.standalone_size = 64 * 1024;
|
||||
cparam.fixed_len_size = 0;
|
||||
if(H5HF_create(f, H5P_DATASET_XFER_DEFAULT, &cparam, &fh_addr/*out*/) < 0)
|
||||
FAIL_STACK_ERROR
|
||||
if(!H5F_addr_defined(fh_addr))
|
||||
FAIL_STACK_ERROR
|
||||
@ -101,10 +105,10 @@ test_create(hid_t fapl)
|
||||
|
||||
/* Query the type of address mapping */
|
||||
TESTING("Query mapped address mapping setting");
|
||||
test_heap_type = H5HF_ABSOLUTE;
|
||||
if(H5HF_get_addrmap_test(f, H5P_DATASET_XFER_DEFAULT, fh_addr, &test_heap_type) < 0)
|
||||
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
|
||||
if(H5HF_get_cparam_test(f, H5P_DATASET_XFER_DEFAULT, fh_addr, &test_cparam) < 0)
|
||||
FAIL_STACK_ERROR
|
||||
if(test_heap_type != heap_type)
|
||||
if(HDmemcmp(&cparam, &test_cparam, sizeof(H5HF_create_t)))
|
||||
FAIL_STACK_ERROR
|
||||
PASSED()
|
||||
|
||||
@ -144,6 +148,7 @@ test_abs_insert_first(hid_t fapl)
|
||||
hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
|
||||
char filename[1024]; /* Filename to use */
|
||||
H5F_t *f = NULL; /* Internal file object pointer */
|
||||
H5HF_create_t cparam; /* Creation parameters for heap */
|
||||
haddr_t fh_addr; /* Address of fractal heap created */
|
||||
unsigned char obj[10]; /* Buffer for object to insert */
|
||||
haddr_t heap_id; /* Heap ID for object inserted */
|
||||
@ -162,7 +167,10 @@ test_abs_insert_first(hid_t fapl)
|
||||
STACK_ERROR
|
||||
|
||||
/* Create absolute heap */
|
||||
if(H5HF_create(f, dxpl, H5HF_ABSOLUTE, &fh_addr/*out*/) < 0)
|
||||
cparam.addrmap = H5HF_ABSOLUTE;
|
||||
cparam.standalone_size = 64 * 1024;
|
||||
cparam.fixed_len_size = 0;
|
||||
if(H5HF_create(f, dxpl, &cparam, &fh_addr/*out*/) < 0)
|
||||
FAIL_STACK_ERROR
|
||||
if(!H5F_addr_defined(fh_addr))
|
||||
FAIL_STACK_ERROR
|
||||
|
Loading…
Reference in New Issue
Block a user