summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5EA.c22
-rw-r--r--src/H5EAcache.c50
-rw-r--r--src/H5EAdbg.c28
-rw-r--r--src/H5EAdblock.c12
-rw-r--r--src/H5EAhdr.c26
-rw-r--r--src/H5EAiblock.c16
-rw-r--r--src/H5EApkg.h13
-rw-r--r--src/H5EAtest.c10
-rw-r--r--test/earray.c655
9 files changed, 215 insertions, 617 deletions
diff --git a/src/H5EA.c b/src/H5EA.c
index d12a0c6..8db42c4 100644
--- a/src/H5EA.c
+++ b/src/H5EA.c
@@ -355,7 +355,7 @@ HDfprintf(stderr, "%s: Index block address not defined!\n", FUNC, idx);
H5E_THROW(H5E_CANTCREATE, "unable to create index block")
/* Increment count of elements "realized" */
- hdr->stats.nelmts += hdr->idx_blk_elmts;
+ hdr->stats.nelmts += hdr->cparam.idx_blk_elmts;
/* Mark the header dirty */
hdr_dirty = TRUE;
@@ -369,9 +369,9 @@ HDfprintf(stderr, "%s: Index block address is: %a\n", FUNC, hdr->idx_blk_addr);
H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", (unsigned long_long)hdr->idx_blk_addr)
/* Check if element is in index block */
- if(idx < hdr->idx_blk_elmts) {
+ if(idx < hdr->cparam.idx_blk_elmts) {
/* Set element in index block */
- HDmemcpy(((uint8_t *)iblock->elmts) + (hdr->cls->nat_elmt_size * idx), elmt, hdr->cls->nat_elmt_size);
+ HDmemcpy(((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size);
iblock_cache_flags |= H5AC__DIRTIED_FLAG;
} /* end if */
else {
@@ -382,7 +382,7 @@ HDfprintf(stderr, "%s: Index block address is: %a\n", FUNC, hdr->idx_blk_addr);
sblk_idx = H5EA__dblock_sblk_idx(hdr, idx);
/* Adjust index to offset in super block */
- elmt_idx = idx - hdr->idx_blk_elmts + hdr->sblk_info[sblk_idx].start_idx;
+ elmt_idx = idx - hdr->cparam.idx_blk_elmts + hdr->sblk_info[sblk_idx].start_idx;
#ifdef QAK
HDfprintf(stderr, "%s: after adjusting for super block elements, elmt_idx = %Hu\n", FUNC, elmt_idx);
#endif /* QAK */
@@ -428,7 +428,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u\n", FUNC, dblk_idx);
elmt_idx %= hdr->sblk_info[sblk_idx].dblk_nelmts;
/* Set element in data block */
- HDmemcpy(((uint8_t *)dblock->elmts) + (hdr->cls->nat_elmt_size * elmt_idx), elmt, hdr->cls->nat_elmt_size);
+ HDmemcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size);
dblock_cache_flags |= H5AC__DIRTIED_FLAG;
} /* end if */
else {
@@ -503,7 +503,7 @@ HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx);
HDfprintf(stderr, "%s: Element beyond max. index set, hdr->stats.max_idx_set = %Hu, idx = %Hu\n", FUNC, hdr->stats.max_idx_set, idx);
#endif /* QAK */
/* Call the class's 'fill' callback */
- if((hdr->cls->fill)(elmt, (size_t)1) < 0)
+ if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0)
H5E_THROW(H5E_CANTSET, "can't set element to class's fill value")
} /* end if */
else {
@@ -516,9 +516,9 @@ HDfprintf(stderr, "%s: Index block address is: %a\n", FUNC, hdr->idx_blk_addr);
H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", (unsigned long_long)hdr->idx_blk_addr)
/* Check if element is in index block */
- if(idx < hdr->idx_blk_elmts) {
+ if(idx < hdr->cparam.idx_blk_elmts) {
/* Get element from index block */
- HDmemcpy(elmt, ((uint8_t *)iblock->elmts) + (hdr->cls->nat_elmt_size * idx), hdr->cls->nat_elmt_size);
+ HDmemcpy(elmt, ((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), hdr->cparam.cls->nat_elmt_size);
} /* end if */
else {
unsigned sblk_idx; /* Which superblock does this index fall in? */
@@ -528,7 +528,7 @@ HDfprintf(stderr, "%s: Index block address is: %a\n", FUNC, hdr->idx_blk_addr);
sblk_idx = H5EA__dblock_sblk_idx(hdr, idx);
/* Adjust index to offset in super block */
- elmt_idx = idx - hdr->idx_blk_elmts + hdr->sblk_info[sblk_idx].start_idx;
+ elmt_idx = idx - hdr->cparam.idx_blk_elmts + hdr->sblk_info[sblk_idx].start_idx;
#ifdef QAK
HDfprintf(stderr, "%s: after adjusting for super block elements, elmt_idx = %Hu\n", FUNC, elmt_idx);
#endif /* QAK */
@@ -550,7 +550,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u\n", FUNC, dblk_idx);
/* Check if the data block has been allocated on disk yet */
if(!H5F_addr_defined(iblock->dblk_addrs[dblk_idx])) {
/* Call the class's 'fill' callback */
- if((hdr->cls->fill)(elmt, (size_t)1) < 0)
+ if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0)
H5E_THROW(H5E_CANTSET, "can't set element to class's fill value")
} /* end if */
else {
@@ -562,7 +562,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u\n", FUNC, dblk_idx);
elmt_idx %= hdr->sblk_info[sblk_idx].dblk_nelmts;
/* Retrieve element from data block */
- HDmemcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cls->nat_elmt_size * elmt_idx), hdr->cls->nat_elmt_size);
+ HDmemcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), hdr->cparam.cls->nat_elmt_size);
} /* end else */
} /* end if */
else {
diff --git a/src/H5EAcache.c b/src/H5EAcache.c
index 35f6275..d484653 100644
--- a/src/H5EAcache.c
+++ b/src/H5EAcache.c
@@ -213,11 +213,11 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls,
H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
/* General array creation/configuration information */
- hdr->raw_elmt_size = *p++; /* Element size in file (in bytes) */
- hdr->max_nelmts_bits = *p++; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
- hdr->idx_blk_elmts = *p++; /* # of elements to store in index block */
- hdr->data_blk_min_elmts = *p++; /* Min. # of elements per data block */
- hdr->sup_blk_min_data_ptrs = *p++; /* Min. # of data block pointers for a super block */
+ hdr->cparam.raw_elmt_size = *p++; /* Element size in file (in bytes) */
+ hdr->cparam.max_nelmts_bits = *p++; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
+ hdr->cparam.idx_blk_elmts = *p++; /* # of elements to store in index block */
+ hdr->cparam.data_blk_min_elmts = *p++; /* Min. # of elements per data block */
+ hdr->cparam.sup_blk_min_data_ptrs = *p++; /* Min. # of data block pointers for a super block */
/* Internal information */
H5F_addr_decode(f, &p, &hdr->idx_blk_addr); /* Address of index block */
@@ -318,14 +318,14 @@ H5EA__cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
*p++ = H5EA_HDR_VERSION;
/* Extensible array type */
- *p++ = hdr->cls->id;
+ *p++ = hdr->cparam.cls->id;
/* General array creation/configuration information */
- *p++ = hdr->raw_elmt_size; /* Element size in file (in bytes) */
- *p++ = hdr->max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
- *p++ = hdr->idx_blk_elmts; /* # of elements to store in index block */
- *p++ = hdr->data_blk_min_elmts; /* Min. # of elements per data block */
- *p++ = hdr->sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */
+ *p++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */
+ *p++ = hdr->cparam.max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
+ *p++ = hdr->cparam.idx_blk_elmts; /* # of elements to store in index block */
+ *p++ = hdr->cparam.data_blk_min_elmts; /* Min. # of elements per data block */
+ *p++ = hdr->cparam.sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */
/* Internal information */
H5F_addr_encode(f, &p, hdr->idx_blk_addr); /* Address of index block */
@@ -525,17 +525,17 @@ H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
H5E_THROW(H5E_VERSION, "wrong extensible array index block version")
/* Extensible array type */
- if(*p++ != (uint8_t)hdr->cls->id)
+ if(*p++ != (uint8_t)hdr->cparam.cls->id)
H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
/* Internal information */
/* Decode elements in index block */
- if(hdr->idx_blk_elmts > 0) {
+ if(hdr->cparam.idx_blk_elmts > 0) {
/* Convert from raw elements on disk into native elements in memory */
- if((hdr->cls->decode)(p, iblock->elmts, (size_t)hdr->idx_blk_elmts) < 0)
+ if((hdr->cparam.cls->decode)(p, iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts) < 0)
H5E_THROW(H5E_CANTDECODE, "can't decode extensible array index elements")
- p += (hdr->idx_blk_elmts * hdr->raw_elmt_size);
+ p += (hdr->cparam.idx_blk_elmts * hdr->cparam.raw_elmt_size);
} /* end if */
/* Decode data block addresses in index block */
@@ -647,16 +647,16 @@ H5EA__cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
*p++ = H5EA_IBLOCK_VERSION;
/* Extensible array type */
- *p++ = iblock->hdr->cls->id;
+ *p++ = iblock->hdr->cparam.cls->id;
/* Internal information */
/* Encode elements in index block */
- if(iblock->hdr->idx_blk_elmts > 0) {
+ if(iblock->hdr->cparam.idx_blk_elmts > 0) {
/* Convert from native elements in memory into raw elements on disk */
- if((iblock->hdr->cls->encode)(p, iblock->elmts, (size_t)iblock->hdr->idx_blk_elmts) < 0)
+ if((iblock->hdr->cparam.cls->encode)(p, iblock->elmts, (size_t)iblock->hdr->cparam.idx_blk_elmts) < 0)
H5E_THROW(H5E_CANTENCODE, "can't encode extensible array index elements")
- p += (iblock->hdr->idx_blk_elmts * iblock->hdr->raw_elmt_size);
+ p += (iblock->hdr->cparam.idx_blk_elmts * iblock->hdr->cparam.raw_elmt_size);
} /* end if */
/* Encode data block addresses in index block */
@@ -869,16 +869,16 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
H5E_THROW(H5E_VERSION, "wrong extensible array data block version")
/* Extensible array type */
- if(*p++ != (uint8_t)hdr->cls->id)
+ if(*p++ != (uint8_t)hdr->cparam.cls->id)
H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
/* Internal information */
/* Decode elements in data block */
/* Convert from raw elements on disk into native elements in memory */
- if((hdr->cls->decode)(p, dblock->elmts, *nelmts) < 0)
+ if((hdr->cparam.cls->decode)(p, dblock->elmts, *nelmts) < 0)
H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements")
- p += (*nelmts * hdr->raw_elmt_size);
+ p += (*nelmts * hdr->cparam.raw_elmt_size);
/* Sanity check */
/* (allow for checksum not decoded yet) */
@@ -971,16 +971,16 @@ H5EA__cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
*p++ = H5EA_DBLOCK_VERSION;
/* Extensible array type */
- *p++ = dblock->hdr->cls->id;
+ *p++ = dblock->hdr->cparam.cls->id;
/* Internal information */
/* Encode elements in data block */
/* Convert from native elements in memory into raw elements on disk */
- if((dblock->hdr->cls->encode)(p, dblock->elmts, dblock->nelmts) < 0)
+ if((dblock->hdr->cparam.cls->encode)(p, dblock->elmts, dblock->nelmts) < 0)
H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements")
- p += (dblock->nelmts * dblock->hdr->raw_elmt_size);
+ p += (dblock->nelmts * dblock->hdr->cparam.raw_elmt_size);
/* Compute metadata checksum */
metadata_chksum = H5_checksum_metadata(buf, (size_t)(p - buf), 0);
diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c
index 26c1070..9fb30c7 100644
--- a/src/H5EAdbg.c
+++ b/src/H5EAdbg.c
@@ -119,26 +119,26 @@ H5EA__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,
"Array class ID:",
- (hdr->cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
+ (hdr->cparam.cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
"Unknown!"));
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Header size:",
hdr->size);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"Raw Element Size:",
- (unsigned)hdr->raw_elmt_size);
+ (unsigned)hdr->cparam.raw_elmt_size);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Native Element Size (on this platform):",
- hdr->cls->nat_elmt_size);
+ hdr->cparam.cls->nat_elmt_size);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"# of elements in index block:",
- (unsigned)hdr->idx_blk_elmts);
+ (unsigned)hdr->cparam.idx_blk_elmts);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"Min. # of elements per data block:",
- (unsigned)hdr->data_blk_min_elmts);
+ (unsigned)hdr->cparam.data_blk_min_elmts);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"Min. # of data block pointers for a super block:",
- (unsigned)hdr->sup_blk_min_data_ptrs);
+ (unsigned)hdr->cparam.sup_blk_min_data_ptrs);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
"Highest element index stored (+1):",
hdr->stats.max_idx_set);
@@ -210,7 +210,7 @@ H5EA__iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Array class ID:",
- (hdr->cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
+ (hdr->cparam.cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
"Unknown!"));
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Index Block size:",
@@ -223,16 +223,16 @@ H5EA__iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
iblock->nsblk_addrs);
/* Check if there are any elements in index block */
- if(hdr->idx_blk_elmts > 0) {
+ if(hdr->cparam.idx_blk_elmts > 0) {
unsigned u; /* Local index variable */
/* Print the elements in the index block */
HDfprintf(stream, "%*sElements in Index Block:\n", indent, "");
- for(u = 0; u < hdr->idx_blk_elmts; u++) {
+ for(u = 0; u < hdr->cparam.idx_blk_elmts; u++) {
/* Call the class's 'debug' callback */
- if((hdr->cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)),
+ if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)),
(hsize_t)u,
- ((uint8_t *)iblock->elmts) + (hdr->cls->nat_elmt_size * u)) < 0)
+ ((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0)
H5E_THROW(H5E_CANTGET, "can't get element for debugging")
} /* end for */
} /* end if */
@@ -325,7 +325,7 @@ H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Array class ID:",
- (hdr->cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
+ (hdr->cparam.cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
"Unknown!"));
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Data Block size:",
@@ -336,9 +336,9 @@ H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
HDfprintf(stream, "%*sElements:\n", indent, "");
for(u = 0; u < dblk_nelmts; u++) {
/* Call the class's 'debug' callback */
- if((hdr->cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)),
+ if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)),
(hsize_t)u,
- ((uint8_t *)dblock->elmts) + (hdr->cls->nat_elmt_size * u)) < 0)
+ ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0)
H5E_THROW(H5E_CANTGET, "can't get element for debugging")
} /* end for */
diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c
index e99fb3d..15a38c5 100644
--- a/src/H5EAdblock.c
+++ b/src/H5EAdblock.c
@@ -176,11 +176,11 @@ HDfprintf(stderr, "%s: dblock->size = %Zu\n", FUNC, dblock->size);
#endif /* QAK */
/* Allocate space for the data block on disk */
- if(HADDR_UNDEF == (dblock->addr = H5MF_alloc(iblock->hdr->f, H5FD_MEM_EARRAY_DBLOCK, dxpl_id, dblock->size)))
+ if(HADDR_UNDEF == (dblock->addr = H5MF_alloc(iblock->hdr->f, H5FD_MEM_EARRAY_DBLOCK, dxpl_id, (hsize_t)dblock->size)))
H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block")
/* Clear any elements in index block to fill value */
- if((iblock->hdr->cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0)
+ if((iblock->hdr->cparam.cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0)
H5E_THROW(H5E_CANTSET, "can't set extensible array data block elements to class's fill value")
/* Cache the new extensible array data block */
@@ -228,13 +228,13 @@ H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx))
/* Sanity check */
HDassert(hdr);
- HDassert(idx >= hdr->idx_blk_elmts);
+ HDassert(idx >= hdr->cparam.idx_blk_elmts);
#ifdef QAK
HDfprintf(stderr, "%s: Entering - idx = %Hu\n", FUNC, idx);
#endif /* QAK */
/* Adjust index for elements in index block */
- idx -= hdr->idx_blk_elmts;
+ idx -= hdr->cparam.idx_blk_elmts;
#ifdef QAK
HDfprintf(stderr, "%s: after adjusting for index block elements, idx = %Hu\n", FUNC, idx);
#endif /* QAK */
@@ -242,9 +242,9 @@ HDfprintf(stderr, "%s: after adjusting for index block elements, idx = %Hu\n", F
/* Determine the superblock information for the index */
H5_CHECK_OVERFLOW(idx, /*From:*/hsize_t, /*To:*/uint64_t);
#ifdef QAK
-HDfprintf(stderr, "%s: hdr->data_blk_min_elmts = %u\n", FUNC, (unsigned)hdr->data_blk_min_elmts);
+HDfprintf(stderr, "%s: hdr->cparam.data_blk_min_elmts = %u\n", FUNC, (unsigned)hdr->cparam.data_blk_min_elmts);
#endif /* QAK */
- sblk_idx = H5V_log2_gen((uint64_t)((idx / hdr->data_blk_min_elmts) + 1));
+ sblk_idx = H5V_log2_gen((uint64_t)((idx / hdr->cparam.data_blk_min_elmts) + 1));
#ifdef QAK
HDfprintf(stderr, "%s: sblk_idx = %u\n", FUNC, sblk_idx);
HDfprintf(stderr, "%s: hdr->sblk_info[%u] = {%Hu, %Zu, %Hu, %Hu}\n", FUNC, sblk_idx, hdr->sblk_info[sblk_idx].ndblks, hdr->sblk_info[sblk_idx].dblk_nelmts, hdr->sblk_info[sblk_idx].start_idx, hdr->sblk_info[sblk_idx].start_dblk);
diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c
index 5fcf2be..3dc5d50 100644
--- a/src/H5EAhdr.c
+++ b/src/H5EAhdr.c
@@ -131,7 +131,7 @@ H5EA__hdr_alloc(H5F_t *f, const H5EA_class_t *cls))
hdr->sizeof_size = H5F_SIZEOF_SIZE(f);
/* Set the class of the array */
- hdr->cls = cls;
+ hdr->cparam.cls = cls;
/* Set the return value */
ret_value = hdr;
@@ -191,12 +191,12 @@ H5EA__hdr_init(H5EA_hdr_t *hdr))
/* Sanity check */
HDassert(hdr);
- HDassert(hdr->max_nelmts_bits);
- HDassert(hdr->data_blk_min_elmts);
- HDassert(hdr->sup_blk_min_data_ptrs);
+ HDassert(hdr->cparam.max_nelmts_bits);
+ HDassert(hdr->cparam.data_blk_min_elmts);
+ HDassert(hdr->cparam.sup_blk_min_data_ptrs);
/* Compute general information */
- hdr->nsblks = 1 + (hdr->max_nelmts_bits - H5V_log2_of2(hdr->data_blk_min_elmts));
+ hdr->nsblks = 1 + (hdr->cparam.max_nelmts_bits - H5V_log2_of2(hdr->cparam.data_blk_min_elmts));
#ifdef QAK
HDfprintf(stderr, "%s: hdr->nsblks = %Zu\n", FUNC, hdr->nsblks);
#endif /* QAK */
@@ -210,7 +210,7 @@ HDfprintf(stderr, "%s: hdr->nsblks = %Zu\n", FUNC, hdr->nsblks);
start_dblk = 0;
for(u = 0; u < hdr->nsblks; u++) {
hdr->sblk_info[u].ndblks = (hsize_t)H5_EXP2(u / 2);
- hdr->sblk_info[u].dblk_nelmts = (size_t)H5_EXP2((u + 1) / 2) * hdr->data_blk_min_elmts;
+ hdr->sblk_info[u].dblk_nelmts = (size_t)H5_EXP2((u + 1) / 2) * hdr->cparam.data_blk_min_elmts;
hdr->sblk_info[u].start_idx = start_idx;
hdr->sblk_info[u].start_dblk = start_dblk;
#ifdef QAK
@@ -257,7 +257,7 @@ H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts))
/* Compute the index of the element buffer factory */
H5_CHECK_OVERFLOW(nelmts, /*From:*/size_t, /*To:*/uint32_t);
- idx = H5V_log2_of2((uint32_t)nelmts) - H5V_log2_of2((uint32_t)hdr->data_blk_min_elmts);
+ idx = H5V_log2_of2((uint32_t)nelmts) - H5V_log2_of2((uint32_t)hdr->cparam.data_blk_min_elmts);
#ifdef QAK
HDfprintf(stderr, "%s: nelmts = %Zu, hdr->data_blk_min_elmts = %u, idx = %u\n", FUNC, nelmts, (unsigned)hdr->data_blk_min_elmts, idx);
#endif /* QAK */
@@ -281,7 +281,7 @@ HDfprintf(stderr, "%s: nelmts = %Zu, hdr->data_blk_min_elmts = %u, idx = %u\n",
/* Check for un-initialized factory at index */
if(NULL == hdr->elmt_fac.fac[idx]) {
- if(NULL == (hdr->elmt_fac.fac[idx] = H5FL_fac_init(nelmts * (size_t)hdr->cls->nat_elmt_size)))
+ if(NULL == (hdr->elmt_fac.fac[idx] = H5FL_fac_init(nelmts * (size_t)hdr->cparam.cls->nat_elmt_size)))
H5E_THROW(H5E_CANTINIT, "can't create data block data element buffer factory")
} /* end if */
@@ -327,7 +327,7 @@ H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts))
/* Compute the index of the element buffer factory */
H5_CHECK_OVERFLOW(nelmts, /*From:*/size_t, /*To:*/uint32_t);
- idx = H5V_log2_of2((uint32_t)nelmts) - H5V_log2_of2((uint32_t)hdr->data_blk_min_elmts);
+ idx = H5V_log2_of2((uint32_t)nelmts) - H5V_log2_of2((uint32_t)hdr->cparam.data_blk_min_elmts);
#ifdef QAK
HDfprintf(stderr, "%s: nelmts = %Zu, hdr->data_blk_min_elmts = %u, idx = %u\n", FUNC, nelmts, (unsigned)hdr->data_blk_min_elmts, idx);
#endif /* QAK */
@@ -392,18 +392,14 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
hdr->idx_blk_addr = HADDR_UNDEF;
/* Set the creation parameters for the array */
- hdr->raw_elmt_size = cparam->raw_elmt_size;
- hdr->max_nelmts_bits = cparam->max_nelmts_bits;
- hdr->idx_blk_elmts = cparam->idx_blk_elmts;
- hdr->sup_blk_min_data_ptrs = cparam->sup_blk_min_data_ptrs;
- hdr->data_blk_min_elmts = cparam->data_blk_min_elmts;
+ HDmemcpy(&hdr->cparam, cparam, sizeof(hdr->cparam));
/* Finish initializing extensible array header */
if(H5EA__hdr_init(hdr) < 0)
H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header")
/* Allocate space for the header on disk */
- if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, dxpl_id, hdr->size)))
+ if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, dxpl_id, (hsize_t)hdr->size)))
H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header")
/* Cache the new extensible array header */
diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c
index bf3fac4..75c2c85 100644
--- a/src/H5EAiblock.c
+++ b/src/H5EAiblock.c
@@ -123,8 +123,8 @@ H5EA__iblock_alloc(H5EA_hdr_t *hdr))
iblock->addr = HADDR_UNDEF;
/* Compute information */
- iblock->nsblks = 2 * H5V_log2_of2((uint32_t)hdr->sup_blk_min_data_ptrs);
- iblock->ndblk_addrs = 2 * ((size_t)hdr->sup_blk_min_data_ptrs - 1);
+ iblock->nsblks = 2 * H5V_log2_of2((uint32_t)hdr->cparam.sup_blk_min_data_ptrs);
+ iblock->ndblk_addrs = 2 * ((size_t)hdr->cparam.sup_blk_min_data_ptrs - 1);
iblock->nsblk_addrs = hdr->nsblks - iblock->nsblks;
#ifdef QAK
HDfprintf(stderr, "%s: iblock->nsblks = %u\n", FUNC, iblock->nsblks);
@@ -133,8 +133,8 @@ HDfprintf(stderr, "%s: iblock->nsblk_addrs = %Zu\n", FUNC, iblock->nsblk_addrs);
#endif /* QAK */
/* Allocate buffer for elements in index block */
- if(hdr->idx_blk_elmts > 0)
- if(NULL == (iblock->elmts = H5FL_BLK_MALLOC(idx_blk_elmt_buf, (size_t)(hdr->idx_blk_elmts * hdr->cls->nat_elmt_size))))
+ if(hdr->cparam.idx_blk_elmts > 0)
+ if(NULL == (iblock->elmts = H5FL_BLK_MALLOC(idx_blk_elmt_buf, (size_t)(hdr->cparam.idx_blk_elmts * hdr->cparam.cls->nat_elmt_size))))
H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data element buffer")
/* Allocate buffer for data block addresses in index block */
@@ -201,13 +201,13 @@ HDfprintf(stderr, "%s: iblock->size = %Zu\n", FUNC, iblock->size);
#endif /* QAK */
/* Allocate space for the index block on disk */
- if(HADDR_UNDEF == (iblock->addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_IBLOCK, dxpl_id, iblock->size)))
+ if(HADDR_UNDEF == (iblock->addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_IBLOCK, dxpl_id, (hsize_t)iblock->size)))
H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array index block")
/* Clear any elements in index block to fill value */
- if(hdr->idx_blk_elmts > 0) {
+ if(hdr->cparam.idx_blk_elmts > 0) {
/* Call the class's 'fill' callback */
- if((hdr->cls->fill)(iblock->elmts, (size_t)hdr->idx_blk_elmts) < 0)
+ if((hdr->cparam.cls->fill)(iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts) < 0)
H5E_THROW(H5E_CANTSET, "can't set extensible array index block elements to class's fill value")
} /* end if */
@@ -431,7 +431,7 @@ H5EA__iblock_dest(H5F_t *f, H5EA_iblock_t *iblock))
iblock->hdr->f = f;
/* Check if we've got elements in the index block */
- if(iblock->hdr->idx_blk_elmts > 0) {
+ if(iblock->hdr->cparam.idx_blk_elmts > 0) {
/* Free buffer for index block elements */
HDassert(iblock->elmts);
(void)H5FL_BLK_FREE(idx_blk_elmt_buf, iblock->elmts);
diff --git a/src/H5EApkg.h b/src/H5EApkg.h
index 72264cd..ca920ec 100644
--- a/src/H5EApkg.h
+++ b/src/H5EApkg.h
@@ -386,7 +386,7 @@ func_init_failed: \
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Extensible Array Index Block specific fields */ \
- + ((size_t)(i)->hdr->idx_blk_elmts * (size_t)(i)->hdr->raw_elmt_size) /* Elements in index block */ \
+ + ((size_t)(i)->hdr->cparam.idx_blk_elmts * (size_t)(i)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \
+ ((i)->ndblk_addrs * (i)->hdr->sizeof_addr) /* Data block addresses in index block */ \
+ ((i)->nsblk_addrs * (i)->hdr->sizeof_addr) /* Super block addresses in index block */ \
)
@@ -397,7 +397,7 @@ func_init_failed: \
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Extensible Array Data Block specific fields */ \
- + ((d)->nelmts * (size_t)(d)->hdr->raw_elmt_size) /* Elements in index block */ \
+ + ((d)->nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \
)
@@ -422,11 +422,7 @@ typedef struct H5EA_hdr_t {
H5AC_info_t cache_info;
/* Extensible array configuration/creation parameters (stored) */
- uint8_t raw_elmt_size; /* Element size in file (in bytes) */
- uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
- uint8_t idx_blk_elmts; /* # of elements to store in index block */
- uint8_t data_blk_min_elmts; /* Min. # of elements per data block */
- uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */
+ H5EA_create_t cparam; /* Creation parameters for extensible array */
/* Index block information (stored in header) */
haddr_t idx_blk_addr; /* Address of index block in header */
@@ -453,9 +449,6 @@ typedef struct H5EA_hdr_t {
/* Super block information (not stored) */
size_t nsblks; /* Number of superblocks needed for array */
H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */
-
- /* Memory data structures (not stored directly) */
- const H5EA_class_t *cls; /* Pointer to class for array */
} H5EA_hdr_t;
/* The extensible array index block information */
diff --git a/src/H5EAtest.c b/src/H5EAtest.c
index 00e6e64..25b33dd 100644
--- a/src/H5EAtest.c
+++ b/src/H5EAtest.c
@@ -262,11 +262,11 @@ H5EA_get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam))
HDassert(cparam);
/* Get extensible array creation parameters */
- cparam->raw_elmt_size = ea->hdr->raw_elmt_size;
- cparam->max_nelmts_bits = ea->hdr->max_nelmts_bits;
- cparam->idx_blk_elmts = ea->hdr->idx_blk_elmts;
- cparam->sup_blk_min_data_ptrs = ea->hdr->sup_blk_min_data_ptrs;
- cparam->data_blk_min_elmts = ea->hdr->data_blk_min_elmts;
+ cparam->raw_elmt_size = ea->hdr->cparam.raw_elmt_size;
+ cparam->max_nelmts_bits = ea->hdr->cparam.max_nelmts_bits;
+ cparam->idx_blk_elmts = ea->hdr->cparam.idx_blk_elmts;
+ cparam->sup_blk_min_data_ptrs = ea->hdr->cparam.sup_blk_min_data_ptrs;
+ cparam->data_blk_min_elmts = ea->hdr->cparam.data_blk_min_elmts;
END_FUNC(PRIV) /* end H5EA_get_cparam_test() */
diff --git a/test/earray.c b/test/earray.c
index c0c7bb7..1a45bf1 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -28,6 +28,7 @@
/* Other private headers that this test requires */
#include "H5Iprivate.h" /* IDs */
+#include "H5Vprivate.h" /* Vectors and arrays */
/* Local macros */
@@ -73,6 +74,10 @@ typedef enum {
typedef struct earray_test_param_t {
earray_test_type_t reopen_array; /* Whether to re-open the array during the test */
earray_test_comp_t comp; /* Whether to compress the blocks or not */
+
+ /* Super block information */
+ size_t nsblks; /* Number of superblocks needed for array */
+ H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */
} earray_test_param_t;
/* Extensible array state information */
@@ -131,6 +136,80 @@ init_cparam(H5EA_create_t *cparam)
/*-------------------------------------------------------------------------
+ * Function: init_tparam
+ *
+ * Purpose: Initialize array testing parameter structure
+ *
+ * Note: This initialization is the same as that in H5EA_hdr_init()
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, September 25, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+init_tparam(earray_test_param_t *tparam, const H5EA_create_t *cparam)
+{
+ hsize_t start_idx; /* First element index for each super block */
+ hsize_t start_dblk; /* First data block index for each super block */
+ size_t u; /* Local index variable */
+
+ /* Wipe out background */
+ HDmemset(tparam, 0, sizeof(*tparam));
+
+ /* Compute general information */
+ tparam->nsblks = 1 + (cparam->max_nelmts_bits - H5V_log2_of2(cparam->data_blk_min_elmts));
+
+ /* Allocate information for each super block */
+ tparam->sblk_info = (H5EA_sblk_info_t *)HDmalloc(sizeof(H5EA_sblk_info_t) * tparam->nsblks);
+ HDassert(tparam->sblk_info);
+
+ /* Compute information about each super block */
+ start_idx = 0;
+ start_dblk = 0;
+ for(u = 0; u < tparam->nsblks; u++) {
+ tparam->sblk_info[u].ndblks = (hsize_t)H5_EXP2(u / 2);
+ tparam->sblk_info[u].dblk_nelmts = (size_t)H5_EXP2((u + 1) / 2) * cparam->data_blk_min_elmts;
+ tparam->sblk_info[u].start_idx = start_idx;
+ tparam->sblk_info[u].start_dblk = start_dblk;
+
+ /* Advance starting indices for next super block */
+ start_idx += tparam->sblk_info[u].ndblks * tparam->sblk_info[u].dblk_nelmts;
+ start_dblk += tparam->sblk_info[u].ndblks;
+ } /* end for */
+
+ return(0);
+} /* init_tparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: finish_tparam
+ *
+ * Purpose: Close down array testing parameter structure
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, September 25, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+finish_tparam(earray_test_param_t *tparam)
+{
+ /* Release super block information */
+ HDfree(tparam->sblk_info);
+ tparam->sblk_info = NULL;
+
+ return(0);
+} /* finish_tparam() */
+
+
+/*-------------------------------------------------------------------------
* Function: create_file
*
* Purpose: Create file and retrieve pointer to internal file object
@@ -870,379 +949,9 @@ error:
/*-------------------------------------------------------------------------
- * Function: test_set_first
+ * Function: test_set_elmts
*
- * Purpose: Set first element in extensible array
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, August 28, 2008
- *
- *-------------------------------------------------------------------------
- */
-static unsigned
-test_set_first(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
-{
- hid_t file = -1; /* File ID */
- H5F_t *f = NULL; /* Internal file object pointer */
- H5EA_t *ea = NULL; /* Extensible array wrapper */
- earray_state_t state; /* State of extensible array */
- uint64_t welmt; /* Element to write */
- uint64_t relmt; /* Element to read */
- hsize_t nelmts; /* Highest element written in array */
- haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
-
- /*
- * Display testing message
- */
- TESTING("setting first element of array");
-
- /* Check for elements in index block */
- if(cparam->idx_blk_elmts > 0) {
- /* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
- TEST_ERROR
-
- /* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
- TEST_ERROR
-
- /* Verify the creation parameters */
- if(verify_cparam(ea, cparam) < 0)
- TEST_ERROR
-
- /* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
- TEST_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != 0)
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Retrieve first element of array (not set yet) */
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify first element is fill value for array */
- if(relmt != H5EA_TEST_FILL)
- TEST_ERROR
-
- /* Set first element of array */
- welmt = (uint64_t)7;
- if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, &welmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != 1)
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- state.max_idx_set = 1;
- state.nelmts = (hsize_t)cparam->idx_blk_elmts;
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Retrieve first element of array (set now) */
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify first element is value written */
- if(relmt != welmt)
- TEST_ERROR
-
- /* Close array, delete array, close file & verify file is empty */
- if(finish(file, f, ea, ea_addr) < 0)
- TEST_ERROR
-
- /* All tests passed */
- PASSED()
- } /* end if */
- else {
- SKIPPED();
- puts(" No elements stored in index block");
- } /* end else */
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- if(ea)
- H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
- H5Fclose(file);
- } H5E_END_TRY;
-
- return 1;
-} /* test_set_first() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_set_iblock
- *
- * Purpose: Set all elements in extensible array's index block
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, September 11, 2008
- *
- *-------------------------------------------------------------------------
- */
-static unsigned
-test_set_iblock(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
-{
- hid_t file = -1; /* File ID */
- H5F_t *f = NULL; /* Internal file object pointer */
- H5EA_t *ea = NULL; /* Extensible array wrapper */
- earray_state_t state; /* State of extensible array */
- uint64_t welmt; /* Element to write */
- uint64_t relmt; /* Element to read */
- hsize_t nelmts; /* Highest element written in array */
- haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
-
- /*
- * Display testing message
- */
- TESTING("setting index block elements of array");
-
- /* Check for elements in index block */
- if(cparam->idx_blk_elmts > 0) {
- unsigned u; /* Local index variable */
-
- /* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
- TEST_ERROR
-
- /* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
- TEST_ERROR
-
- /* Verify the creation parameters */
- if(verify_cparam(ea, cparam) < 0)
- TEST_ERROR
-
- /* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
- TEST_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != 0)
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Retrieve elements of array in index block (not set yet) */
- for(u = 0; u < cparam->idx_blk_elmts; u++) {
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)u, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify first element is fill value for array */
- if(relmt != H5EA_TEST_FILL)
- TEST_ERROR
- } /* end for */
-
- /* Set elements of array in index block */
- for(u = 0; u < cparam->idx_blk_elmts; u++) {
- welmt = (uint64_t)(7 + u);
- if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)u, &welmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != (u + 1))
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- state.max_idx_set = u + 1;
- state.nelmts = (hsize_t)cparam->idx_blk_elmts;
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Retrieve first element of array (set now) */
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)u, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify first element is value written */
- if(relmt != welmt)
- TEST_ERROR
- } /* end for */
-
- /* Close array, delete array, close file & verify file is empty */
- if(finish(file, f, ea, ea_addr) < 0)
- TEST_ERROR
-
- /* All tests passed */
- PASSED()
- } /* end if */
- else {
- SKIPPED();
- puts(" No elements stored in index block");
- } /* end else */
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- if(ea)
- H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
- H5Fclose(file);
- } H5E_END_TRY;
-
- return 1;
-} /* test_set_iblock() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_set_first_dblock_first
- *
- * Purpose: Set first element in extensible array's first data block
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, September 11, 2008
- *
- *-------------------------------------------------------------------------
- */
-static unsigned
-test_set_first_dblock_first(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
-{
- hid_t file = -1; /* File ID */
- H5F_t *f = NULL; /* Internal file object pointer */
- H5EA_t *ea = NULL; /* Extensible array wrapper */
- earray_state_t state; /* State of extensible array */
- uint64_t welmt; /* Element to write */
- uint64_t relmt; /* Element to read */
- hsize_t nelmts; /* Highest element written in array */
- hsize_t idx; /* Index value of first element of first data block */
- haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
-
- /*
- * Display testing message
- */
- TESTING("setting first element of array's first data block");
-
- /* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
- TEST_ERROR
-
- /* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
- TEST_ERROR
-
- /* Verify the creation parameters */
- if(verify_cparam(ea, cparam) < 0)
- TEST_ERROR
-
- /* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
- TEST_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != 0)
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Compute index of first element of first data block */
- idx = cparam->idx_blk_elmts;
-
- /* Retrieve first element of first data block of array (not set yet) */
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify first element is fill value for array */
- if(relmt != H5EA_TEST_FILL)
- TEST_ERROR
-
- /* Set first element of first data block */
- welmt = (uint64_t)7;
- if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != (idx + 1))
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- state.max_idx_set = idx + 1;
- state.ndata_blks = 1;
- state.nelmts = (hsize_t)(cparam->idx_blk_elmts + cparam->data_blk_min_elmts);
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Retrieve first element of array (set now) */
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify first element is value written */
- if(relmt != welmt)
- TEST_ERROR
-
- /* Close array, delete array, close file & verify file is empty */
- if(finish(file, f, ea, ea_addr) < 0)
- TEST_ERROR
-
- /* All tests passed */
- PASSED()
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- if(ea)
- H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
- H5Fclose(file);
- } H5E_END_TRY;
-
- return 1;
-} /* test_set_first_dblock_first() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_set_first_dblock
- *
- * Purpose: Set all elements in extensible array's first data block
+ * Purpose: Set all elements from 0 through 'nelmts' in extensible array
*
* Return: Success: 0
* Failure: 1
@@ -1253,7 +962,8 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_set_first_dblock(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
+ hsize_t nelmts, const char *test_str)
{
hid_t file = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
@@ -1261,15 +971,14 @@ test_set_first_dblock(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tp
earray_state_t state; /* State of extensible array */
uint64_t welmt; /* Element to write */
uint64_t relmt; /* Element to read */
- hsize_t nelmts; /* Highest element written in array */
+ hsize_t nelmts_written; /* Highest element written in array */
hsize_t idx; /* Index value of first element of first data block */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
- unsigned u; /* Local index variable */
/*
* Display testing message
*/
- TESTING("setting all elements of array's first data block");
+ TESTING(test_str);
/* Create file & retrieve pointer to internal file object */
if(create_file(fapl, &file, &f) < 0)
@@ -1288,10 +997,10 @@ test_set_first_dblock(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tp
TEST_ERROR
/* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
+ nelmts_written = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
FAIL_STACK_ERROR
- if(nelmts != 0)
+ if(nelmts_written != 0)
TEST_ERROR
/* Verify array state */
@@ -1300,11 +1009,8 @@ test_set_first_dblock(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tp
TEST_ERROR
/* Retrieve elements of array in data block (not set yet) */
- for(u = 0; u < cparam->data_blk_min_elmts; u++) {
- /* Compute index of element of first data block */
- idx = cparam->idx_blk_elmts + u;
-
- /* Retrieve element of first data block of array (not set yet) */
+ for(idx = 0; idx < nelmts; idx++) {
+ /* Retrieve element of array (not set yet) */
relmt = (uint64_t)0;
if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
FAIL_STACK_ERROR
@@ -1314,28 +1020,48 @@ test_set_first_dblock(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tp
TEST_ERROR
} /* end for */
- /* Set elements of array in index block */
- for(u = 0; u < cparam->data_blk_min_elmts; u++) {
- /* Compute index of element of first data block */
- idx = cparam->idx_blk_elmts + u;
-
+ /* Set elements of array */
+ for(idx = 0; idx < nelmts; idx++) {
/* Set element of first data block */
- welmt = (uint64_t)7 + u;
+ welmt = (uint64_t)7 + idx;
if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
FAIL_STACK_ERROR
/* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
+ nelmts_written = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
FAIL_STACK_ERROR
- if(nelmts != (idx + 1))
+ if(nelmts_written != (idx + 1))
TEST_ERROR
/* Verify array state */
HDmemset(&state, 0, sizeof(state));
state.max_idx_set = idx + 1;
- state.ndata_blks = 1;
- state.nelmts = (hsize_t)(cparam->idx_blk_elmts + cparam->data_blk_min_elmts);
+ if(idx < cparam->idx_blk_elmts)
+ state.nelmts = (hsize_t)cparam->idx_blk_elmts;
+ else {
+ unsigned sblk_idx; /* Which superblock does this index fall in? */
+
+ /* Compute super block index for element index */
+ /* (same eqn. as in H5EA__dblock_sblk_idx()) */
+ sblk_idx = H5V_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
+#ifdef QAK
+HDfprintf(stderr, "idx = %Hu, tparam->sblk_info[%u] = {%Hu, %Zu, %Hu, %Hu}\n", idx, sblk_idx, tparam->sblk_info[sblk_idx].ndblks, tparam->sblk_info[sblk_idx].dblk_nelmts, tparam->sblk_info[sblk_idx].start_idx, tparam->sblk_info[sblk_idx].start_dblk);
+#endif /* QAK */
+
+ state.nelmts = (hsize_t)(cparam->idx_blk_elmts +
+ tparam->sblk_info[sblk_idx].start_idx +
+ ((1 + ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / tparam->sblk_info[sblk_idx].dblk_nelmts))
+ * tparam->sblk_info[sblk_idx].dblk_nelmts));
+#ifdef QAK
+HDfprintf(stderr, "state.nelmts = %Hu\n", state.nelmts);
+#endif /* QAK */
+ state.ndata_blks = 1 + tparam->sblk_info[sblk_idx].start_dblk +
+ ((idx - cparam->idx_blk_elmts) / tparam->sblk_info[sblk_idx].dblk_nelmts);
+#ifdef QAK
+HDfprintf(stderr, "state.ndata_blks = %Hu\n", state.ndata_blks);
+#endif /* QAK */
+ } /* end else */
if(check_stats(ea, &state))
TEST_ERROR
@@ -1366,127 +1092,7 @@ error:
} H5E_END_TRY;
return 1;
-} /* test_set_first_dblock() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_set_second_dblock_first
- *
- * Purpose: Set first element in extensible array's second data block
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, September 22, 2008
- *
- *-------------------------------------------------------------------------
- */
-static unsigned
-test_set_second_dblock_first(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
-{
- hid_t file = -1; /* File ID */
- H5F_t *f = NULL; /* Internal file object pointer */
- H5EA_t *ea = NULL; /* Extensible array wrapper */
- earray_state_t state; /* State of extensible array */
- uint64_t welmt; /* Element to write */
- uint64_t relmt; /* Element to read */
- hsize_t nelmts; /* Highest element written in array */
- hsize_t idx; /* Index value of first element of first data block */
- haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
-
- /*
- * Display testing message
- */
- TESTING("setting first element of array's second data block");
-
- /* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
- TEST_ERROR
-
- /* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
- TEST_ERROR
-
- /* Verify the creation parameters */
- if(verify_cparam(ea, cparam) < 0)
- TEST_ERROR
-
- /* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
- TEST_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != 0)
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Compute index of first element of second data block */
- idx = (hsize_t)(cparam->idx_blk_elmts + cparam->data_blk_min_elmts);
-
- /* Retrieve element from array (not set yet) */
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify element is fill value for array */
- if(relmt != H5EA_TEST_FILL)
- TEST_ERROR
-
- /* Set element of array */
- welmt = (uint64_t)7;
- if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify high-water # of elements written */
- nelmts = (hsize_t)ULLONG_MAX;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
- FAIL_STACK_ERROR
- if(nelmts != (idx + 1))
- TEST_ERROR
-
- /* Verify array state */
- HDmemset(&state, 0, sizeof(state));
- state.max_idx_set = idx + 1;
- state.ndata_blks = 1;
- state.nelmts = (hsize_t)(cparam->idx_blk_elmts + cparam->data_blk_min_elmts * 2);
- if(check_stats(ea, &state))
- TEST_ERROR
-
- /* Retrieve element of array (set now) */
- relmt = (uint64_t)0;
- if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
- FAIL_STACK_ERROR
-
- /* Verify element is value written */
- if(relmt != welmt)
- TEST_ERROR
-
- /* Close array, delete array, close file & verify file is empty */
- if(finish(file, f, ea, ea_addr) < 0)
- TEST_ERROR
-
- /* All tests passed */
- PASSED()
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- if(ea)
- H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
- H5Fclose(file);
- } H5E_END_TRY;
-
- return 1;
-} /* test_set_second_dblock_first() */
+} /* test_set_elmts() */
/*-------------------------------------------------------------------------
@@ -1552,8 +1158,8 @@ main(void)
/* Iterate over the testing parameters */
for(curr_test = EARRAY_TEST_NORMAL; curr_test < EARRAY_TEST_NTESTS; curr_test++) {
- /* Clear the testing parameters */
- HDmemset(&tparam, 0, sizeof(tparam));
+ /* Initialize the testing parameters */
+ init_tparam(&tparam, &cparam);
/* Set appropriate testing parameters for each test */
switch(curr_test) {
@@ -1580,11 +1186,14 @@ main(void)
nerrors += test_delete_open(fapl, &cparam, &tparam);
/* Basic capacity tests */
- nerrors += test_set_first(fapl, &cparam, &tparam);
- nerrors += test_set_iblock(fapl, &cparam, &tparam);
- nerrors += test_set_first_dblock_first(fapl, &cparam, &tparam);
- nerrors += test_set_first_dblock(fapl, &cparam, &tparam);
- nerrors += test_set_second_dblock_first(fapl, &cparam, &tparam);
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)0, "setting first element of array");
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, "setting index block elements of array");
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + 1), "setting first element of array's first data block");
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + cparam.data_blk_min_elmts), "setting all elements of array's first data block");
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + cparam.data_blk_min_elmts + 1), "setting first element of array's second data block");
+
+ /* Close down testing parameters */
+ finish_tparam(&tparam);
} /* end for */
if(nerrors)