diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-03-18 21:33:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-03-18 21:33:48 (GMT) |
commit | a53790e16a5e7109a52e8b4a611954f52890a804 (patch) | |
tree | 7ebe9b191aeef1815621089914996f6259b8ada2 /src/H5HF.c | |
parent | cac506d3fb8b2f0edc8b52d684849b8da9801840 (diff) | |
download | hdf5-a53790e16a5e7109a52e8b4a611954f52890a804.zip hdf5-a53790e16a5e7109a52e8b4a611954f52890a804.tar.gz hdf5-a53790e16a5e7109a52e8b4a611954f52890a804.tar.bz2 |
[svn-r12122] Purpose:
Code update
Description:
Add basics of routine for reading information back out of a fractal heap.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'src/H5HF.c')
-rw-r--r-- | src/H5HF.c | 71 |
1 files changed, 69 insertions, 2 deletions
@@ -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() */ + |