summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5HF.c71
-rw-r--r--src/H5HFcache.c2
-rw-r--r--src/H5HFint.c92
-rw-r--r--src/H5HFpkg.h2
-rw-r--r--src/H5HFprivate.h2
5 files changed, 164 insertions, 5 deletions
diff --git a/src/H5HF.c b/src/H5HF.c
index d5649d8..ac5990b 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -159,7 +159,7 @@ herr_t
H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
const void *obj, void *id/*out*/)
{
- H5HF_t *fh = NULL; /* The new fractal heap header information */
+ H5HF_t *fh = NULL; /* The fractal heap header information */
H5HF_shared_t *shared; /* Shared fractal heap information */
unsigned hdr_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for header */
herr_t ret_value = SUCCEED;
@@ -198,7 +198,7 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "standalone blocks not supported ye
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet")
} /* end if */
else {
- H5HF_section_free_node_t *sec_node;
+ H5HF_section_free_node_t *sec_node; /* Pointer to free space section */
/* Find free space in heap */
if(H5HF_man_find(fh->shared, dxpl_id, size, &sec_node) < 0)
@@ -221,3 +221,70 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_insert() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_read
+ *
+ * Purpose: Read an object from a fractal heap into a buffer
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Mar 18 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_id,
+ void *obj/*out*/)
+{
+ H5HF_t *fh = NULL; /* The fractal heap header information */
+ H5HF_shared_t *shared; /* Shared fractal heap information */
+ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
+ hsize_t obj_off; /* Object's offset in heap */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5HF_read, FAIL)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(id);
+ HDassert(obj);
+
+ /*
+ * Load the fractal heap header.
+ */
+ if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_READ)))
+ 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);
+ HDassert(shared);
+
+ /* Decode the offset within the heap */
+ UINT64DECODE_VAR(id, obj_off, shared->heap_off_size);
+#ifdef QAK
+HDfprintf(stderr, "%s: obj_off = %Hu\n", FUNC, obj_off);
+#endif /* QAK */
+
+ /* Check for standalone object */
+ if(obj_off & 0) {
+HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "standalone blocks not supported yet")
+ } /* end if */
+ else {
+ /* Read object from managed heap blocks */
+ if(H5HF_man_read(fh->shared, dxpl_id, obj_off, obj) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't read object from fractal heap")
+ } /* end else */
+
+done:
+ if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_read() */
+
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index 2b34604..fbeecc8 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -1064,7 +1064,7 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
iblock->next_dir_size = shared->man_dtable.cparam.start_block_size;
else
iblock->next_dir_size = shared->man_dtable.cparam.start_block_size * (1 << (iblock->next_dir_row - 1));
- if(heap_addr == 0)
+ if(iblock->block_off == 0)
iblock->max_direct_rows = shared->man_dtable.max_direct_rows;
else
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, NULL, "computing max direct rows for non-root indirect block not supported yet")
diff --git a/src/H5HFint.c b/src/H5HFint.c
index 4464bb1..bbae6a2 100644
--- a/src/H5HFint.c
+++ b/src/H5HFint.c
@@ -1272,6 +1272,92 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5HF_man_read
+ *
+ * Purpose: Read an object from a managed heap
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Mar 17 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_man_read(H5RC_t *fh_shared, hid_t dxpl_id, hsize_t obj_off, void *obj)
+{
+ H5HF_shared_t *shared; /* Pointer to shared heap info */
+ unsigned row, col; /* Row & column for object's block */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_man_read)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(fh_shared);
+ HDassert(obj_off > 0);
+ HDassert(obj);
+
+ /* Get the pointer to the shared heap info */
+ shared = H5RC_GET_OBJ(fh_shared);
+ HDassert(shared);
+
+ /* Check for root direct block */
+ if(shared->man_dtable.curr_root_rows == 0) {
+ H5HF_parent_shared_t par_shared; /* Parent shared information */
+ H5HF_direct_t *dblock; /* Pointer to direct block to query */
+ size_t blk_off; /* Offset of object in block */
+ uint8_t *p; /* Temporary pointer to obj info in block */
+ size_t obj_size; /* Size of object */
+
+#ifdef QAK
+ /* Look up row & column for object */
+ if(H5HF_dtable_lookup(&shared->man_dtable, obj_off, &row, &col) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of object")
+HDfprintf(stderr, "%s: row = %u, col = %u\n", FUNC, row, col);
+#endif /* QAK */
+
+ /* Lock first (root) direct block */
+ par_shared.shared = fh_shared;
+ par_shared.parent = NULL;
+ par_shared.parent_entry = 0;
+ par_shared.parent_free_space = shared->total_man_free;
+ if(NULL == (dblock = H5AC_protect(shared->f, dxpl_id, H5AC_FHEAP_DBLOCK, shared->man_dtable.table_addr, &shared->man_dtable.cparam.start_block_size, &par_shared, H5AC_READ)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap direct block")
+
+ /* Compute offset of object within block */
+ HDassert((obj_off - dblock->block_off) < (hsize_t)shared->man_dtable.cparam.start_block_size);
+ blk_off = (size_t)(obj_off - dblock->block_off);
+
+ /* Point to location for object */
+ p = dblock->blk + blk_off;
+
+ /* Decode the length */
+ UINT64DECODE_VAR(p, obj_size, dblock->blk_off_size);
+
+ /* Skip over the free fragment size & ref count */
+ p += 1 + (shared->ref_count_obj ? shared->ref_count_size : 0);
+
+ /* Copy the object's data into the heap */
+ HDmemcpy(obj, p, obj_size);
+
+ /* Unlock first (root) direct block */
+ if(H5AC_unprotect(shared->f, dxpl_id, H5AC_FHEAP_DBLOCK, shared->man_dtable.table_addr, dblock, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap direct block")
+ dblock = NULL;
+ } /* end if */
+ else {
+HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "root indirect blocks not supported yet")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_man_read() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_iblock_free
*
* Purpose: Free fractal heap indirect block
@@ -1465,6 +1551,7 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, NULL, "skipping direct block sizes not su
/* Check if we need a direct block past current allocation */
if(iblock->next_dir_row == iblock->ndir_rows) {
haddr_t old_addr; /* Old address of indirect block */
+ haddr_t new_addr; /* New address of indirect block */
unsigned new_nrows; /* New # of direct rows */
size_t u; /* Local index variable */
@@ -1499,7 +1586,7 @@ HDfprintf(stderr, "%s: new_nrows = %u\n", FUNC, new_nrows);
iblock->size = H5HF_MAN_INDIRECT_SIZE(shared, iblock);
/* Allocate space for the new indirect block on disk */
- if(HADDR_UNDEF == (shared->man_dtable.table_addr = H5MF_alloc(shared->f, H5FD_MEM_FHEAP_IBLOCK, dxpl_id, (hsize_t)iblock->size)))
+ if(HADDR_UNDEF == (new_addr = H5MF_alloc(shared->f, H5FD_MEM_FHEAP_IBLOCK, dxpl_id, (hsize_t)iblock->size)))
HGOTO_ERROR(H5E_STORAGE, H5E_NOSPACE, NULL, "file allocation failed for fractal heap indirect block")
/* Re-allocate direct block entry table */
@@ -1522,11 +1609,12 @@ HDfprintf(stderr, "%s: new_nrows = %u\n", FUNC, new_nrows);
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap indirect block")
/* Move object in cache */
- if(H5AC_rename(shared->f, H5AC_FHEAP_IBLOCK, old_addr, shared->man_dtable.table_addr) < 0)
+ if(H5AC_rename(shared->f, H5AC_FHEAP_IBLOCK, old_addr, new_addr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTSPLIT, NULL, "unable to move fractal heap root indirect block")
/* Update other shared header info */
shared->man_dtable.curr_root_rows = new_nrows;
+ shared->man_dtable.table_addr = new_addr;
/* Mark heap header as modified */
shared->dirty = TRUE;
diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h
index 7ccf879..33a9d37 100644
--- a/src/H5HFpkg.h
+++ b/src/H5HFpkg.h
@@ -373,6 +373,8 @@ H5_DLL herr_t H5HF_man_find(H5RC_t *fh_shared, hid_t dxpl_id, size_t request,
H5_DLL herr_t H5HF_man_insert(H5RC_t *fh_shared, hid_t dxpl_id,
H5HF_section_free_node_t *sec_node, size_t obj_size, const void *obj,
void *id);
+H5_DLL herr_t H5HF_man_read(H5RC_t *fh_shared, hid_t dxpl_id, hsize_t obj_off,
+ void *obj);
/* Metadata cache callbacks */
H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_t *fh);
diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h
index b5abe9e..4454ee7 100644
--- a/src/H5HFprivate.h
+++ b/src/H5HFprivate.h
@@ -81,6 +81,8 @@ 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*/);
+H5_DLL herr_t H5HF_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *id,
+ void *obj/*out*/);
#endif /* _H5HFprivate_H */