summaryrefslogtreecommitdiffstats
path: root/src/H5Abtree2.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-02-07 02:18:17 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-02-07 02:18:17 (GMT)
commitd47a0604451a975d3389ff510b6cad6507ea7200 (patch)
tree31b5cdd1319799a8bd26c3c59545020356f88ce2 /src/H5Abtree2.c
parent535d29a726e4faa7e58d4836e7099616105d6beb (diff)
downloadhdf5-d47a0604451a975d3389ff510b6cad6507ea7200.zip
hdf5-d47a0604451a975d3389ff510b6cad6507ea7200.tar.gz
hdf5-d47a0604451a975d3389ff510b6cad6507ea7200.tar.bz2
[svn-r13250] Description:
Add support for inserting attributes into creation order index. Also, update support for dense link & attribute storage in h5debug. Tested on: FreeBSD/32 6.2 (duty) Mac OS X/32 10.4.8 (amazon)
Diffstat (limited to 'src/H5Abtree2.c')
-rw-r--r--src/H5Abtree2.c239
1 files changed, 224 insertions, 15 deletions
diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c
index 14d7bb9..25abd92 100644
--- a/src/H5Abtree2.c
+++ b/src/H5Abtree2.c
@@ -77,6 +77,17 @@ typedef struct H5A_fh_ud_cmp_t {
/* v2 B-tree function callbacks */
+/* v2 B-tree driver callbacks for 'creation order' index */
+static herr_t H5A_dense_btree2_corder_store(void *native, const void *udata);
+static herr_t H5A_dense_btree2_corder_retrieve(void *udata, const void *native);
+static herr_t H5A_dense_btree2_corder_compare(const void *rec1, const void *rec2);
+static herr_t H5A_dense_btree2_corder_encode(const H5F_t *f, uint8_t *raw,
+ const void *native);
+static herr_t H5A_dense_btree2_corder_decode(const H5F_t *f, const uint8_t *raw,
+ void *native);
+static herr_t H5A_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id,
+ int indent, int fwidth, const void *record, const void *_udata);
+
/* v2 B-tree driver callbacks for 'name' index */
static herr_t H5A_dense_btree2_name_store(void *native, const void *udata);
static herr_t H5A_dense_btree2_name_retrieve(void *udata, const void *native);
@@ -95,7 +106,7 @@ static herr_t H5A_dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_da
/*********************/
/* Package Variables */
/*********************/
-/* v2 B-tree class for indexing 'name' field of links */
+/* v2 B-tree class for indexing 'name' field of attributes */
const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */
H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */
sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */
@@ -107,6 +118,18 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */
H5A_dense_btree2_name_debug /* Record debugging callback */
}};
+/* v2 B-tree class for indexing 'creation order' field of attributes */
+const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */
+ H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */
+ sizeof(H5A_dense_bt2_corder_rec_t),/* Size of native record */
+ H5A_dense_btree2_corder_store, /* Record storage callback */
+ H5A_dense_btree2_corder_retrieve, /* Record retrieval callback */
+ H5A_dense_btree2_corder_compare, /* Record comparison callback */
+ H5A_dense_btree2_corder_encode, /* Record encoding callback */
+ H5A_dense_btree2_corder_decode, /* Record decoding callback */
+ H5A_dense_btree2_corder_debug /* Record debugging callback */
+}};
+
/*****************************/
/* Library Private Variables */
@@ -142,7 +165,7 @@ H5A_dense_fh_name_cmp(const void *obj, size_t UNUSED obj_len, void *_udata)
FUNC_ENTER_NOAPI_NOINIT(H5A_dense_fh_name_cmp)
- /* Decode link information */
+ /* Decode attribute information */
if(NULL == (attr = (H5A_t *)H5O_msg_decode(udata->f, udata->dxpl_id, H5O_ATTR_ID, (const unsigned char *)obj)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "can't decode attribute")
@@ -155,6 +178,9 @@ H5A_dense_fh_name_cmp(const void *obj, size_t UNUSED obj_len, void *_udata)
if(udata->record->flags & H5O_MSG_FLAG_SHARED)
H5SM_reconstitute(&(attr->sh_loc), udata->record->id);
+ /* Set the creation order index for the attribute */
+ attr->crt_idx = udata->record->corder;
+
/* Make callback */
if((udata->found_op)(attr, udata->found_op_data) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPERATE, FAIL, "attribute found callback failed")
@@ -191,9 +217,10 @@ H5A_dense_btree2_name_store(void *_nrecord, const void *_udata)
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_name_store)
/* Copy user information info native record */
- nrecord->hash = udata->common.name_hash;
- nrecord->flags = udata->common.flags;
nrecord->id = udata->id;
+ nrecord->flags = udata->common.flags;
+ nrecord->corder = udata->common.corder;
+ nrecord->hash = udata->common.name_hash;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5A_dense_btree2_name_store() */
@@ -252,9 +279,9 @@ H5A_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec)
/* Check hash value */
if(bt2_udata->name_hash < bt2_rec->hash)
- HGOTO_DONE(-1)
+ ret_value = (-1);
else if(bt2_udata->name_hash > bt2_rec->hash)
- HGOTO_DONE(1)
+ ret_value = 1;
else {
H5A_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */
H5HF_t *fheap; /* Fractal heap handle to use for finding object */
@@ -282,15 +309,14 @@ H5A_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec)
fheap = bt2_udata->fheap;
HDassert(fheap);
- /* Check if the user's link and the B-tree's link have the same name */
+ /* Check if the user's attribute and the B-tree's attribute have the same name */
status = H5HF_op(fheap, bt2_udata->dxpl_id, &bt2_rec->id, H5A_dense_fh_name_cmp, &fh_udata);
HDassert(status >= 0);
/* Callback will set comparison value */
- HGOTO_DONE(fh_udata.cmp)
+ ret_value = fh_udata.cmp;
} /* end else */
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A_dense_btree2_name_compare() */
@@ -316,9 +342,10 @@ H5A_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_n
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_name_encode)
/* Encode the record's fields */
- UINT32ENCODE(raw, nrecord->hash)
- *raw++ = nrecord->flags;
UINT64ENCODE(raw, nrecord->id);
+ *raw++ = nrecord->flags;
+ UINT32ENCODE(raw, nrecord->corder)
+ UINT32ENCODE(raw, nrecord->hash)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5A_dense_btree2_name_encode() */
@@ -345,9 +372,10 @@ H5A_dense_btree2_name_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_n
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_name_decode)
/* Decode the record's fields */
- UINT32DECODE(raw, nrecord->hash)
- nrecord->flags = *raw++;
UINT64DECODE(raw, nrecord->id);
+ nrecord->flags = *raw++;
+ UINT32DECODE(raw, nrecord->corder)
+ UINT32DECODE(raw, nrecord->hash)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5A_dense_btree2_name_decode() */
@@ -374,9 +402,190 @@ H5A_dense_btree2_name_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dx
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_name_debug)
- HDfprintf(stream, "%*s%-*s {%lx, %Hx, %02x}", indent, "", fwidth, "Record:",
- nrecord->hash, nrecord->id, nrecord->flags);
+ HDfprintf(stream, "%*s%-*s {%016Hx, %02x, %u, %08lx}\n", indent, "", fwidth,
+ "Record:",
+ (hsize_t)nrecord->id, (unsigned)nrecord->flags, (unsigned)nrecord->corder, (unsigned long)nrecord->hash);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5A_dense_btree2_name_debug() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_dense_btree2_corder_store
+ *
+ * Purpose: Store user information into native record for v2 B-tree
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, February 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5A_dense_btree2_corder_store(void *_nrecord, const void *_udata)
+{
+ const H5A_bt2_ud_ins_t *udata = (const H5A_bt2_ud_ins_t *)_udata;
+ H5A_dense_bt2_corder_rec_t *nrecord = (H5A_dense_bt2_corder_rec_t *)_nrecord;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_corder_store)
+
+ /* Copy user information info native record */
+ nrecord->id = udata->id;
+ nrecord->flags = udata->common.flags;
+ nrecord->corder = udata->common.corder;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5A_dense_btree2_corder_store() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_dense_btree2_corder_retrieve
+ *
+ * Purpose: Retrieve native information from record for v2 B-tree
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, February 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5A_dense_btree2_corder_retrieve(void *udata, const void *nrecord)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_corder_retrieve)
+
+ *(H5A_dense_bt2_corder_rec_t *)udata = *(const H5A_dense_bt2_corder_rec_t *)nrecord;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5A_dense_btree2_corder_retrieve() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_dense_btree2_corder_compare
+ *
+ * Purpose: Compare two native information records, according to some key
+ *
+ * Return: <0 if rec1 < rec2
+ * =0 if rec1 == rec2
+ * >0 if rec1 > rec2
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, February 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5A_dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec)
+{
+ const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata;
+ const H5A_dense_bt2_corder_rec_t *bt2_rec = (const H5A_dense_bt2_corder_rec_t *)_bt2_rec;
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_corder_compare)
+
+ /* Sanity check */
+ HDassert(bt2_udata);
+ HDassert(bt2_rec);
+
+ /* Check creation order value */
+ if(bt2_udata->corder < bt2_rec->corder)
+ ret_value = -1;
+ else if(bt2_udata->corder > bt2_rec->corder)
+ ret_value = 1;
+ else
+ ret_value = 0;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5A_dense_btree2_corder_compare() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_dense_btree2_corder_encode
+ *
+ * Purpose: Encode native information into raw form for storing on disk
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, February 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5A_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord)
+{
+ const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_corder_encode)
+
+ /* Encode the record's fields */
+ UINT64ENCODE(raw, nrecord->id);
+ *raw++ = nrecord->flags;
+ UINT32ENCODE(raw, nrecord->corder)
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5A_dense_btree2_corder_encode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_dense_btree2_corder_decode
+ *
+ * Purpose: Decode raw disk form of record into native form
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, February 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5A_dense_btree2_corder_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord)
+{
+ H5A_dense_bt2_corder_rec_t *nrecord = (H5A_dense_bt2_corder_rec_t *)_nrecord;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_corder_decode)
+
+ /* Decode the record's fields */
+ UINT64DECODE(raw, nrecord->id);
+ nrecord->flags = *raw++;
+ UINT32DECODE(raw, nrecord->corder)
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5A_dense_btree2_corder_decode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_dense_btree2_corder_debug
+ *
+ * Purpose: Debug native form of record
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, February 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5A_dense_btree2_corder_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id,
+ int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata)
+{
+ const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_corder_debug)
+
+ HDfprintf(stream, "%*s%-*s {%016Hx, %02x, %u}\n", indent, "", fwidth,
+ "Record:",
+ (hsize_t)nrecord->id, (unsigned)nrecord->flags, (unsigned)nrecord->corder);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5A_dense_btree2_corder_debug() */
+