diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-07-30 02:57:12 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-07-30 02:57:12 (GMT) |
commit | 31a7cd56bfdb08646d9638fdabb576b3af38fc11 (patch) | |
tree | dc70241d63eb91309da13aefa690734dd47921f3 /src | |
parent | 981ba55190b978b3e67223df0a7049c65c826a1a (diff) | |
download | hdf5-31a7cd56bfdb08646d9638fdabb576b3af38fc11.zip hdf5-31a7cd56bfdb08646d9638fdabb576b3af38fc11.tar.gz hdf5-31a7cd56bfdb08646d9638fdabb576b3af38fc11.tar.bz2 |
[svn-r17271] Description:
Bring r17269 from trunk to 1.8 branch:
Refactor how serialized size of layout message is computed, slightly.
Tested on:
Mac OS X/32 10.5.7 (amazon) debug & production
FreeBSD/32 6.3 (duty) debug
Too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dcompact.c | 6 | ||||
-rw-r--r-- | src/H5Dlayout.c | 63 | ||||
-rw-r--r-- | src/H5Dpkg.h | 2 | ||||
-rw-r--r-- | src/H5Olayout.c | 69 | ||||
-rw-r--r-- | src/H5Oprivate.h | 3 |
5 files changed, 71 insertions, 72 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 7639c2e..17bf531 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -172,7 +172,7 @@ static herr_t H5D_compact_construct(H5F_t *f, H5D_t *dset) { hssize_t tmp_size; /* Temporary holder for raw data size */ - hsize_t comp_data_size; /* Size of compact data */ + hsize_t max_comp_data_size; /* Max. allowed size of compact data */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_compact_construct) @@ -191,8 +191,8 @@ H5D_compact_construct(H5F_t *f, H5D_t *dset) /* Verify data size is smaller than maximum header message size * (64KB) minus other layout message fields. */ - comp_data_size = H5O_MESG_MAX_SIZE - H5O_layout_meta_size(f, &(dset->shared->layout)); - if(dset->shared->layout.store.u.compact.size > comp_data_size) + max_comp_data_size = H5O_MESG_MAX_SIZE - H5D_layout_meta_size(f, &(dset->shared->layout), FALSE); + if(dset->shared->layout.store.u.compact.size > max_comp_data_size) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "compact dataset size is bigger than header message maximum size") done: diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 4966cb5..1c74a66 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -114,6 +114,69 @@ done: /*------------------------------------------------------------------------- + * Function: H5D_layout_meta_size + * + * Purpose: Returns the size of the raw message in bytes except raw data + * part for compact dataset. This function doesn't take into + * account message alignment. + * + * Return: Success: Message data size in bytes + * Failure: 0 + * + * Programmer: Raymond Lu + * August 14, 2002 + * + *------------------------------------------------------------------------- + */ +size_t +H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data) +{ + size_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT(H5D_layout_meta_size) + + /* check args */ + HDassert(f); + HDassert(layout); + + ret_value = 1 + /* Version number */ + 1; /* layout class type */ + + switch(layout->type) { + case H5D_COMPACT: + /* Size of raw data */ + ret_value += 2; + if(include_compact_data) + ret_value += layout->store.u.compact.size;/* data for compact dataset */ + break; + + case H5D_CONTIGUOUS: + ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ + ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ + break; + + case H5D_CHUNKED: + /* Number of dimensions (1 byte) */ + HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + ret_value++; + + /* Dimension sizes */ + ret_value += layout->u.chunk.ndims * 4; + + /* B-tree address */ + ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ + break; + + default: + HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_layout_meta_size() */ + + +/*------------------------------------------------------------------------- * Function: H5D_layout_oh_create * * Purpose: Create layout/pline/efl information for dataset diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 3167f56..b77c391 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -559,6 +559,8 @@ H5_DLL herr_t H5D_scatgath_write(const H5D_io_info_t *io_info, /* Functions that operate on dataset's layout information */ H5_DLL herr_t H5D_layout_set_io_ops(const H5D_t *dataset); +H5_DLL size_t H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, + hbool_t include_compact_data); H5_DLL herr_t H5D_layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, hid_t dapl_id); H5_DLL herr_t H5D_layout_oh_read(H5D_t *dset, hid_t dxpl_id, hid_t dapl_id, diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 0f9370a..8c3e266 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -430,9 +430,9 @@ H5O_layout_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg HDassert(f); HDassert(mesg); - ret_value = H5O_layout_meta_size(f, mesg); - if(H5D_COMPACT == mesg->type) - ret_value += mesg->store.u.compact.size;/* data for compact dataset */ + /* Compute serialized size */ + /* (including possibly compact data) */ + ret_value = H5D_layout_meta_size(f, mesg, TRUE); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_layout_size() */ @@ -740,66 +740,3 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_layout_debug() */ - -/*------------------------------------------------------------------------- - * Function: H5O_layout_meta_size - * - * Purpose: Returns the size of the raw message in bytes except raw data - * part for compact dataset. This function doesn't take into - * account message alignment. - * - * Return: Success: Message data size in bytes(except raw data - * for compact dataset) - * Failure: 0 - * - * Programmer: Raymond Lu - * August 14, 2002 - * - *------------------------------------------------------------------------- - */ -size_t -H5O_layout_meta_size(const H5F_t *f, const void *_mesg) -{ - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - size_t ret_value; - - FUNC_ENTER_NOAPI_NOINIT(H5O_layout_meta_size) - - /* check args */ - HDassert(f); - HDassert(mesg); - - ret_value = 1 + /* Version number */ - 1; /* layout class type */ - - switch(mesg->type) { - case H5D_COMPACT: - /* Size of raw data */ - ret_value += 2; - break; - - case H5D_CONTIGUOUS: - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ - break; - - case H5D_CHUNKED: - /* Number of dimensions (1 byte) */ - HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); - ret_value++; - - /* Dimension sizes */ - ret_value += mesg->u.chunk.ndims * 4; - - /* B-tree address */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - break; - - default: - HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_layout_meta_size() */ - diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index ada4c9c..3f05abf 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -673,9 +673,6 @@ H5_DLL herr_t H5O_loc_copy(H5O_loc_t *dst, const H5O_loc_t *src, H5_copy_depth_t H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc); H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc); -/* Layout operators */ -H5_DLL size_t H5O_layout_meta_size(const H5F_t *f, const void *_mesg); - /* EFL operators */ H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl); |