summaryrefslogtreecommitdiffstats
path: root/src/H5Distore.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-11-14 14:42:14 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-11-14 14:42:14 (GMT)
commitcdeeb5553a3920565d87201761dadd1fe32aa3b1 (patch)
treea209c61f85983c1a76bf5c65d1f3285c4861ec46 /src/H5Distore.c
parent73897627660169de753597b9ff045d3112646506 (diff)
downloadhdf5-cdeeb5553a3920565d87201761dadd1fe32aa3b1.zip
hdf5-cdeeb5553a3920565d87201761dadd1fe32aa3b1.tar.gz
hdf5-cdeeb5553a3920565d87201761dadd1fe32aa3b1.tar.bz2
[svn-r136] ./MANIFEST
./src/Makefile.in Added H5Ffamily.c and H5Fsplit.c ./src/H5B.c ./src/H5Bprivate.h ./src/H5Gnode.c Added `const' to sublass arguments. ./src/H5F.c ./src/H5Flow.c ./src/H5Fsec2.c Make sure file buffers get flushed during a call to H5Fflush(). Check for overflow in address encoding and decoding. ./src/H5Ffam.c ./src/H5Fprivate.c ./test/istore.c Implementation of file families so 32-bit machines can access 64-bit files. ./src/H5Oprivate.h Removed H5O_NO_ADDR constant. ./config/freebsd2.2.1 ./config/linux Added -DH5G_DEBUG and -DH5F_DEBUG to the list of debugging flags. ./html/H5.format.html Changed some <offset>-sized things to <length>-sized things. ./src/H5AC.c ./src/H5ACprivate.h ./src/H5B.c ./src/H5Bprivate.h ./src/H5C.c ./src/H5D.c ./src/H5F.c ./src/H5Fcore.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fprivate.h ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5Gpkg.h ./src/H5Gprivate.h ./src/H5Gshad.c ./src/H5Gstab.c ./src/H5H.c ./src/H5Hprivate.h ./src/H5MF.c ./src/H5MFprivate.h ./src/H5O.c ./src/H5Ocont.c ./src/H5Oistore.c ./src/H5Oprivate.h ./src/H5Ostab.c ./src/H5Ostdst.c ./src/H5pivate.h ./src/debug.c ./test/istore.c ./test/theap.c ./test/tohdr.c ./test/tstab.c Lots of changes caused by generalizing addresses. The haddr_t is now a struct, so you can no longer perform arithmetic on it. But since it's small, simple, and often used, storage is allocated like with an integer. But we always pass them around by reference. That is, when using an address in another struct, allocate space: struct my_struct { char *name; haddr_t address; } x; But when passing it to a function, pass by reference: H5F_addr_print (stderr, &(x.address)); Addresses should be initialized with H5F_addr_undef (&(x.address)); Functions for operating on addresses are in H5Flow.c and begin with H5F_addr_... Functions never return haddr_t or haddr_t*; they always pass them through arguments instead. A function that returns an address through an argument does so with its last argument and it is marked with `/*out*/'. Calls to such functions also mark output-only arguments with `/*out*/' ./src/H5Fsplit.c (new) A two-member family where all meta data goes in the first member and all raw data goes in the second member. ./src/H5B.c ./src/H5D.c ./src/H5F.c ./src/H5Ffamily.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fprivate.h ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5Gnode.c ./src/H5H.c ./src/H5MF.c ./src/H5MFprivate.h ./src/H5O.c Differentiate between meta data storage and raw data storage. Provide a mechanism so that the file driver can extend the file to allocate more memory. ./src/H5E.c ./src/H5Epublic.c Added the error H5E_TRUNCATED to be reported when the file is shorter than the length recorded in the boot block. ./src/H5F.c Added H5F_locate_signature() so we only do it in one place now. ./INSTALL ./INSTALL_MAINT Just a couple clarifications. ./html/ExternalFiles.html ./html/storage.html Documents how external files work. ./test/hyperslab.c ./test/istore.c Fixed printf's on 64-bit machines. ./test/istore.c Added ifdef's to test the split file driver.
Diffstat (limited to 'src/H5Distore.c')
-rw-r--r--src/H5Distore.c92
1 files changed, 49 insertions, 43 deletions
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 06997a1..b997945 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 1997 Spizella Software
+ * Copyright (C) 1997 NCSA
* All rights reserved.
*
- * Programmer: Robb Matzke <robb@arborea.spizella.com>
+ * Programmer: Robb Matzke <matzke@llnl.gov>
* Wednesday, October 8, 1997
*/
#include <H5private.h>
@@ -29,18 +29,20 @@ static hbool_t interface_initialize_g = FALSE;
/* PRIVATE PROTOTYPES */
static size_t H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata);
-static haddr_t H5F_istore_new_node (H5F_t *f, H5B_ins_t, void *_lt_key,
- void *_udata, void *_rt_key);
+static herr_t H5F_istore_new_node (H5F_t *f, H5B_ins_t, void *_lt_key,
+ void *_udata, void *_rt_key, haddr_t*);
static intn H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata,
void *_rt_key);
static intn H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata,
void *_rt_key);
-static herr_t H5F_istore_found (H5F_t *f, haddr_t addr, const void *_lt_key,
- void *_udata, const void *_rt_key);
-static haddr_t H5F_istore_insert (H5F_t *f, haddr_t addr, H5B_ins_t *anchor,
- void *_lt_key, hbool_t *lt_key_changed,
- void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed);
+static herr_t H5F_istore_found (H5F_t *f, const haddr_t *addr,
+ const void *_lt_key, void *_udata,
+ const void *_rt_key);
+static H5B_ins_t H5F_istore_insert (H5F_t *f, const haddr_t *addr,
+ void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata,
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t*);
static herr_t H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
void *_key);
static herr_t H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
@@ -317,8 +319,9 @@ H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
* the domain represented by UDATA doesn't intersect the domain
* already represented by the B-tree.
*
- * Return: Success: Address of leaf, which is passed in from the
- * UDATA pointer.
+ * Return: Success: SUCCEED. The address of leaf is returned
+ * through the ADDR argument. It is also added
+ * to the UDATA.
*
* Failure: FAIL
*
@@ -329,9 +332,10 @@ H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
*
*-------------------------------------------------------------------------
*/
-static haddr_t
+static herr_t
H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
- void *_lt_key, void *_udata, void *_rt_key)
+ void *_lt_key, void *_udata, void *_rt_key,
+ haddr_t *addr/*out*/)
{
H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
@@ -347,14 +351,16 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
assert (rt_key);
assert (udata);
assert (udata->mesg.ndims>=0 && udata->mesg.ndims<H5O_ISTORE_NDIMS);
+ assert (addr);
/* Allocate new storage */
nbytes = H5V_vector_reduce_product (udata->mesg.ndims, udata->key.size);
assert (nbytes>0);
- if ((udata->addr=H5MF_alloc (f, nbytes))<0) {
+ if (H5MF_alloc (f, H5MF_RAW, nbytes, addr/*out*/)<0) {
/* Couldn't allocate new file storage */
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL);
}
+ udata->addr = *addr;
/* Initialize the key(s) */
for (i=0; i<udata->mesg.ndims; i++) {
@@ -376,7 +382,7 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
}
}
- FUNC_LEAVE (udata->addr);
+ FUNC_LEAVE (SUCCEED);
}
@@ -403,7 +409,7 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_found (H5F_t *f, haddr_t addr, const void *_lt_key,
+H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
void *_udata, const void *_rt_key)
{
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
@@ -414,12 +420,12 @@ H5F_istore_found (H5F_t *f, haddr_t addr, const void *_lt_key,
/* Check arguments */
assert (f);
- assert (addr>=0);
+ assert (addr && H5F_addr_defined (addr));
assert (udata);
assert (lt_key);
/* Initialize return values */
- udata->addr = addr;
+ udata->addr = *addr;
for (i=0; i<udata->mesg.ndims; i++) {
udata->key.offset[i] = lt_key->offset[i];
udata->key.size[i] = lt_key->size[i];
@@ -447,13 +453,12 @@ H5F_istore_found (H5F_t *f, haddr_t addr, const void *_lt_key,
* `offset' and `size' fields). On return, UDATA describes the
* logical addresses contained in a chunk on disk.
*
- * Return: Success: SUCCEED, with UDATA containing information
- * about the (newly allocated) chunk.
+ * Return: Success: An insertion command for the caller, one of
+ * the H5B_INS_* constants. The address of the
+ * new chunk is returned through the NEW_NODE
+ * argument.
*
- * If the storage address has changed then the
- * new address is returned.
- *
- * Failure: FAIL
+ * Failure: H5B_INS_ERROR
*
* Programmer: Robb Matzke
* Thursday, October 9, 1997
@@ -462,32 +467,33 @@ H5F_istore_found (H5F_t *f, haddr_t addr, const void *_lt_key,
*
*-------------------------------------------------------------------------
*/
-static haddr_t
-H5F_istore_insert (H5F_t *f, haddr_t addr, H5B_ins_t *parent_ins,
+static H5B_ins_t
+H5F_istore_insert (H5F_t *f, const haddr_t *addr,
void *_lt_key, hbool_t *lt_key_changed,
void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed)
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t *new_node/*out*/)
{
H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
H5F_istore_key_t *md_key = (H5F_istore_key_t *)_md_key;
H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
intn i, cmp;
- haddr_t ret_value = 0;
+ H5B_ins_t ret_value = H5B_INS_ERROR;
size_t nbytes;
FUNC_ENTER (H5F_istore_insert, NULL, FAIL);
/* check args */
assert (f);
- assert (addr>=0);
- assert (parent_ins);
+ assert (addr && H5F_addr_defined (addr));
assert (lt_key);
assert (lt_key_changed);
assert (md_key);
assert (udata);
assert (rt_key);
assert (rt_key_changed);
+ assert (new_node);
cmp = H5F_istore_cmp3 (f, lt_key, udata, rt_key);
assert (cmp<=0);
@@ -503,8 +509,8 @@ H5F_istore_insert (H5F_t *f, haddr_t addr, H5B_ins_t *parent_ins,
/*
* Already exists. Just return the info.
*/
- udata->addr = addr;
- *parent_ins = H5B_INS_NOOP;
+ udata->addr = *addr;
+ ret_value = H5B_INS_NOOP;
} else if (H5V_hyper_disjointp (udata->mesg.ndims,
lt_key->offset, lt_key->size,
@@ -528,11 +534,11 @@ H5F_istore_insert (H5F_t *f, haddr_t addr, H5B_ins_t *parent_ins,
/*
* Allocate storage for the new chunk
*/
- if ((udata->addr=ret_value=H5MF_alloc (f, nbytes))<=0) {
+ if (H5MF_alloc (f, H5MF_RAW, nbytes, new_node/*out*/)<0) {
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL);
}
-
- *parent_ins = H5B_INS_RIGHT;
+ udata->addr = *new_node;
+ ret_value = H5B_INS_RIGHT;
} else {
assert ("HDF5 INTERNAL ERROR -- see rpm" && 0);
@@ -599,7 +605,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
/* check args */
assert (f);
assert (istore);
- assert (istore->btree_addr>0);
+ assert (H5F_addr_defined (&(istore->btree_addr)));
assert (istore->ndims>0 && istore->ndims<=H5O_ISTORE_NDIMS);
assert (H5F_ISTORE_READ==op || H5F_ISTORE_WRITE==op);
assert (size);
@@ -659,10 +665,10 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
}
if (H5F_ISTORE_WRITE==op) {
- status = H5B_insert (f, H5B_ISTORE, istore->btree_addr, &udata);
+ status = H5B_insert (f, H5B_ISTORE, &(istore->btree_addr), &udata);
assert (status>=0);
} else {
- status = H5B_find (f, H5B_ISTORE, istore->btree_addr, &udata);
+ status = H5B_find (f, H5B_ISTORE, &(istore->btree_addr), &udata);
}
/*
@@ -672,8 +678,8 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
if (H5F_ISTORE_READ==op ||
!H5V_vector_zerop (istore->ndims, offset_wrt_chunk) ||
!H5V_vector_eq (istore->ndims, sub_size, udata.key.size)) {
- if (status>=0 && udata.addr>0) {
- if (H5F_block_read (f, udata.addr, chunk_size, chunk)<0) {
+ if (status>=0 && H5F_addr_defined (&(udata.addr))) {
+ if (H5F_block_read (f, &(udata.addr), chunk_size, chunk)<0) {
HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL);
}
} else {
@@ -686,7 +692,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
H5V_hyper_copy (istore->ndims, sub_size,
udata.key.size, offset_wrt_chunk, chunk,
size_m, sub_offset_m, buf);
- if (H5F_block_write (f, udata.addr, chunk_size, chunk)<0) {
+ if (H5F_block_write (f, &(udata.addr), chunk_size, chunk)<0) {
HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL);
}
} else {
@@ -835,7 +841,7 @@ H5F_istore_new (H5F_t *f, struct H5O_istore_t *istore,
#endif
udata.mesg.ndims = istore->ndims = ndims;
- if ((istore->btree_addr=H5B_new (f, H5B_ISTORE, &udata))<0) {
+ if (H5B_new (f, H5B_ISTORE, &udata, &(istore->btree_addr)/*out*/)<0) {
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL); /* Can't create B-tree */
}