diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-03-11 04:01:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-03-11 04:01:49 (GMT) |
commit | 330a3f1fcb16bcc61c525bb81aa2d4db907974c7 (patch) | |
tree | e8ba6b064af994f3b64534b18c8246b0ac420d59 | |
parent | da3eeee908eb6f6432b7fb15ce211c890d097dd5 (diff) | |
download | hdf5-330a3f1fcb16bcc61c525bb81aa2d4db907974c7.zip hdf5-330a3f1fcb16bcc61c525bb81aa2d4db907974c7.tar.gz hdf5-330a3f1fcb16bcc61c525bb81aa2d4db907974c7.tar.bz2 |
[svn-r10190] Purpose:
New feature
Description:
Add query for the total size of blocks tracked
Platforms tested:
FreeBSD 4.11 (sleipnir)
Solaris 2.9 (shanti)
-rw-r--r-- | src/H5BT.c | 48 | ||||
-rw-r--r-- | src/H5BTprivate.h | 2 | ||||
-rw-r--r-- | test/blocktrack.c | 30 |
3 files changed, 78 insertions, 2 deletions
@@ -44,7 +44,7 @@ /* If this flag is not set, then only part of the blocks have been */ /* searched to determine the current maximum block size. This can happen */ /* during block shrinks or removals */ -#define H5BT_STATUS_MIN_VALID 0x01 /* Minimum block size valid over all blocks tracked */ +#define H5BT_STATUS_MIN_VALID 0x02 /* Minimum block size valid over all blocks tracked */ /* If this flag is not set, then only part of the blocks have been */ /* searched to determine the current minimum block size. This can happen */ /* during block expansions or removals */ @@ -242,7 +242,7 @@ HGOTO_ERROR(H5E_BLKTRK, H5E_UNSUPPORTED, FAIL, "lower or upper block found!") bt->status |= H5BT_STATUS_MAX_VALID; bt->min_block_size = length; bt->min_block_cnt = 1; - bt->status |= H5BT_STATUS_MAX_VALID; + bt->status |= H5BT_STATUS_MIN_VALID; } /* end if */ else { /* Update maximum block size */ @@ -273,3 +273,47 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5BT_insert() */ + +/*------------------------------------------------------------------------- + * Function: H5BT_get_total_size + * + * Purpose: Query the total amount of bytes tracked + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5BT_get_total_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *tot_size) +{ + H5BT_t *bt = NULL; /* The new B-tree header information */ + herr_t ret_value=SUCCEED; + + FUNC_ENTER_NOAPI(H5BT_get_total_size, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(tot_size); + + /* Look up the block tracker header */ + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BLTR, addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTPROTECT, FAIL, "unable to load block tracker info") + + /* Save total number of bytes tracked in all blocks */ + *tot_size = bt->tot_block_size; + +done: + /* Release the block tracker info */ + if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BLTR, addr, bt, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BLKTRK, H5E_CANTUNPROTECT, FAIL, "unable to release block tracker info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5BT_get_total_size() */ + diff --git a/src/H5BTprivate.h b/src/H5BTprivate.h index 2c01e51..a5805ac 100644 --- a/src/H5BTprivate.h +++ b/src/H5BTprivate.h @@ -48,6 +48,8 @@ H5_DLL herr_t H5BT_create(H5F_t *f, hid_t dxpl_id, haddr_t *addr_p); H5_DLL herr_t H5BT_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, haddr_t offset, hsize_t length); +H5_DLL herr_t H5BT_get_total_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, + hsize_t *tot_size); #endif /* _H5BTprivate_H */ diff --git a/test/blocktrack.c b/test/blocktrack.c index 8929bfc..c297bca 100644 --- a/test/blocktrack.c +++ b/test/blocktrack.c @@ -57,6 +57,7 @@ test_create(hid_t fapl) char filename[1024]; H5F_t *f=NULL; haddr_t bt_addr; /* Address of block tracker created */ + hsize_t tot_size; /* Total size of blocks tracked */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); @@ -78,6 +79,16 @@ test_create(hid_t fapl) H5Eprint_stack(H5E_DEFAULT, stdout); goto error; } /* end if */ + + if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) { + H5_FAILED(); + H5Eprint_stack(H5E_DEFAULT, stdout); + goto error; + } /* end if */ + /* Make certain that the size is correct */ + if(tot_size != 0) TEST_ERROR; + + PASSED(); if (H5Fclose(file)<0) TEST_ERROR; @@ -115,6 +126,7 @@ test_insert_one(hid_t fapl) char filename[1024]; H5F_t *f=NULL; haddr_t bt_addr; /* Address of block tracker created */ + hsize_t tot_size; /* Total size of blocks tracked */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); @@ -143,6 +155,14 @@ test_insert_one(hid_t fapl) goto error; } /* end if */ + if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) { + H5_FAILED(); + H5Eprint_stack(H5E_DEFAULT, stdout); + goto error; + } /* end if */ + /* Make certain that the size is correct */ + if(tot_size != 20) TEST_ERROR; + PASSED(); if (H5Fclose(file)<0) TEST_ERROR; @@ -181,6 +201,7 @@ test_insert_many(hid_t fapl) H5F_t *f=NULL; haddr_t bt_addr; /* Address of block tracker created */ unsigned u; /* Local index variable */ + hsize_t tot_size; /* Total size of blocks tracked */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); @@ -209,6 +230,15 @@ test_insert_many(hid_t fapl) H5Eprint_stack(H5E_DEFAULT, stdout); goto error; } /* end if */ + + if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) { + H5_FAILED(); + H5Eprint_stack(H5E_DEFAULT, stdout); + goto error; + } /* end if */ + /* Make certain that the size is correct */ + if(tot_size != ((u+1)*20)) TEST_ERROR; + } /* end for */ PASSED(); |