summaryrefslogtreecommitdiffstats
path: root/src/H5Oattribute.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-02-21 19:58:48 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-02-21 19:58:48 (GMT)
commit1e07756ac265fad1171cd18efcdb2b0ba9bb903d (patch)
tree92f09eaab8d0ad899a15ef089cc1b7c5f4e07440 /src/H5Oattribute.c
parent9deb5961eeb5265c54df1a8a9daf0cea6c3cded6 (diff)
downloadhdf5-1e07756ac265fad1171cd18efcdb2b0ba9bb903d.zip
hdf5-1e07756ac265fad1171cd18efcdb2b0ba9bb903d.tar.gz
hdf5-1e07756ac265fad1171cd18efcdb2b0ba9bb903d.tar.bz2
[svn-r13367] Description:
Allow "big" attributes to push attribute storage into "dense" form immediately, to accomodate storing the attribute. (This is only allowed in the "latest" version of the format). Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Oattribute.c')
-rw-r--r--src/H5Oattribute.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 3d3ae2c..9377bd0 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -221,24 +221,38 @@ H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr)
if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, FAIL, "unable to load object header")
- /* Check for switching to "dense" attribute storage */
- if(oh->version > H5O_VERSION_1 && oh->nattrs == oh->max_compact &&
- !H5F_addr_defined(oh->attr_fheap_addr)) {
- H5O_iter_cvt_t udata; /* User data for callback */
- H5O_mesg_operator_t op; /* Wrapper for operator */
+ /* Check if switching to "dense" attribute storage is possible */
+ if(oh->version > H5O_VERSION_1 && !H5F_addr_defined(oh->attr_fheap_addr)) {
+ htri_t sharable; /* Whether the attribute will be shared */
+ size_t raw_size = 0; /* Raw size of message */
+
+ /* Check for attribute being sharable */
+ if((sharable = H5SM_can_share(loc->file, dxpl_id, NULL, NULL, H5O_ATTR_ID, attr)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't determine attribute sharing status")
+ else if(sharable == FALSE) {
+ /* Compute the size needed to encode the attribute */
+ raw_size = (H5O_MSG_ATTR->raw_size)(loc->file, FALSE, attr);
+ } /* end if */
- /* Create dense storage for attributes */
- if(H5A_dense_create(loc->file, dxpl_id, oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create dense storage for attributes")
+ /* Check for condititions for switching to "dense" attribute storage are met */
+ if(oh->nattrs == oh->max_compact ||
+ (!sharable && raw_size >= H5O_MESG_MAX_SIZE)) {
+ H5O_iter_cvt_t udata; /* User data for callback */
+ H5O_mesg_operator_t op; /* Wrapper for operator */
- /* Set up user data for callback */
- udata.f = loc->file;
- udata.dxpl_id = dxpl_id;
+ /* Create dense storage for attributes */
+ if(H5A_dense_create(loc->file, dxpl_id, oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create dense storage for attributes")
- /* Iterate over existing attributes, moving them to dense storage */
- op.lib_op = H5O_attr_to_dense_cb;
- if(H5O_msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, TRUE, op, &udata, dxpl_id, &oh_flags) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCONVERT, FAIL, "error converting attributes to dense storage")
+ /* Set up user data for callback */
+ udata.f = loc->file;
+ udata.dxpl_id = dxpl_id;
+
+ /* Iterate over existing attributes, moving them to dense storage */
+ op.lib_op = H5O_attr_to_dense_cb;
+ if(H5O_msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, TRUE, op, &udata, dxpl_id, &oh_flags) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTCONVERT, FAIL, "error converting attributes to dense storage")
+ } /* end if */
} /* end if */
/* Increment attribute count */