summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-10-02 21:46:39 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-10-02 21:46:39 (GMT)
commit84a4166e72abac9eb08a7daa3f67c90227641cda (patch)
treeef7159ea41f3f22ef049f0ddf240c561e09e26d0 /src
parent79aecf895393d2871764a9405c9698fd73225925 (diff)
downloadhdf5-84a4166e72abac9eb08a7daa3f67c90227641cda.zip
hdf5-84a4166e72abac9eb08a7daa3f67c90227641cda.tar.gz
hdf5-84a4166e72abac9eb08a7daa3f67c90227641cda.tar.bz2
[svn-r12707] Description:
Further minor modifications to the file format for tracking links in groups. This is tentatively the "final" file format for groups. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r--src/H5Glink.c40
-rw-r--r--src/H5Gprivate.h6
-rw-r--r--src/H5Oginfo.c46
-rw-r--r--src/H5Olinfo.c86
-rw-r--r--src/H5Oprivate.h6
5 files changed, 118 insertions, 66 deletions
diff --git a/src/H5Glink.c b/src/H5Glink.c
index ab9fdce..cc86edd 100644
--- a/src/H5Glink.c
+++ b/src/H5Glink.c
@@ -563,29 +563,29 @@ H5G_link_remove_cb(const void *_mesg, unsigned UNUSED idx, void *_udata)
if(HDstrcmp(lnk->name, udata->name) == 0) {
switch(lnk->type)
{
- case H5L_TYPE_HARD:
- {
- H5O_loc_t tmp_oloc; /* Temporary object location */
-
- /* Build temporary object location */
- tmp_oloc.file = udata->file;
- tmp_oloc.addr = lnk->u.hard.addr;
-
- /* Get the type of the object */
- /* Note: no way to check for error :-( */
- *(udata->obj_type) = H5O_obj_type(&tmp_oloc, udata->dxpl_id);
- }
- break;
+ case H5L_TYPE_HARD:
+ {
+ H5O_loc_t tmp_oloc; /* Temporary object location */
- case H5L_TYPE_SOFT:
- *(udata->obj_type) = H5G_LINK;
- break;
+ /* Build temporary object location */
+ tmp_oloc.file = udata->file;
+ tmp_oloc.addr = lnk->u.hard.addr;
+
+ /* Get the type of the object */
+ /* Note: no way to check for error :-( */
+ *(udata->obj_type) = H5O_obj_type(&tmp_oloc, udata->dxpl_id);
+ }
+ break;
+
+ case H5L_TYPE_SOFT:
+ *(udata->obj_type) = H5G_LINK;
+ break;
- default: /* User-defined link */
- if(lnk->type < H5L_TYPE_UD_MIN)
- HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type")
+ default: /* User-defined link */
+ if(lnk->type < H5L_TYPE_UD_MIN)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type")
- *(udata->obj_type) = H5G_UDLINK;
+ *(udata->obj_type) = H5G_UDLINK;
}
/* Stop the iteration, we found the correct link */
HGOTO_DONE(H5O_ITER_STOP)
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index e1379c5..cb075fa 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -59,13 +59,15 @@
/* ========= Group Creation properties ============ */
/* Defaults for link info values */
+#define H5G_CRT_LINFO_INDEX_CORDER FALSE
#define H5G_CRT_LINFO_NLINKS 0
#define H5G_CRT_LINFO_MIN_CORDER 0
#define H5G_CRT_LINFO_MAX_CORDER 0
#define H5G_CRT_LINFO_LINK_FHEAP_ADDR HADDR_UNDEF
#define H5G_CRT_LINFO_NAME_BT2_ADDR HADDR_UNDEF
#define H5G_CRT_LINFO_CORDER_BT2_ADDR HADDR_UNDEF
-#define H5G_CRT_LINK_INFO_DEF {H5G_CRT_LINFO_NLINKS, \
+#define H5G_CRT_LINK_INFO_DEF {H5G_CRT_LINFO_INDEX_CORDER, \
+ H5G_CRT_LINFO_NLINKS, \
H5G_CRT_LINFO_MIN_CORDER, \
H5G_CRT_LINFO_MAX_CORDER, \
H5G_CRT_LINFO_LINK_FHEAP_ADDR, \
@@ -75,7 +77,6 @@
/* Defaults for group info values */
#define H5G_CRT_GINFO_LHEAP_SIZE_HINT 0
#define H5G_CRT_GINFO_TRACK_CORDER FALSE
-#define H5G_CRT_GINFO_INDEX_CORDER FALSE
#define H5G_CRT_GINFO_MAX_COMPACT 8
#define H5G_CRT_GINFO_MIN_DENSE 6
#define H5G_CRT_GINFO_EST_NUM_ENTRIES 4
@@ -86,7 +87,6 @@
#define H5G_CRT_GROUP_INFO_SIZE sizeof(H5O_ginfo_t)
#define H5G_CRT_GROUP_INFO_DEF {H5G_CRT_GINFO_LHEAP_SIZE_HINT, \
H5G_CRT_GINFO_TRACK_CORDER, \
- H5G_CRT_GINFO_INDEX_CORDER, \
H5G_CRT_GINFO_MAX_COMPACT, \
H5G_CRT_GINFO_MIN_DENSE, \
H5G_CRT_GINFO_EST_NUM_ENTRIES, \
diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c
index 54caa35..7ca79df 100644
--- a/src/H5Oginfo.c
+++ b/src/H5Oginfo.c
@@ -66,9 +66,9 @@ const H5O_msg_class_t H5O_MSG_GINFO[1] = {{
/* Current version of group info information */
#define H5O_GINFO_VERSION 1
-/* Flags for group flag encoding */
-#define H5O_GINFO_FLAG_TRACK_CORDER 0x01
-#define H5O_GINFO_FLAG_INDEX_CORDER 0x02
+/* Flags for group info flag encoding */
+#define H5O_GINFO_FLAG_TRACK_NAME 0x01
+#define H5O_GINFO_FLAG_TRACK_CORDER 0x02
/* Declare a free list to manage the H5O_ginfo_t struct */
H5FL_DEFINE_STATIC(H5O_ginfo_t);
@@ -104,6 +104,11 @@ H5O_ginfo_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
/* check args */
HDassert(p);
+#ifndef NDEBUG
+{
+ const uint8_t *start_p = p;
+#endif /* NDEBUG */
+
/* Version of message */
if(*p++ != H5O_GINFO_VERSION)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message")
@@ -114,8 +119,8 @@ H5O_ginfo_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
/* Get the flags for the group */
flags = *p++;
+ HDassert(flags & H5O_GINFO_FLAG_TRACK_NAME);
ginfo->track_corder = (flags & H5O_GINFO_FLAG_TRACK_CORDER) ? TRUE : FALSE;
- ginfo->index_corder = (flags & H5O_GINFO_FLAG_INDEX_CORDER) ? TRUE : FALSE;
/* Get the max. # of links to store compactly & the min. # of links to store densely */
UINT32DECODE(p, ginfo->max_compact)
@@ -125,8 +130,13 @@ H5O_ginfo_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
UINT32DECODE(p, ginfo->est_num_entries)
UINT32DECODE(p, ginfo->est_name_len)
+#ifndef NDEBUG
+ HDassert((size_t)(p - start_p) == H5O_ginfo_size(f, ginfo));
+}
+#endif /* NDEBUG */
+
/* Set return value */
- ret_value=ginfo;
+ ret_value = ginfo;
done:
if(ret_value == NULL)
@@ -164,12 +174,17 @@ H5O_ginfo_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
HDassert(p);
HDassert(ginfo);
- /* encode */
+#ifndef NDEBUG
+{
+ uint8_t *start_p = p;
+#endif /* NDEBUG */
+
+ /* Message version */
*p++ = H5O_GINFO_VERSION;
- /* The flags for the group */
- flags = ginfo->track_corder ? H5O_GINFO_FLAG_TRACK_CORDER : 0;
- flags |= ginfo->index_corder ? H5O_GINFO_FLAG_INDEX_CORDER : 0;
+ /* The flags for the group info */
+ flags = H5O_GINFO_FLAG_TRACK_NAME; /* Names are always tracked */
+ flags |= ginfo->track_corder ? H5O_GINFO_FLAG_TRACK_CORDER : 0;
*p++ = flags;
/* Store the max. # of links to store compactly & the min. # of links to store densely */
@@ -180,6 +195,11 @@ H5O_ginfo_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
UINT32ENCODE(p, ginfo->est_num_entries)
UINT32ENCODE(p, ginfo->est_name_len)
+#ifndef NDEBUG
+ HDassert((size_t)(p - start_p) == H5O_ginfo_size(f, ginfo));
+}
+#endif /* NDEBUG */
+
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_ginfo_encode() */
@@ -205,8 +225,8 @@ H5O_ginfo_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
static void *
H5O_ginfo_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags)
{
- const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *) _mesg;
- H5O_ginfo_t *dest = (H5O_ginfo_t *) _dest;
+ const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg;
+ H5O_ginfo_t *dest = (H5O_ginfo_t *)_dest;
void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_ginfo_copy)
@@ -220,7 +240,7 @@ H5O_ginfo_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags)
*dest = *ginfo;
/* Set return value */
- ret_value=dest;
+ ret_value = dest;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -324,8 +344,6 @@ H5O_ginfo_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *
HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth,
"Track creation order of links:", ginfo->track_corder);
- HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth,
- "Index creation order of links:", ginfo->index_corder);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"Max. compact links:", ginfo->max_compact);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c
index 57a230f..bac8200 100644
--- a/src/H5Olinfo.c
+++ b/src/H5Olinfo.c
@@ -73,6 +73,10 @@ const H5O_msg_class_t H5O_MSG_LINFO[1] = {{
/* Current version of link info information */
#define H5O_LINFO_VERSION 1
+/* Flags for link info index flag encoding */
+#define H5O_LINFO_INDEX_NAME 0x01
+#define H5O_LINFO_INDEX_CORDER 0x02
+
/* Data exchange structure to use when copying links from src to dst */
typedef struct {
const H5O_loc_t *src_oloc; /* Source object location */
@@ -100,13 +104,12 @@ H5FL_DEFINE_STATIC(H5O_linfo_t);
* koziol@ncsa.uiuc.edu
* Aug 23 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
H5O_linfo_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
+ unsigned char index_flags; /* Flags for encoding link index info */
H5O_linfo_t *linfo = NULL; /* Link info */
void *ret_value; /* Return value */
@@ -116,14 +119,24 @@ H5O_linfo_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
HDassert(f);
HDassert(p);
- /* decode */
+#ifndef NDEBUG
+{
+ const uint8_t *start_p = p;
+#endif /* NDEBUG */
+
+ /* Version of message */
if(*p++ != H5O_LINFO_VERSION)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message")
/* Allocate space for message */
- if (NULL == (linfo = H5FL_MALLOC(H5O_linfo_t)))
+ if(NULL == (linfo = H5FL_MALLOC(H5O_linfo_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ /* Get the index flags for the group */
+ index_flags = *p++;
+ HDassert(index_flags & H5O_LINFO_INDEX_NAME);
+ linfo->index_corder = (index_flags & H5O_LINFO_INDEX_CORDER) ? TRUE : FALSE;
+
/* Number of links in the group */
H5F_DECODE_LENGTH(f, p, linfo->nlinks)
@@ -134,11 +147,19 @@ H5O_linfo_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
/* Address of fractal heap to store "dense" links */
H5F_addr_decode(f, &p, &(linfo->link_fheap_addr));
- /* Address of v2 B-tree to index names of links */
+ /* Address of v2 B-tree to index names of links (names are always indexed) */
H5F_addr_decode(f, &p, &(linfo->name_bt2_addr));
- /* Address of v2 B-tree to index creation order of links */
- H5F_addr_decode(f, &p, &(linfo->corder_bt2_addr));
+ /* Address of v2 B-tree to index creation order of links, if there is one */
+ if(linfo->index_corder)
+ H5F_addr_decode(f, &p, &(linfo->corder_bt2_addr));
+ else
+ linfo->corder_bt2_addr = HADDR_UNDEF;
+
+#ifndef NDEBUG
+ HDassert((size_t)(p - start_p) == H5O_linfo_size(f, linfo));
+}
+#endif /* NDEBUG */
/* Set return value */
ret_value = linfo;
@@ -163,14 +184,13 @@ done:
* koziol@ncsa.uiuc.edu
* Aug 23 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
H5O_linfo_encode(H5F_t *f, uint8_t *p, const void *_mesg)
{
- const H5O_linfo_t *linfo = (const H5O_linfo_t *) _mesg;
+ const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg;
+ unsigned char index_flags; /* Flags for encoding link index info */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_linfo_encode)
@@ -179,9 +199,19 @@ H5O_linfo_encode(H5F_t *f, uint8_t *p, const void *_mesg)
HDassert(p);
HDassert(linfo);
- /* encode */
+#ifndef NDEBUG
+{
+ uint8_t *start_p = p;
+#endif /* NDEBUG */
+
+ /* Message version */
*p++ = H5O_LINFO_VERSION;
+ /* The flags for the link indices */
+ index_flags = H5O_LINFO_INDEX_NAME; /* Names are always indexed */
+ index_flags |= linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0;
+ *p++ = index_flags;
+
/* Number of links in the group */
H5F_ENCODE_LENGTH(f, p, linfo->nlinks)
@@ -195,8 +225,16 @@ H5O_linfo_encode(H5F_t *f, uint8_t *p, const void *_mesg)
/* Address of v2 B-tree to index names of links */
H5F_addr_encode(f, &p, linfo->name_bt2_addr);
- /* Address of v2 B-tree to index creation order of links */
- H5F_addr_encode(f, &p, linfo->corder_bt2_addr);
+ /* Address of v2 B-tree to index creation order of links, if they are indexed */
+ if(linfo->index_corder)
+ H5F_addr_encode(f, &p, linfo->corder_bt2_addr);
+ else
+ HDassert(!H5F_addr_defined(linfo->corder_bt2_addr));
+
+#ifndef NDEBUG
+ HDassert((size_t)(p - start_p) == H5O_linfo_size(f, linfo));
+}
+#endif /* NDEBUG */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_linfo_encode() */
@@ -216,14 +254,12 @@ H5O_linfo_encode(H5F_t *f, uint8_t *p, const void *_mesg)
* koziol@ncsa.uiuc.edu
* Aug 23 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
H5O_linfo_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags)
{
- const H5O_linfo_t *linfo = (const H5O_linfo_t *) _mesg;
+ const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg;
H5O_linfo_t *dest = (H5O_linfo_t *) _dest;
void *ret_value; /* Return value */
@@ -260,25 +296,25 @@ done:
* koziol@ncsa.uiuc.edu
* Aug 23 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static size_t
-H5O_linfo_size(const H5F_t *f, const void UNUSED *_mesg)
+H5O_linfo_size(const H5F_t *f, const void *_mesg)
{
+ const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg;
size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_linfo_size)
/* Set return value */
ret_value = 1 /* Version */
+ + 1 /* Index flags */
+ H5F_SIZEOF_SIZE(f) /* Number of links */
- + 8 /* Min. creation order value */
- + 8 /* Max. creation order value */
+ + 8 /* Curr. min. creation order value */
+ + 8 /* Curr. max. creation order value */
+ H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */
+ H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */
- + H5F_SIZEOF_ADDR(f); /* Address of v2 B-tree for indexing creation order values of links */
+ + (linfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of links */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_linfo_size() */
@@ -294,8 +330,6 @@ H5O_linfo_size(const H5F_t *f, const void UNUSED *_mesg)
* Programmer: Quincey Koziol
* Tuesday, August 23, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -530,8 +564,6 @@ done:
* koziol@ncsa.uiuc.edu
* Aug 23 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -549,6 +581,8 @@ H5O_linfo_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *
HDassert(indent >= 0);
HDassert(fwidth >= 0);
+ HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth,
+ "Index creation order of links:", linfo->index_corder);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
"Number of links:", linfo->nlinks);
HDfprintf(stream, "%*s%-*s %Hd\n", indent, "", fwidth,
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index ead851e..fd226f1 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -108,9 +108,10 @@ typedef struct H5O_copy_t {
* (Data structure in memory)
*/
typedef struct H5O_linfo_t {
+ hbool_t index_corder; /* Are creation order values indexed on links? */
hsize_t nlinks; /* Number of links in the group */
- int64_t min_corder; /* Min. creation order value for group */
- int64_t max_corder; /* Max. creation order value for group */
+ int64_t min_corder; /* Current min. creation order value for group */
+ int64_t max_corder; /* Current max. creation order value for group */
haddr_t link_fheap_addr; /* Address of fractal heap for storing "dense" links */
haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of links */
haddr_t corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of links */
@@ -252,7 +253,6 @@ typedef struct H5O_ginfo_t {
/* "New" format group info (stored) */
hbool_t track_corder; /* Are creation order values tracked on links? */
- hbool_t index_corder; /* Are creation order values indexed on links? */
uint32_t max_compact; /* Maximum # of compact links */
uint32_t min_dense; /* Minimum # of "dense" links */
uint32_t est_num_entries; /* Estimated # of entries in group */