[svn-r12550] Description:

Refactor fractal heap IDs to include "flag byte" as part of the ID.  This
byte will be used for the heap ID format version as well as flags to indicate
whether the heap object is a "tiny"/normal/"huge" object (with storage
mechanisms optimized for each type of object).

Platforms tested:
    Linux/32 2.4 (chicago)
    Too minor to require h5committest
This commit is contained in:
Quincey Koziol 2006-08-07 13:18:17 -05:00
parent 9a03ce6406
commit 80b1c44327
5 changed files with 96 additions and 40 deletions

View File

@ -400,8 +400,10 @@ herr_t
H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p) H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p)
{ {
const uint8_t *id = (const uint8_t *)_id; /* Object ID */ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
uint8_t id_flags; /* Heap ID flag bits */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOFUNC(H5HF_get_obj_len) FUNC_ENTER_NOAPI(H5HF_get_obj_len, FAIL)
/* /*
* Check arguments. * Check arguments.
@ -410,13 +412,28 @@ H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p)
HDassert(id); HDassert(id);
HDassert(obj_len_p); HDassert(obj_len_p);
/* Skip over object offset */ /* Get the ID flags */
id += fh->hdr->heap_off_size; id_flags = *id++;
/* Retrieve the entry length */ /* Check for correct heap ID version */
UINT64DECODE_VAR(id, *obj_len_p, fh->hdr->heap_len_size); if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
FUNC_LEAVE_NOAPI(SUCCEED) /* Check for managed object */
if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
/* Skip over object offset */
id += fh->hdr->heap_off_size;
/* Retrieve the entry length */
UINT64DECODE_VAR(id, *obj_len_p, fh->hdr->heap_len_size);
} /* end if */
else {
HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_get_obj_len() */ } /* end H5HF_get_obj_len() */
@ -436,11 +453,9 @@ H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p)
herr_t herr_t
H5HF_read(H5HF_t *fh, hid_t dxpl_id, const void *_id, void *obj/*out*/) H5HF_read(H5HF_t *fh, hid_t dxpl_id, const void *_id, void *obj/*out*/)
{ {
H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
const uint8_t *id = (const uint8_t *)_id; /* Object ID */ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
hsize_t obj_off; /* Object's offset in heap */ uint8_t id_flags; /* Heap ID flag bits */
size_t obj_len; /* Object's length in heap */ herr_t ret_value = SUCCEED; /* Return value */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5HF_read, FAIL) FUNC_ENTER_NOAPI(H5HF_read, FAIL)
@ -451,23 +466,32 @@ H5HF_read(H5HF_t *fh, hid_t dxpl_id, const void *_id, void *obj/*out*/)
HDassert(id); HDassert(id);
HDassert(obj); HDassert(obj);
/* Get the fractal heap header */ /* Get the ID flags */
hdr = fh->hdr; id_flags = *id++;
/* Decode the object offset within the heap & it's length */ /* Check for correct heap ID version */
H5HF_ID_DECODE(id, hdr, obj_off, obj_len); if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Check for managed object */
if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
hsize_t obj_off; /* Object's offset in heap */
size_t obj_len; /* Object's length in heap */
/* Decode the object offset within the heap & it's length */
UINT64DECODE_VAR(id, obj_off, fh->hdr->heap_off_size);
UINT64DECODE_VAR(id, obj_len, fh->hdr->heap_len_size);
#ifdef QAK #ifdef QAK
HDfprintf(stderr, "%s: obj_off = %Hu, obj_len = %Zu\n", FUNC, obj_off, obj_len); HDfprintf(stderr, "%s: obj_off = %Hu, obj_len = %Zu\n", FUNC, obj_off, obj_len);
#endif /* QAK */ #endif /* QAK */
/* Check for standalone object */ /* Read object from managed heap blocks */
if(obj_off & 0) { if(H5HF_man_read(fh->hdr, dxpl_id, obj_off, obj_len, obj) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "standalone blocks not supported yet") HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read object from fractal heap")
} /* end if */ } /* end if */
else { else {
/* Read object from managed heap blocks */ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
if(H5HF_man_read(hdr, dxpl_id, obj_off, obj_len, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read object from fractal heap")
} /* end else */ } /* end else */
done: done:
@ -492,9 +516,8 @@ herr_t
H5HF_remove(H5HF_t *fh, hid_t dxpl_id, const void *_id) H5HF_remove(H5HF_t *fh, hid_t dxpl_id, const void *_id)
{ {
const uint8_t *id = (const uint8_t *)_id; /* Object ID */ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
hsize_t obj_off; /* Object's offset in heap */ uint8_t id_flags; /* Heap ID flag bits */
size_t obj_len; /* Object's length in heap */ herr_t ret_value = SUCCEED; /* Return value */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5HF_remove, FAIL) FUNC_ENTER_NOAPI(H5HF_remove, FAIL)
@ -505,27 +528,39 @@ H5HF_remove(H5HF_t *fh, hid_t dxpl_id, const void *_id)
HDassert(fh->hdr); HDassert(fh->hdr);
HDassert(id); HDassert(id);
/* Decode the object offset within the heap & it's length */ /* Get the ID flags */
id_flags = *id++;
/* Check for correct heap ID version */
if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Check for managed object */
if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
hsize_t obj_off; /* Object's offset in heap */
size_t obj_len; /* Object's length in heap */
/* Decode the object offset within the heap & it's length */
#ifdef QAK #ifdef QAK
HDfprintf(stderr, "%s: fh->hdr->heap_off_size = %u, fh->hdr->heap_len_size = %u\n", FUNC, (unsigned)fh->hdr->heap_off_size, (unsigned)fh->hdr->heap_len_size); HDfprintf(stderr, "%s: fh->hdr->heap_off_size = %u, fh->hdr->heap_len_size = %u\n", FUNC, (unsigned)fh->hdr->heap_off_size, (unsigned)fh->hdr->heap_len_size);
#endif /* QAK */ #endif /* QAK */
H5HF_ID_DECODE(id, fh->hdr, obj_off, obj_len); UINT64DECODE_VAR(id, obj_off, fh->hdr->heap_off_size);
UINT64DECODE_VAR(id, obj_len, fh->hdr->heap_len_size);
#ifdef QAK #ifdef QAK
HDfprintf(stderr, "%s: obj_off = %Hu, obj_len = %Zu\n", FUNC, obj_off, obj_len); HDfprintf(stderr, "%s: obj_off = %Hu, obj_len = %Zu\n", FUNC, obj_off, obj_len);
#endif /* QAK */ #endif /* QAK */
/* Sanity check parameters */ /* Sanity check parameters */
HDassert(obj_off); HDassert(obj_off);
HDassert(obj_len); HDassert(obj_len);
/* Check for standalone object */
if(obj_off & 0) {
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "standalone blocks not supported yet")
} /* end if */
else {
/* Remove object from managed heap blocks */ /* Remove object from managed heap blocks */
if(H5HF_man_remove(fh->hdr, dxpl_id, obj_off, obj_len) < 0) if(H5HF_man_remove(fh->hdr, dxpl_id, obj_off, obj_len) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from fractal heap") HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from fractal heap")
} /* end if */
else {
HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */ } /* end else */
done: done:

View File

@ -225,7 +225,7 @@ H5HF_hdr_finish_init(H5HF_hdr_t *hdr)
/* Set the size of heap IDs */ /* Set the size of heap IDs */
hdr->heap_len_size = MIN(hdr->man_dtable.max_dir_blk_off_size, hdr->heap_len_size = MIN(hdr->man_dtable.max_dir_blk_off_size,
((H5V_log2_gen((hsize_t)hdr->standalone_size) + 7) / 8)); ((H5V_log2_gen((hsize_t)hdr->standalone_size) + 7) / 8));
hdr->id_len = hdr->heap_off_size + hdr->heap_len_size; hdr->id_len = H5HF_ID_SIZE(hdr);
/* Set the free space in direct blocks */ /* Set the free space in direct blocks */
for(u = 0; u < hdr->man_dtable.max_root_rows; u++) { for(u = 0; u < hdr->man_dtable.max_root_rows; u++) {

View File

@ -385,7 +385,7 @@ HDfprintf(stderr, "%s: blk_off = %Zu\n", FUNC, blk_off);
#ifdef QAK #ifdef QAK
HDfprintf(stderr, "%s: dblock->block_off = %Hu\n", FUNC, dblock->block_off); HDfprintf(stderr, "%s: dblock->block_off = %Hu\n", FUNC, dblock->block_off);
#endif /* QAK */ #endif /* QAK */
H5HF_ID_ENCODE(id, hdr, (dblock->block_off + blk_off), obj_size); H5HF_MAN_ID_ENCODE(id, hdr, (dblock->block_off + blk_off), obj_size);
#ifdef QAK #ifdef QAK
HDfprintf(stderr, "%s: obj_off = %Hu, obj_len = %Zu\n", FUNC, (dblock->block_off + blk_off), obj_size); HDfprintf(stderr, "%s: obj_off = %Hu, obj_len = %Zu\n", FUNC, (dblock->block_off + blk_off), obj_size);
#endif /* QAK */ #endif /* QAK */

View File

@ -114,16 +114,37 @@
#define H5HF_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) #define H5HF_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8)
#define H5HF_SIZEOF_OFFSET_LEN(l) H5HF_SIZEOF_OFFSET_BITS(H5V_log2_of2((unsigned)(l))) #define H5HF_SIZEOF_OFFSET_LEN(l) H5HF_SIZEOF_OFFSET_BITS(H5V_log2_of2((unsigned)(l)))
/* Encode a heap ID */ /* Heap ID bit flags */
#define H5HF_ID_ENCODE(i, h, o, l) \ /* Heap ID version (2 bits: 6-7) */
#define H5HF_ID_VERS_CURR 0x00 /* Current version of ID format */
#define H5HF_ID_VERS_MASK 0xC0 /* Mask for getting the ID version from flags */
/* Heap ID type (2 bits: 4-5) */
#define H5HF_ID_TYPE_MAN 0x00 /* "Managed" object - stored in fractal heap blocks */
#define H5HF_ID_TYPE_HUGE 0x10 /* "Huge" object - stored in file directly */
#define H5HF_ID_TYPE_TINY 0x20 /* "Tiny" object - stored in heap ID directly */
#define H5HF_ID_TYPE_RESERVED 0x30 /* "?" object - reserved for future use */
#define H5HF_ID_TYPE_MASK 0x30 /* Mask for getting the ID type from flags */
/* Heap ID bits 0-3 reserved for future use */
/* Encode a "managed" heap ID */
#define H5HF_MAN_ID_ENCODE(i, h, o, l) \
*(uint8_t *)i++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; \
UINT64ENCODE_VAR((i), (o), (h)->heap_off_size); \ UINT64ENCODE_VAR((i), (o), (h)->heap_off_size); \
UINT64ENCODE_VAR((i), (l), (h)->heap_len_size) UINT64ENCODE_VAR((i), (l), (h)->heap_len_size)
/* Decode a heap ID */ /* Decode a "managed" heap ID */
#define H5HF_ID_DECODE(i, h, o, l) \ #define H5HF_MAN_ID_DECODE(i, h, f, o, l) \
f = *(uint8_t *)i++; \
UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \
UINT64DECODE_VAR((i), (l), (h)->heap_len_size) UINT64DECODE_VAR((i), (l), (h)->heap_len_size)
/* Size of ID for heap */
#define H5HF_ID_SIZE(h) ( \
1 /* ID flag byte */ \
+ (h)->heap_off_size /* Space for managed object offset */ \
+ (h)->heap_len_size /* Space for managed object length */ \
)
/* Free space section types for fractal heap */ /* Free space section types for fractal heap */
/* (values stored in free space data structures in file) */ /* (values stored in free space data structures in file) */
#define H5HF_FSPACE_SECT_SINGLE 0 /* Section is a range of actual bytes in a direct block */ #define H5HF_FSPACE_SECT_SINGLE 0 /* Section is a range of actual bytes in a direct block */

View File

@ -52,7 +52,7 @@
/* #define ALL_INSERT_TESTS */ /* #define ALL_INSERT_TESTS */
/* Heap metadata macros */ /* Heap metadata macros */
#define HEAP_ID_LEN 6 /* # of bytes to use for heap ID */ #define HEAP_ID_LEN 7 /* # of bytes to use for heap ID */
#define HEAP_MAX_ROOT_ROWS(fh) H5HF_get_max_root_rows(fh) /* Max. # of rows in root indirect block */ #define HEAP_MAX_ROOT_ROWS(fh) H5HF_get_max_root_rows(fh) /* Max. # of rows in root indirect block */
#define DTABLE_WIDTH(fh) H5HF_get_dtable_width_test(fh) /* Width of doubling table for heap */ #define DTABLE_WIDTH(fh) H5HF_get_dtable_width_test(fh) /* Width of doubling table for heap */
#define DTABLE_MAX_DROWS(fh) H5HF_get_dtable_max_drows_test(fh) /* Max. # of direct block rows in any indirect block */ #define DTABLE_MAX_DROWS(fh) H5HF_get_dtable_max_drows_test(fh) /* Max. # of direct block rows in any indirect block */