summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-01-31 18:12:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-01-31 18:12:20 (GMT)
commit940f64156bb08c8875dd18ecb96e9a58f3c8ad82 (patch)
treefaff172323e140a2446f90e935589708f9bd0830
parent9146841b9edd9681dde762985ca595fe8f2800fd (diff)
downloadhdf5-940f64156bb08c8875dd18ecb96e9a58f3c8ad82.zip
hdf5-940f64156bb08c8875dd18ecb96e9a58f3c8ad82.tar.gz
hdf5-940f64156bb08c8875dd18ecb96e9a58f3c8ad82.tar.bz2
[svn-r16391] Description:
Add more metadata statistics to extensible array header. Tested on: FreeBSD 6.3 (duty) (too minor to require h5committest)
-rw-r--r--src/H5EA.c30
-rw-r--r--src/H5EAcache.c30
-rw-r--r--src/H5EAdblock.c24
-rw-r--r--src/H5EAhdr.c4
-rw-r--r--src/H5EAiblock.c25
-rw-r--r--src/H5EApkg.h13
-rw-r--r--src/H5EAprivate.h10
-rw-r--r--src/H5EAsblock.c23
-rw-r--r--test/earray.c52
9 files changed, 160 insertions, 51 deletions
diff --git a/src/H5EA.c b/src/H5EA.c
index aa65da7..86c54fd 100644
--- a/src/H5EA.c
+++ b/src/H5EA.c
@@ -355,15 +355,9 @@ HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx);
HDfprintf(stderr, "%s: Index block address not defined!\n", FUNC, idx);
#endif /* QAK */
/* Create the index block */
- hdr->idx_blk_addr = H5EA__iblock_create(hdr, dxpl_id);
+ hdr->idx_blk_addr = H5EA__iblock_create(hdr, dxpl_id, &hdr_dirty);
if(!H5F_addr_defined(hdr->idx_blk_addr))
H5E_THROW(H5E_CANTCREATE, "unable to create index block")
-
- /* Increment count of elements "realized" */
- hdr->stats.nelmts += hdr->cparam.idx_blk_elmts;
-
- /* Mark the header dirty */
- hdr_dirty = TRUE;
} /* end if */
#ifdef QAK
HDfprintf(stderr, "%s: Index block address is: %a\n", FUNC, hdr->idx_blk_addr);
@@ -415,18 +409,13 @@ HDfprintf(stderr, "%s: dblk_idx = %u, iblock->ndblk_addrs = %Zu\n", FUNC, dblk_i
/* Create data block */
dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts);
- dblk_addr = H5EA__dblock_create(hdr, dxpl_id, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts);
+ dblk_addr = H5EA__dblock_create(hdr, dxpl_id, &hdr_dirty, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts);
if(!H5F_addr_defined(dblk_addr))
H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block")
/* Set data block address in index block */
iblock->dblk_addrs[dblk_idx] = dblk_addr;
iblock_cache_flags |= H5AC__DIRTIED_FLAG;
-
- /* Increment count of elements "realized" and actual data blocks created */
- hdr->stats.ndata_blks++;
- hdr->stats.nelmts += hdr->sblk_info[sblk_idx].dblk_nelmts;
- hdr_dirty = TRUE;
} /* end if */
/* Protect data block */
@@ -452,7 +441,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u, iblock->ndblk_addrs = %Zu\n", FUNC, dblk_i
haddr_t sblk_addr; /* Address of data block created */
/* Create super block */
- sblk_addr = H5EA__sblock_create(hdr, dxpl_id, sblk_idx);
+ sblk_addr = H5EA__sblock_create(hdr, dxpl_id, &hdr_dirty, sblk_idx);
#ifdef QAK
HDfprintf(stderr, "%s: New super block address is: %a\n", FUNC, sblk_addr);
#endif /* QAK */
@@ -462,10 +451,6 @@ HDfprintf(stderr, "%s: New super block address is: %a\n", FUNC, sblk_addr);
/* Set super block address in index block */
iblock->sblk_addrs[sblk_off] = sblk_addr;
iblock_cache_flags |= H5AC__DIRTIED_FLAG;
-
- /* Increment count of actual super blocks created */
- hdr->stats.nsuper_blks++;
- hdr_dirty = TRUE;
} /* end if */
/* Protect super block */
@@ -486,18 +471,13 @@ HDfprintf(stderr, "%s: dblk_idx = %u, sblock->ndblks = %Zu\n", FUNC, dblk_idx, s
/* Create data block */
dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts);
- dblk_addr = H5EA__dblock_create(hdr, dxpl_id, dblk_off, sblock->dblk_nelmts);
+ dblk_addr = H5EA__dblock_create(hdr, dxpl_id, &hdr_dirty, dblk_off, sblock->dblk_nelmts);
if(!H5F_addr_defined(dblk_addr))
H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block")
/* Set data block address in index block */
sblock->dblk_addrs[dblk_idx] = dblk_addr;
sblock_cache_flags |= H5AC__DIRTIED_FLAG;
-
- /* Increment count of elements "realized" and actual data blocks created */
- hdr->stats.ndata_blks++;
- hdr->stats.nelmts += hdr->sblk_info[sblk_idx].dblk_nelmts;
- hdr_dirty = TRUE;
} /* end if */
#ifdef QAK
@@ -832,7 +812,7 @@ CATCH
if(dblk_page && H5EA__dblk_page_unprotect(dblk_page, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block page")
-END_FUNC(PRIV) /* end H5EA_set() */
+END_FUNC(PRIV) /* end H5EA_get() */
/*-------------------------------------------------------------------------
diff --git a/src/H5EAcache.c b/src/H5EAcache.c
index bf2bf43..286c6a5 100644
--- a/src/H5EAcache.c
+++ b/src/H5EAcache.c
@@ -254,14 +254,38 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls,
hdr->cparam.max_dblk_page_nelmts_bits = *p++; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */
/* Array statistics */
- H5F_DECODE_LENGTH(f, p, hdr->stats.max_idx_set); /* Max. index set (+1) */
+ hdr->stats.hdr_size = size; /* Size of header in file */
H5F_DECODE_LENGTH(f, p, hdr->stats.nsuper_blks); /* Number of super blocks created */
+ H5F_DECODE_LENGTH(f, p, hdr->stats.super_blk_size); /* Size of super blocks created */
H5F_DECODE_LENGTH(f, p, hdr->stats.ndata_blks); /* Number of data blocks created */
+ H5F_DECODE_LENGTH(f, p, hdr->stats.data_blk_size); /* Size of data blocks created */
+ H5F_DECODE_LENGTH(f, p, hdr->stats.max_idx_set); /* Max. index set (+1) */
H5F_DECODE_LENGTH(f, p, hdr->stats.nelmts); /* Number of elements 'realized' */
/* Internal information */
H5F_addr_decode(f, &p, &hdr->idx_blk_addr); /* Address of index block */
+ /* Index block statistics */
+ if(H5F_addr_defined(hdr->idx_blk_addr)) {
+ H5EA_iblock_t iblock; /* Fake index block for computing size */
+
+ /* Set index block count for file */
+ hdr->stats.nindex_blks = 1;
+
+ /* Set up fake index block for computing size on disk */
+ iblock.hdr = hdr;
+ iblock.nsblks = H5EA_SBLK_FIRST_IDX(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;
+
+ /* Compute size of index block in file */
+ hdr->stats.index_blk_size = H5EA_IBLOCK_SIZE(&iblock);
+ } /* end if */
+ else {
+ hdr->stats.nindex_blks = 0; /* Number of index blocks in file */
+ hdr->stats.index_blk_size = 0; /* Size of index blocks in file */
+ } /* end else */
+
/* Sanity check */
/* (allow for checksum not decoded yet) */
HDassert((size_t)(p - buf) == (size - H5EA_SIZEOF_CHKSUM));
@@ -365,9 +389,11 @@ H5EA__cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
*p++ = hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */
/* Array statistics */
- H5F_ENCODE_LENGTH(f, p, hdr->stats.max_idx_set); /* Max. index set (+1) */
H5F_ENCODE_LENGTH(f, p, hdr->stats.nsuper_blks); /* Number of super blocks created */
+ H5F_ENCODE_LENGTH(f, p, hdr->stats.super_blk_size); /* Size of super blocks created */
H5F_ENCODE_LENGTH(f, p, hdr->stats.ndata_blks); /* Number of data blocks created */
+ H5F_ENCODE_LENGTH(f, p, hdr->stats.data_blk_size); /* Size of data blocks created */
+ H5F_ENCODE_LENGTH(f, p, hdr->stats.max_idx_set); /* Max. index set (+1) */
H5F_ENCODE_LENGTH(f, p, hdr->stats.nelmts); /* Number of elements 'realized' */
/* Internal information */
diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c
index b64cb7d..aec5af2 100644
--- a/src/H5EAdblock.c
+++ b/src/H5EAdblock.c
@@ -160,10 +160,12 @@ END_FUNC(PKG) /* end H5EA__dblock_alloc() */
*/
BEGIN_FUNC(PKG, ERR,
haddr_t, HADDR_UNDEF, HADDR_UNDEF,
-H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hsize_t dblk_off, size_t nelmts))
+H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty,
+ hsize_t dblk_off, size_t nelmts))
/* Local variables */
- H5EA_dblock_t *dblock = NULL; /* Extensible array data block */
+ H5EA_dblock_t *dblock = NULL; /* Extensible array data block */
+ haddr_t dblock_addr; /* Extensible array data block address */
#ifdef QAK
HDfprintf(stderr, "%s: Called, hdr->dblk_page_nelmts = %Zu, nelmts = %Zu\n", FUNC, hdr->dblk_page_nelmts, nelmts);
@@ -171,6 +173,7 @@ HDfprintf(stderr, "%s: Called, hdr->dblk_page_nelmts = %Zu, nelmts = %Zu\n", FUN
/* Sanity check */
HDassert(hdr);
+ HDassert(hdr_dirty);
HDassert(nelmts > 0);
/* Allocate the data block */
@@ -190,8 +193,9 @@ HDfprintf(stderr, "%s: dblock->block_off = %Hu\n", FUNC, dblock->block_off);
#endif /* QAK */
/* Allocate space for the data block on disk */
- if(HADDR_UNDEF == (dblock->addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dxpl_id, (hsize_t)dblock->size)))
+ if(HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dxpl_id, (hsize_t)dblock->size)))
H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block")
+ dblock->addr = dblock_addr;
/* Don't initialize elements if paged */
if(!dblock->npages)
@@ -200,11 +204,21 @@ HDfprintf(stderr, "%s: dblock->block_off = %Hu\n", FUNC, dblock->block_off);
H5E_THROW(H5E_CANTSET, "can't set extensible array data block elements to class's fill value")
/* Cache the new extensible array data block */
- if(H5AC_set(hdr->f, dxpl_id, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_set(hdr->f, dxpl_id, H5AC_EARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block to cache")
+ /* Update extensible array data block statistics */
+ hdr->stats.ndata_blks++;
+ hdr->stats.data_blk_size += dblock->size;
+
+ /* Increment count of elements "realized" */
+ hdr->stats.nelmts += nelmts;
+
+ /* Mark the header dirty (for updating statistics) */
+ *hdr_dirty = TRUE;
+
/* Set address of data block to return */
- ret_value = dblock->addr;
+ ret_value = dblock_addr;
CATCH
if(!H5F_addr_defined(ret_value))
diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c
index 349dceb..998e169 100644
--- a/src/H5EAhdr.c
+++ b/src/H5EAhdr.c
@@ -235,8 +235,8 @@ HDfprintf(stderr, "%s: hdr->sblk_info[%Zu] = {%Zu, %Zu, %Hu, %Hu}\n", FUNC, u, h
start_dblk += (hsize_t)hdr->sblk_info[u].ndblks;
} /* end for */
- /* Set size of header on disk */
- hdr->size = H5EA_HEADER_SIZE(hdr);
+ /* Set size of header on disk (locally and in statistics) */
+ hdr->stats.hdr_size = hdr->size = H5EA_HEADER_SIZE(hdr);
CATCH
diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c
index dcb75d1..6fd6f2a 100644
--- a/src/H5EAiblock.c
+++ b/src/H5EAiblock.c
@@ -178,10 +178,11 @@ END_FUNC(PKG) /* end H5EA__iblock_alloc() */
*/
BEGIN_FUNC(PKG, ERR,
haddr_t, HADDR_UNDEF, HADDR_UNDEF,
-H5EA__iblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id))
+H5EA__iblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty))
/* Local variables */
- H5EA_iblock_t *iblock = NULL; /* Extensible array index block */
+ H5EA_iblock_t *iblock = NULL; /* Extensible array index block */
+ haddr_t iblock_addr; /* Extensible array index block address */
#ifdef QAK
HDfprintf(stderr, "%s: Called\n", FUNC);
@@ -189,6 +190,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
/* Sanity check */
HDassert(hdr);
+ HDassert(hdr_dirty);
/* Allocate the index block */
if(NULL == (iblock = H5EA__iblock_alloc(hdr)))
@@ -201,8 +203,9 @@ 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, (hsize_t)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")
+ iblock->addr = iblock_addr;
/* Clear any elements in index block to fill value */
if(hdr->cparam.idx_blk_elmts > 0) {
@@ -228,11 +231,23 @@ HDfprintf(stderr, "%s: iblock->size = %Zu\n", FUNC, iblock->size);
} /* end if */
/* Cache the new extensible array index block */
- if(H5AC_set(hdr->f, dxpl_id, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_set(hdr->f, dxpl_id, H5AC_EARRAY_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTINSERT, "can't add extensible array index block to cache")
+ /* Update extensible array index block statistics */
+ HDassert(0 == hdr->stats.nindex_blks);
+ HDassert(0 == hdr->stats.index_blk_size);
+ hdr->stats.nindex_blks = 1;
+ hdr->stats.index_blk_size = iblock->size;
+
+ /* Increment count of elements "realized" */
+ hdr->stats.nelmts += hdr->cparam.idx_blk_elmts;
+
+ /* Mark the header dirty (for updating statistics) */
+ *hdr_dirty = TRUE;
+
/* Set address of index block to return */
- ret_value = iblock->addr;
+ ret_value = iblock_addr;
CATCH
if(!H5F_addr_defined(ret_value))
diff --git a/src/H5EApkg.h b/src/H5EApkg.h
index 7ac5be6..e374d3a 100644
--- a/src/H5EApkg.h
+++ b/src/H5EApkg.h
@@ -372,9 +372,11 @@ func_init_failed: \
+ 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ \
\
/* Extensible Array Header statistics fields */ \
- + (h)->sizeof_size /* Max. index set */ \
+ (h)->sizeof_size /* Number of super blocks created */ \
+ + (h)->sizeof_size /* Size of super blocks created */ \
+ (h)->sizeof_size /* Number of data blocks created */ \
+ + (h)->sizeof_size /* Size of data blocks created */ \
+ + (h)->sizeof_size /* Max. index set */ \
+ (h)->sizeof_size /* Number of elements 'realized' */ \
\
/* Extensible Array Header specific fields */ \
@@ -471,6 +473,7 @@ typedef struct H5EA_hdr_t {
haddr_t idx_blk_addr; /* Address of index block in header */
/* Statistics for array (stored in header) */
+ /* (header and index number/size fields not stored) */
H5EA_stat_t stats; /* Statistics for extensible array */
/* Data block element buffer factory info (not stored in header) */
@@ -636,7 +639,8 @@ H5_DLL herr_t H5EA__hdr_dest(H5EA_hdr_t *hdr);
/* Index block routines */
H5_DLL H5EA_iblock_t *H5EA__iblock_alloc(H5EA_hdr_t *hdr);
-H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id);
+H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id,
+ hbool_t *hdr_dirty);
H5_DLL H5EA_iblock_t *H5EA__iblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id,
H5AC_protect_t rw);
H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, hid_t dxpl_id,
@@ -646,7 +650,8 @@ H5_DLL herr_t H5EA__iblock_dest(H5F_t *f, H5EA_iblock_t *iblock);
/* Super block routines */
H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, unsigned sblk_idx);
-H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, unsigned sblk_idx);
+H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty,
+ unsigned sblk_idx);
H5_DLL H5EA_sblock_t *H5EA__sblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id,
haddr_t sblk_addr, unsigned sblk_idx, H5AC_protect_t rw);
H5_DLL herr_t H5EA__sblock_unprotect(H5EA_sblock_t *sblock, hid_t dxpl_id,
@@ -657,7 +662,7 @@ H5_DLL herr_t H5EA__sblock_dest(H5F_t *f, H5EA_sblock_t *sblock);
/* Data block routines */
H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, size_t nelmts);
-H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id,
+H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty,
hsize_t dblk_off, size_t nelmts);
H5_DLL unsigned H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx);
H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id,
diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h
index 3b9ba4d..f44d046 100644
--- a/src/H5EAprivate.h
+++ b/src/H5EAprivate.h
@@ -83,9 +83,17 @@ typedef struct H5EA_create_t {
/* Extensible array metadata statistics info */
typedef struct H5EA_stat_t {
- hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */
+ /* Non-stored (i.e. computed) fields */
+ hsize_t hdr_size; /* Size of header */
+ hsize_t nindex_blks; /* # of index blocks (should be 0 or 1) */
+ hsize_t index_blk_size; /* Size of index blocks allocated */
+
+ /* Stored fields */
hsize_t nsuper_blks; /* # of super blocks */
+ hsize_t super_blk_size; /* Size of super blocks allocated */
hsize_t ndata_blks; /* # of data blocks */
+ hsize_t data_blk_size; /* Size of data blocks allocated */
+ hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */
hsize_t nelmts; /* # of elements "realized" */
} H5EA_stat_t;
diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c
index 3d3d4e3..4ad83b0 100644
--- a/src/H5EAsblock.c
+++ b/src/H5EAsblock.c
@@ -190,11 +190,13 @@ END_FUNC(PKG) /* end H5EA__sblock_alloc() */
*/
BEGIN_FUNC(PKG, ERR,
haddr_t, HADDR_UNDEF, HADDR_UNDEF,
-H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, unsigned sblk_idx))
+H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty,
+ unsigned sblk_idx))
/* Local variables */
- H5EA_sblock_t *sblock = NULL; /* Extensible array super block */
- haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */
+ H5EA_sblock_t *sblock = NULL; /* Extensible array super block */
+ haddr_t sblock_addr; /* Extensible array super block address */
+ haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */
#ifdef QAK
HDfprintf(stderr, "%s: Called\n", FUNC);
@@ -202,6 +204,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
/* Sanity check */
HDassert(hdr);
+ HDassert(hdr_dirty);
/* Allocate the super block */
if(NULL == (sblock = H5EA__sblock_alloc(hdr, sblk_idx)))
@@ -220,18 +223,26 @@ HDfprintf(stderr, "%s: sblock->block_off = %Hu\n", FUNC, sblock->block_off);
#endif /* QAK */
/* Allocate space for the super block on disk */
- if(HADDR_UNDEF == (sblock->addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, dxpl_id, (hsize_t)sblock->size)))
+ if(HADDR_UNDEF == (sblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, dxpl_id, (hsize_t)sblock->size)))
H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array super block")
+ sblock->addr = sblock_addr;
/* Reset data block addresses to "undefined" address value */
H5V_array_fill(sblock->dblk_addrs, &tmp_addr, sizeof(haddr_t), sblock->ndblks);
/* Cache the new extensible array super block */
- if(H5AC_set(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_set(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblock_addr, sblock, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache")
+ /* Update extensible array super block statistics */
+ hdr->stats.nsuper_blks++;
+ hdr->stats.super_blk_size += sblock->size;
+
+ /* Mark the header dirty (for updating statistics) */
+ *hdr_dirty = TRUE;
+
/* Set address of super block to return */
- ret_value = sblock->addr;
+ ret_value = sblock_addr;
CATCH
if(!H5F_addr_defined(ret_value))
diff --git a/test/earray.c b/test/earray.c
index 7940305..6935a15 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -45,6 +45,8 @@
#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */
/* Convenience macros for computing earray state */
+#define EA_HDR_SIZE 72 /* (hard-coded, current size) */
+#define EA_IBLOCK_SIZE 298 /* (hard-coded, current size) */
#define EA_NELMTS(cparam, tparam, idx, sblk_idx) \
(hsize_t)(cparam->idx_blk_elmts + \
tparam->sblk_info[sblk_idx].start_idx + \
@@ -97,9 +99,14 @@ typedef enum {
/* Extensible array state information */
typedef struct earray_state_t {
- hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */
+ hsize_t hdr_size; /* Size of header */
+ hsize_t nindex_blks; /* # of index blocks */
+ hsize_t index_blk_size; /* Size of index blocks */
hsize_t nsuper_blks; /* # of super blocks */
+ hsize_t super_blk_size; /* Size of super blocks */
hsize_t ndata_blks; /* # of data blocks */
+ hsize_t data_blk_size; /* Size of data blocks */
+ hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */
hsize_t nelmts; /* # of elements "realized" */
} earray_state_t;
@@ -313,14 +320,44 @@ check_stats(const H5EA_t *ea, const earray_state_t *state)
HDfprintf(stdout, "earray_stats.nelmts = %Hu, state->nelmts = %Hu\n", earray_stats.nelmts, state->nelmts);
TEST_ERROR
} /* end if */
+ if(earray_stats.hdr_size != state->hdr_size) {
+ HDfprintf(stdout, "earray_stats.hdr_size = %Hu, state->hdr_size = %Hu\n", earray_stats.hdr_size, state->hdr_size);
+ TEST_ERROR
+ } /* end if */
+ if(earray_stats.nindex_blks != state->nindex_blks) {
+ HDfprintf(stdout, "earray_stats.nindex_blks = %Hu, state->nindex_blks = %Hu\n", earray_stats.nindex_blks, state->nindex_blks);
+ TEST_ERROR
+ } /* end if */
+ if(earray_stats.index_blk_size != state->index_blk_size) {
+ HDfprintf(stdout, "earray_stats.index_blk_size = %Hu, state->index_blk_size = %Hu\n", earray_stats.index_blk_size, state->index_blk_size);
+ TEST_ERROR
+ } /* end if */
if(earray_stats.ndata_blks != state->ndata_blks) {
HDfprintf(stdout, "earray_stats.ndata_blks = %Hu, state->ndata_blks = %Hu\n", earray_stats.ndata_blks, state->ndata_blks);
TEST_ERROR
} /* end if */
+/* Don't compare this currently, it's very hard to compute */
+#ifdef NOT_YET
+ if(earray_stats.data_blk_size != state->data_blk_size) {
+ HDfprintf(stdout, "earray_stats.data_blk_size = %Hu, state->data_blk_size = %Hu\n", earray_stats.data_blk_size, state->data_blk_size);
+ TEST_ERROR
+ } /* end if */
+#endif /* NOT_YET */
if(earray_stats.nsuper_blks != state->nsuper_blks) {
HDfprintf(stdout, "earray_stats.nsuper_blks = %Hu, state->nsuper_blks = %Hu\n", earray_stats.nsuper_blks, state->nsuper_blks);
TEST_ERROR
} /* end if */
+/* Don't compare this currently, it's very hard to compute */
+#ifdef NOT_YET
+ if(earray_stats.super_blk_size != state->super_blk_size) {
+ HDfprintf(stdout, "earray_stats.super_blk_size = %Hu, state->super_blk_size = %Hu\n", earray_stats.super_blk_size, state->super_blk_size);
+ TEST_ERROR
+ } /* end if */
+#endif /* NOT_YET */
+#ifdef QAK
+HDfprintf(stderr, "nelmts = %Hu, total EA size = %Hu\n", earray_stats.nelmts,
+ (earray_stats.hdr_size + earray_stats.index_blk_size + earray_stats.super_blk_size + earray_stats.data_blk_size));
+#endif /* QAK */
/* All tests passed */
return(0);
@@ -422,6 +459,7 @@ create_array(H5F_t *f, hid_t dxpl, const H5EA_create_t *cparam,
if(!H5F_addr_defined(*ea_addr))
TEST_ERROR
HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
if(check_stats(*ea, &state))
TEST_ERROR
@@ -1158,10 +1196,14 @@ eiter_fw_state(void *_eiter, const H5EA_create_t *cparam,
HDassert(state);
/* Compute the state of the extensible array */
+ state->hdr_size = EA_HDR_SIZE;
+ state->nindex_blks = 1;
+ state->index_blk_size = 298;
state->max_idx_set = idx + 1;
if(idx < cparam->idx_blk_elmts) {
state->nelmts = (hsize_t)cparam->idx_blk_elmts;
state->nsuper_blks = state->ndata_blks = (hsize_t)0;
+ state->super_blk_size = state->data_blk_size = (hsize_t)0;
} /* end if */
else {
unsigned sblk_idx; /* Which superblock does this index fall in? */
@@ -1372,6 +1414,9 @@ eiter_rv_state(void *_eiter, const H5EA_create_t *cparam,
HDassert(state);
/* Compute the state of the extensible array */
+ state->hdr_size = EA_HDR_SIZE;
+ state->nindex_blks = 1;
+ state->index_blk_size = 298;
state->max_idx_set = eiter->max + 1;
if(eiter->max < cparam->idx_blk_elmts) {
state->nelmts = (hsize_t)cparam->idx_blk_elmts;
@@ -1915,6 +1960,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
/* Verify array state */
HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
if(check_stats(ea, &state))
TEST_ERROR
@@ -2088,6 +2134,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
/* Verify array state */
HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
if(check_stats(ea, &state))
TEST_ERROR
@@ -2117,6 +2164,9 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
/* Set array state */
HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
+ state.nindex_blks = 1;
+ state.index_blk_size = EA_IBLOCK_SIZE;
state.max_idx_set = idx + 1;
if(1 == skip_elmts) {
state.nelmts = (hsize_t)cparam->idx_blk_elmts;