mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-17 16:10:24 +08:00
[svn-r13243] Description:
Add API routines for tracking & indexing the creation order on attributes. Tested on: Mac OS X/32 10.4.8 (amazon) FreeBSD/32 6.2 (duty)
This commit is contained in:
parent
4e57d80f2e
commit
571523db1f
11
src/H5O.c
11
src/H5O.c
@ -689,6 +689,10 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
|
||||
if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0)
|
||||
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes")
|
||||
|
||||
/* Get object header flags */
|
||||
if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh->flags) < 0)
|
||||
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags")
|
||||
|
||||
/* Set starting values for attribute info */
|
||||
oh->attr_fheap_addr = HADDR_UNDEF;
|
||||
oh->name_bt2_addr = HADDR_UNDEF;
|
||||
@ -1080,11 +1084,8 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5O_touch_oh(H5F_t *f,
|
||||
hid_t dxpl_id,
|
||||
H5O_t *oh,
|
||||
hbool_t force,
|
||||
unsigned * oh_flags_ptr)
|
||||
H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force,
|
||||
unsigned * oh_flags_ptr)
|
||||
{
|
||||
time_t now; /* Current time */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
@ -262,7 +262,7 @@ H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr)
|
||||
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new attribute in header")
|
||||
} /* end else */
|
||||
|
||||
/* Was new attribugte shared? */
|
||||
/* Was new attribute shared? */
|
||||
if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) > 0) {
|
||||
hsize_t attr_rc; /* Attribute's ref count in shared message storage */
|
||||
|
||||
|
15
src/H5Odbg.c
15
src/H5Odbg.c
@ -299,6 +299,12 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
|
||||
"Birth Time:", buf);
|
||||
|
||||
/* Attribute tracking fields */
|
||||
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
|
||||
"Attribute creation order tracked:",
|
||||
(oh->flags & H5P_CRT_ORDER_TRACKED) ? "Yes" : "No");
|
||||
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
|
||||
"Attribute creation order indexed:",
|
||||
(oh->flags & H5P_CRT_ORDER_INDEXED) ? "Yes" : "No");
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Max. compact attributes:",
|
||||
(unsigned)oh->max_compact);
|
||||
@ -377,20 +383,19 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
|
||||
(unsigned) (oh->mesg[i].type->id),
|
||||
oh->mesg[i].type->name,
|
||||
sequence[oh->mesg[i].type->id]++);
|
||||
HDfprintf (stream, "%*s%-*s %t\n", indent+3, "", MAX (0, fwidth-3),
|
||||
HDfprintf(stream, "%*s%-*s %t\n", indent+3, "", MAX (0, fwidth-3),
|
||||
"Dirty:",
|
||||
oh->mesg[i].dirty);
|
||||
HDfprintf (stream, "%*s%-*s %s\n", indent+3, "", MAX (0, fwidth-3),
|
||||
HDfprintf(stream, "%*s%-*s %s\n", indent+3, "", MAX (0, fwidth-3),
|
||||
"Shared:",
|
||||
(oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) ? "Yes" : "No");
|
||||
HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", MAX(0, fwidth - 3),
|
||||
"Constant:",
|
||||
(oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) ? "Yes" : "No");
|
||||
if(oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS) {
|
||||
HDfprintf (stream, "%*s%-*s 0x%02x\n", indent+3,"",MAX(0,fwidth-3),
|
||||
if(oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS)
|
||||
HDfprintf(stream, "%*s%-*s 0x%02x\n", indent+3,"",MAX(0,fwidth-3),
|
||||
"*** ADDITIONAL UNKNOWN FLAGS --->",
|
||||
oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS);
|
||||
} /* end if */
|
||||
HDfprintf(stream, "%*s%-*s %Zu bytes\n", indent+3, "", MAX(0,fwidth-3),
|
||||
"Raw size in obj header:",
|
||||
oh->mesg[i].raw_size);
|
||||
|
@ -1681,7 +1681,7 @@ done:
|
||||
*/
|
||||
unsigned
|
||||
H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type,
|
||||
unsigned *mesg_flags, void *mesg, unsigned *oh_flags_ptr)
|
||||
unsigned *mesg_flags, void *native, unsigned *oh_flags_ptr)
|
||||
{
|
||||
htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
|
||||
unsigned ret_value = UFAIL; /* Return value */
|
||||
@ -1694,15 +1694,15 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type,
|
||||
HDassert(mesg_flags);
|
||||
HDassert(!(*mesg_flags & H5O_MSG_FLAG_SHARED));
|
||||
HDassert(type);
|
||||
HDassert(mesg);
|
||||
HDassert(native);
|
||||
HDassert(oh_flags_ptr);
|
||||
|
||||
/* Check if message is already shared */
|
||||
if((shared_mesg = H5O_msg_is_shared(type->id, mesg)) < 0)
|
||||
if((shared_mesg = H5O_msg_is_shared(type->id, native)) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, UFAIL, "error determining if message is shared")
|
||||
else if(shared_mesg > 0) {
|
||||
/* Increment message's reference count */
|
||||
if(type->link && (type->link)(f, dxpl_id, mesg) < 0)
|
||||
if(type->link && (type->link)(f, dxpl_id, native) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, UFAIL, "unable to adjust shared message ref count")
|
||||
*mesg_flags |= H5O_MSG_FLAG_SHARED;
|
||||
} /* end if */
|
||||
@ -1710,7 +1710,7 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type,
|
||||
/* Avoid unsharable messages */
|
||||
if(!(*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
|
||||
/* Attempt to share message */
|
||||
if((shared_mesg = H5SM_try_share(f, dxpl_id, type->id, mesg)) > 0)
|
||||
if((shared_mesg = H5SM_try_share(f, dxpl_id, type->id, native)) > 0)
|
||||
/* Mark the message as shared */
|
||||
*mesg_flags |= H5O_MSG_FLAG_SHARED;
|
||||
else if(shared_mesg < 0)
|
||||
@ -1719,13 +1719,13 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type,
|
||||
} /* end else */
|
||||
|
||||
/* Allocate space in the object header for the message */
|
||||
if((ret_value = H5O_alloc(f, dxpl_id, oh, type, mesg, oh_flags_ptr)) == UFAIL)
|
||||
if((ret_value = H5O_alloc(f, dxpl_id, oh, type, native, oh_flags_ptr)) == UFAIL)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, UFAIL, "unable to allocate space for message")
|
||||
|
||||
/* Get the message's "creation index", if it has one */
|
||||
if(type->get_crt_index) {
|
||||
/* Retrieve the creation index for the message */
|
||||
if((type->get_crt_index)(mesg, &oh->mesg[ret_value].crt_idx) < 0)
|
||||
/* Retrieve the creation index from the native message */
|
||||
if((type->get_crt_index)(native, &oh->mesg[ret_value].crt_idx) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, UFAIL, "unable to retrieve creation index")
|
||||
} /* end if */
|
||||
|
||||
|
@ -80,6 +80,7 @@ typedef struct H5O_t H5O_t;
|
||||
/* ========= Object Creation properties ============ */
|
||||
#define H5O_CRT_ATTR_MAX_COMPACT_NAME "max compact attr" /* Max. # of attributes to store compactly */
|
||||
#define H5O_CRT_ATTR_MIN_DENSE_NAME "min dense attr" /* Min. # of attributes to store densely */
|
||||
#define H5O_CRT_OHDR_FLAGS_NAME "object header flags" /* Object header flags */
|
||||
|
||||
/* ========= Object Copy properties ============ */
|
||||
#define H5O_CPY_OPTION_NAME "copy object" /* Copy options */
|
||||
|
@ -466,7 +466,7 @@ done:
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Pget_creation_order_tracking
|
||||
* Function: H5Pget_link_creation_order
|
||||
*
|
||||
* Purpose: Returns the flag indicating that creation order is tracked
|
||||
* for links in a group.
|
||||
|
103
src/H5Pocpl.c
103
src/H5Pocpl.c
@ -49,6 +49,9 @@
|
||||
/* Definitions for the min. # of attributes to store densely */
|
||||
#define H5O_CRT_ATTR_MIN_DENSE_SIZE sizeof(unsigned)
|
||||
#define H5O_CRT_ATTR_MIN_DENSE_DEF 6
|
||||
/* Definitions for the min. # of attributes to store densely */
|
||||
#define H5O_CRT_OHDR_FLAGS_SIZE sizeof(unsigned)
|
||||
#define H5O_CRT_OHDR_FLAGS_DEF 0
|
||||
|
||||
|
||||
/******************/
|
||||
@ -117,6 +120,7 @@ H5P_ocrt_reg_prop(H5P_genclass_t *pclass)
|
||||
{
|
||||
unsigned attr_max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF; /* Default max. compact attribute storage settings */
|
||||
unsigned attr_min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF; /* Default min. dense attribute storage settings */
|
||||
unsigned ohdr_flags = H5O_CRT_OHDR_FLAGS_DEF; /* Default object header flag settings */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5P_ocrt_reg_prop)
|
||||
@ -131,6 +135,11 @@ H5P_ocrt_reg_prop(H5P_genclass_t *pclass)
|
||||
&attr_min_dense, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
|
||||
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
|
||||
|
||||
/* Register object header flags property */
|
||||
if(H5P_register(pclass, H5O_CRT_OHDR_FLAGS_NAME, H5O_CRT_OHDR_FLAGS_SIZE,
|
||||
&ohdr_flags, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
|
||||
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5P_ocrt_reg_prop() */
|
||||
@ -229,3 +238,97 @@ done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Pget_attr_phase_change() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Pset_attr_creation_order
|
||||
*
|
||||
* Purpose: Set the flags for creation order of attributes in a group
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* February 6, 2007
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags)
|
||||
{
|
||||
H5P_genplist_t *plist; /* Property list pointer */
|
||||
unsigned ohdr_flags; /* Object header flags */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_API(H5Pset_attr_creation_order, FAIL)
|
||||
H5TRACE2("e", "iIu", plist_id, crt_order_flags);
|
||||
|
||||
/* Check for bad combination of flags */
|
||||
if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED))
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index")
|
||||
|
||||
/* Get the plist structure */
|
||||
if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
|
||||
|
||||
/* Get object header flags */
|
||||
if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0)
|
||||
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags")
|
||||
|
||||
/* Mask off previous attribute creation order flag settings */
|
||||
ohdr_flags &= ~(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED);
|
||||
|
||||
/* Update with new attribute creation order flags */
|
||||
ohdr_flags |= (crt_order_flags & H5P_CRT_ORDER_TRACKED);
|
||||
ohdr_flags |= (crt_order_flags & H5P_CRT_ORDER_INDEXED);
|
||||
|
||||
/* Set object header flags */
|
||||
if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0)
|
||||
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Pset_attr_creation_order() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Pget_attr_creation_order
|
||||
*
|
||||
* Purpose: Returns the flag indicating that creation order is tracked
|
||||
* for attributes in a group.
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Ferbruary 6, 2007
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* return value */
|
||||
|
||||
FUNC_ENTER_API(H5Pget_attr_creation_order, FAIL)
|
||||
H5TRACE2("e", "ix", plist_id, crt_order_flags);
|
||||
|
||||
/* Get values */
|
||||
if(crt_order_flags) {
|
||||
H5P_genplist_t *plist; /* Property list pointer */
|
||||
unsigned ohdr_flags; /* Object header flags */
|
||||
|
||||
/* Reset the value to return */
|
||||
*crt_order_flags = 0;
|
||||
|
||||
/* Get the plist structure */
|
||||
if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
|
||||
|
||||
/* Get object header flags */
|
||||
if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0)
|
||||
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags")
|
||||
|
||||
/* Set creation order flags to return */
|
||||
*crt_order_flags = ohdr_flags & (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED);
|
||||
} /* end if */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Pget_attr_creation_order() */
|
||||
|
||||
|
@ -221,6 +221,8 @@ H5_DLL hid_t H5Pcopy(hid_t plist_id);
|
||||
/* Object creation property list (OCPL) routines */
|
||||
H5_DLL herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense);
|
||||
H5_DLL herr_t H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_dense);
|
||||
H5_DLL herr_t H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags);
|
||||
H5_DLL herr_t H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags);
|
||||
|
||||
/* File creation property list (FCPL) routines */
|
||||
H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot/*out*/,
|
||||
|
@ -2458,7 +2458,7 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
|
||||
int nprint = 0; /*number of paths shut down */
|
||||
int i; /*counter */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5T_unregister)
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_unregister)
|
||||
|
||||
/* Remove matching entries from the soft list */
|
||||
if(H5T_PERS_DONTCARE == pers || H5T_PERS_SOFT == pers) {
|
||||
|
Loading…
Reference in New Issue
Block a user