summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-02-27 03:46:46 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-02-27 03:46:46 (GMT)
commit3713db1174ff83154ff63f93b4ba512eebed9748 (patch)
tree957c509d716679b29fb84496741724bc161d8bbb
parent3e8948df52ce165edd3238a7e2ae3b047eac7836 (diff)
downloadhdf5-3713db1174ff83154ff63f93b4ba512eebed9748.zip
hdf5-3713db1174ff83154ff63f93b4ba512eebed9748.tar.gz
hdf5-3713db1174ff83154ff63f93b4ba512eebed9748.tar.bz2
[svn-r11967] Purpose:
New feature Description: Check in initial "fractal heap" code, for supporting the group redesign. Also, remove some remnants of the segmented heap/block tracker/B+tree code which I didn't find during the last pass. Platforms tested: FreeBSD 4.11 (sleipnir) Mac OSX (amazon) Linux 2.4
-rw-r--r--MANIFEST8
-rw-r--r--src/H5AC.c1
-rw-r--r--src/H5ACprivate.h1
-rw-r--r--src/H5Cpkg.h2
-rw-r--r--src/H5Edefin.h4
-rw-r--r--src/H5Einit.h12
-rw-r--r--src/H5Epubgen.h6
-rw-r--r--src/H5Eterm.h4
-rw-r--r--src/H5FDpublic.h25
-rw-r--r--src/H5HF.c271
-rw-r--r--src/H5HFcache.c364
-rw-r--r--src/H5HFdbg.c129
-rw-r--r--src/H5HFpkg.h155
-rw-r--r--src/H5HFprivate.h65
-rw-r--r--src/H5HFpublic.h53
-rw-r--r--src/H5HFtest.c112
-rw-r--r--src/H5err.txt5
-rwxr-xr-xsrc/Makefile.am3
-rw-r--r--src/Makefile.in38
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in66
-rw-r--r--test/fheap.c251
-rw-r--r--tools/misc/h5debug.c72
23 files changed, 1528 insertions, 123 deletions
diff --git a/MANIFEST b/MANIFEST
index 4cbd067..a517fdb 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -492,6 +492,13 @@
./src/H5Gstab.c
./src/H5Gtest.c
./src/H5Gtraverse.c
+./src/H5HF.c
+./src/H5HFcache.c
+./src/H5HFdbg.c
+./src/H5HFpkg.h
+./src/H5HFprivate.h
+./src/H5HFpublic.h
+./src/H5HFtest.c
./src/H5HG.c
./src/H5HGdbg.c
./src/H5HGpkg.h
@@ -641,6 +648,7 @@
./test/family_v1.6_00001.h5
./test/family_v1.6_00002.h5
./test/family_v1.6_00003.h5
+./test/fheap.c
./test/fill_old.h5
./test/fillval.c
./test/flush1.c
diff --git a/src/H5AC.c b/src/H5AC.c
index aeb78b6..2d10b03 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -742,6 +742,7 @@ static const char * H5AC_entry_type_names[H5AC_NTYPES] =
"v2 B-tree headers",
"v2 B-tree internal nodes",
"v2 B-tree leaf nodes",
+ "fractal heap headers",
"test entry" /* for testing only -- not used for actual files */
};
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 8f30c28..9817a4a 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -50,6 +50,7 @@ typedef enum {
H5AC_BT2_INT_ID, /*v2 B-tree internal node */
H5AC_BT2_LEAF_ID, /*v2 B-tree leaf node */
H5AC_TEST_ID, /*test entry -- not used for actual files */
+ H5AC_FHEAP_HDR_ID, /*fractal heap header */
H5AC_NTYPES /* Number of types, must be last */
} H5AC_type_t;
diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h
index 3e2c049..7ee4647 100644
--- a/src/H5Cpkg.h
+++ b/src/H5Cpkg.h
@@ -609,7 +609,7 @@
****************************************************************************/
#define H5C__H5C_T_MAGIC 0x005CAC0E
-#define H5C__MAX_NUM_TYPE_IDS 9
+#define H5C__MAX_NUM_TYPE_IDS 10
#define H5C__PREFIX_LEN 32
struct H5C_t
diff --git a/src/H5Edefin.h b/src/H5Edefin.h
index 12582f4..82a74b8 100644
--- a/src/H5Edefin.h
+++ b/src/H5Edefin.h
@@ -40,7 +40,6 @@ hid_t H5E_OHDR_g = FAIL; /* Object header */
hid_t H5E_ATOM_g = FAIL; /* Object atom */
hid_t H5E_ATTR_g = FAIL; /* Attribute */
hid_t H5E_IO_g = FAIL; /* Low-level I/O */
-hid_t H5E_BLKTRK_g = FAIL; /* Block tracker */
hid_t H5E_SLIST_g = FAIL; /* Skip Lists */
hid_t H5E_EFL_g = FAIL; /* External file list */
hid_t H5E_TST_g = FAIL; /* Ternary Search Trees */
@@ -150,9 +149,6 @@ hid_t H5E_CANTUNPROTECT_g = FAIL; /* Unable to unprotect metadata */
hid_t H5E_MPI_g = FAIL; /* Some MPI function failed */
hid_t H5E_MPIERRSTR_g = FAIL; /* MPI Error String */
-/* Block tracker errors */
-hid_t H5E_OVERLAPS_g = FAIL; /* Blocks overlap */
-
/* Dataspace errors */
hid_t H5E_CANTCLIP_g = FAIL; /* Can't clip hyperslab region */
hid_t H5E_CANTCOUNT_g = FAIL; /* Can't count elements */
diff --git a/src/H5Einit.h b/src/H5Einit.h
index bf31088..b2a4563 100644
--- a/src/H5Einit.h
+++ b/src/H5Einit.h
@@ -123,11 +123,6 @@ if((msg = H5E_create_msg(cls, H5E_MAJOR, "Low-level I/O"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_IO_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
-assert(H5E_BLKTRK_g==(-1));
-if((msg = H5E_create_msg(cls, H5E_MAJOR, "Block tracker"))==NULL)
- HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
-if((H5E_BLKTRK_g = H5I_register(H5I_ERROR_MSG, msg))<0)
- HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_SLIST_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MAJOR, "Skip Lists"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
@@ -552,13 +547,6 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "MPI Error String"))==NULL)
if((H5E_MPIERRSTR_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
-/* Block tracker errors */
-assert(H5E_OVERLAPS_g==(-1));
-if((msg = H5E_create_msg(cls, H5E_MINOR, "Blocks overlap"))==NULL)
- HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
-if((H5E_OVERLAPS_g = H5I_register(H5I_ERROR_MSG, msg))<0)
- HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
-
/* Dataspace errors */
assert(H5E_CANTCLIP_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't clip hyperslab region"))==NULL)
diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h
index 4245a5c..c846a67 100644
--- a/src/H5Epubgen.h
+++ b/src/H5Epubgen.h
@@ -43,7 +43,6 @@
#define H5E_ATOM (H5OPEN H5E_ATOM_g)
#define H5E_ATTR (H5OPEN H5E_ATTR_g)
#define H5E_IO (H5OPEN H5E_IO_g)
-#define H5E_BLKTRK (H5OPEN H5E_BLKTRK_g)
#define H5E_SLIST (H5OPEN H5E_SLIST_g)
#define H5E_EFL (H5OPEN H5E_EFL_g)
#define H5E_TST (H5OPEN H5E_TST_g)
@@ -71,7 +70,6 @@ H5_DLLVAR hid_t H5E_OHDR_g; /* Object header */
H5_DLLVAR hid_t H5E_ATOM_g; /* Object atom */
H5_DLLVAR hid_t H5E_ATTR_g; /* Attribute */
H5_DLLVAR hid_t H5E_IO_g; /* Low-level I/O */
-H5_DLLVAR hid_t H5E_BLKTRK_g; /* Block tracker */
H5_DLLVAR hid_t H5E_SLIST_g; /* Skip Lists */
H5_DLLVAR hid_t H5E_EFL_g; /* External file list */
H5_DLLVAR hid_t H5E_TST_g; /* Ternary Search Trees */
@@ -254,10 +252,6 @@ H5_DLLVAR hid_t H5E_CANTUNPROTECT_g; /* Unable to unprotect metadata */
H5_DLLVAR hid_t H5E_MPI_g; /* Some MPI function failed */
H5_DLLVAR hid_t H5E_MPIERRSTR_g; /* MPI Error String */
-/* Block tracker errors */
-#define H5E_OVERLAPS (H5OPEN H5E_OVERLAPS_g)
-H5_DLLVAR hid_t H5E_OVERLAPS_g; /* Blocks overlap */
-
/* Dataspace errors */
#define H5E_CANTCLIP (H5OPEN H5E_CANTCLIP_g)
#define H5E_CANTCOUNT (H5OPEN H5E_CANTCOUNT_g)
diff --git a/src/H5Eterm.h b/src/H5Eterm.h
index 00eee70..66307f9 100644
--- a/src/H5Eterm.h
+++ b/src/H5Eterm.h
@@ -41,7 +41,6 @@ H5E_OHDR_g=
H5E_ATOM_g=
H5E_ATTR_g=
H5E_IO_g=
-H5E_BLKTRK_g=
H5E_SLIST_g=
H5E_EFL_g=
H5E_TST_g=
@@ -152,9 +151,6 @@ H5E_CANTUNPROTECT_g=
H5E_MPI_g=
H5E_MPIERRSTR_g=
-/* Block tracker errors */
-H5E_OVERLAPS_g=
-
/* Dataspace errors */
H5E_CANTCLIP_g=
H5E_CANTCOUNT_g=
diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h
index 285404a..774b3f6 100644
--- a/src/H5FDpublic.h
+++ b/src/H5FDpublic.h
@@ -43,18 +43,21 @@ typedef enum H5FD_mem_t {
H5FD_MEM_NTYPES /*must be last*/
} H5FD_mem_t;
-/* Map "block tracker" header blocks to 'ohdr' type file memory, since its
- * a fair amount of work to add a new kind of file memory, they are similar
- * enough to object headers and probably too minor to deserve their own type. -QAK */
-#define H5FD_MEM_BLKTRK H5FD_MEM_OHDR
-
-/* Map "segmented heap" header blocks to 'ohdr' type file memory, since its
- * a fair amount of work to add a new kind of file memory, they are similar
+/* Map "fractal heap" header blocks to 'ohdr' type file memory, since its
+ * a fair amount of work to add a new kind of file memory and they are similar
* enough to object headers and probably too minor to deserve their own type.
- * Map "segmented heap" blocks to 'lheap' type file memory, since they will be
- * replacing local heaps. -QAK */
-#define H5FD_MEM_SHEAP_HDR H5FD_MEM_OHDR
-#define H5FD_MEM_SHEAP_BLOCK H5FD_MEM_LHEAP
+ *
+ * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they
+ * are similar to fractal heap header blocks.
+ *
+ * Map "fractal heap" direct blocks to 'lheap' type file memory, since they
+ * will be replacing local heaps.
+ *
+ * -QAK
+ */
+#define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR
+#define H5FD_MEM_FHEAP_INDIRECT H5FD_MEM_OHDR
+#define H5FD_MEM_FHEAP_DIRECT H5FD_MEM_LHEAP
/*
* A free-list map which maps all types of allocation requests to a single
diff --git a/src/H5HF.c b/src/H5HF.c
new file mode 100644
index 0000000..1fe38cb
--- /dev/null
+++ b/src/H5HF.c
@@ -0,0 +1,271 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5HF.c
+ * Feb 24 2006
+ * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ *
+ * Purpose: Implements a "fractal heap" for storing variable-
+ * length objects in a file.
+ *
+ * Please see the documentation in:
+ * doc/html/TechNotes/FractalHeap.html for a full description
+ * of how they work, etc.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5MFprivate.h" /* File memory management */
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+static herr_t H5HF_shared_free(void *_shared);
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+/* Declare a free list to manage the H5HF_t struct */
+H5FL_DEFINE(H5HF_t);
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+/* Declare a free list to manage the H5HF_shared_t struct */
+H5FL_DEFINE_STATIC(H5HF_shared_t);
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_shared_init
+ *
+ * Purpose: Allocate & initialize shared fractal heap info
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_shared_init(H5F_t *f, H5HF_t *fh, H5HF_type_t type)
+{
+ H5HF_shared_t *shared = NULL; /* Shared fractal heap information */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_shared_init)
+
+ /* Allocate space for the shared information */
+ if(NULL == (shared = H5FL_CALLOC(H5HF_shared_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap shared information")
+
+ /* Set the type of heap address mapping */
+ shared->type = type;
+
+ /* Make shared B-tree info reference counted */
+ if(NULL == (fh->shared = H5RC_create(shared, H5HF_shared_free)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared fractal heap info")
+
+done:
+ if(ret_value < 0)
+ if(shared)
+ H5HF_shared_free(shared);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_shared_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_shared_free
+ *
+ * Purpose: Free shared fractal heap info
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5HF_shared_free(void *_shared)
+{
+ H5HF_shared_t *shared = (H5HF_shared_t *)_shared;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_shared_free)
+
+ /* Sanity check */
+ HDassert(shared);
+
+ /* Free the shared info itself */
+ H5FL_FREE(H5HF_shared_t, shared);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_shared_free() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_create
+ *
+ * Purpose: Creates a new empty fractal heap in the file.
+ *
+ * Return: Non-negative on success (with address of new fractal heap
+ * filled in), negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_type_t type, haddr_t *addr_p)
+{
+ H5HF_t *fh = NULL; /* The new fractal heap header information */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5HF_create, FAIL)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(addr_p);
+
+ /*
+ * Allocate file and memory data structures.
+ */
+ if(NULL == (fh = H5FL_MALLOC(H5HF_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap header")
+
+ /* Assign internal information */
+ HDmemset(&fh->cache_info, 0, sizeof(H5AC_info_t));
+
+ /* Initialize shared fractal heap info */
+ if(H5HF_shared_init(f, fh, type) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create shared fractal heap info")
+
+ /* Allocate space for the header on disk */
+ if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, dxpl_id, (hsize_t)H5HF_HEADER_SIZE(f))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap header")
+
+ /* Cache the new fractal heap node */
+ if(H5AC_set(f, dxpl_id, H5AC_FHEAP_HDR, *addr_p, fh, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap header to cache")
+
+done:
+ if(ret_value < 0) {
+ if(fh)
+ (void)H5HF_cache_hdr_dest(f, fh);
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_insert
+ *
+ * Purpose: Insert a new object into a fractal heap.
+ *
+ * Return: Non-negative on success (with heap ID of new object
+ * filled in), negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
+ const void *obj, void *id/*out*/)
+{
+ H5HF_t *fh = NULL; /* The new fractal heap header information */
+ H5HF_shared_t *shared; /* Shared fractal heap information */
+ unsigned hdr_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for header */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5HF_insert, FAIL)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(size > 0);
+ HDassert(obj);
+ HDassert(id);
+
+ /*
+ * Load the fractal heap header.
+ */
+ if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_WRITE)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
+
+ /* Get the pointer to the shared fractal heap info */
+ shared = H5RC_GET_OBJ(fh->shared);
+ HDassert(shared);
+
+ /* Check if object is large enough to be standalone */
+ if(size >= shared->standalone_size) {
+ } /* end if */
+ else {
+ } /* end else */
+
+done:
+ if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, hdr_flags) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release fractal heap header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_insert() */
+
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
new file mode 100644
index 0000000..9544242
--- /dev/null
+++ b/src/H5HFcache.c
@@ -0,0 +1,364 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5HFcache.c
+ * Feb 24 2006
+ * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ *
+ * Purpose: Implement fractal heap metadata cache methods.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5Eprivate.h" /* Error handling */
+
+/****************/
+/* Local Macros */
+/****************/
+
+/* Fractal heap format version #'s */
+#define H5HF_HDR_VERSION 0 /* Header */
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+/* Metadata cache callbacks */
+static H5HF_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata);
+static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_t *fh);
+static herr_t H5HF_cache_hdr_clear(H5F_t *f, H5HF_t *fh, hbool_t destroy);
+static herr_t H5HF_cache_hdr_size(const H5F_t *f, const H5HF_t *fh, size_t *size_ptr);
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+/* H5HF inherits cache-like properties from H5AC */
+const H5AC_class_t H5AC_FHEAP_HDR[1] = {{
+ H5AC_FHEAP_HDR_ID,
+ (H5AC_load_func_t)H5HF_cache_hdr_load,
+ (H5AC_flush_func_t)H5HF_cache_hdr_flush,
+ (H5AC_dest_func_t)H5HF_cache_hdr_dest,
+ (H5AC_clear_func_t)H5HF_cache_hdr_clear,
+ (H5AC_size_func_t)H5HF_cache_hdr_size,
+}};
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+/* Declare a free list to manage B-tree header data to/from disk */
+H5FL_BLK_DEFINE_STATIC(header_block);
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_cache_hdr_load
+ *
+ * Purpose: Loads a fractal heap header from the disk.
+ *
+ * Return: Success: Pointer to a new fractal heap
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static H5HF_t *
+H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2)
+{
+ H5HF_t *fh = NULL; /* Fractal heap info */
+ size_t size; /* Header size */
+ uint8_t *buf = NULL; /* Temporary buffer */
+ uint8_t *p; /* Pointer into raw data buffer */
+ H5HF_type_t heap_type; /* Type of heap */
+ uint32_t metadata_chksum; /* Metadata checksum value */
+ H5HF_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5HF_cache_hdr_load, NULL)
+
+ /* Check arguments */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+
+ /* Allocate space for the fractal heap data structure */
+ if(NULL == (fh = H5FL_MALLOC(H5HF_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HDmemset(&fh->cache_info, 0, sizeof(H5AC_info_t));
+
+ /* Compute the size of the fractal heap header on disk */
+ size = H5HF_HEADER_SIZE(f);
+
+ /* Allocate temporary buffer */
+ if((buf = H5FL_BLK_MALLOC(header_block, size)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+
+ /* Read header from disk */
+ if(H5F_block_read(f, H5FD_MEM_FHEAP_HDR, addr, size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "can't read fractal heap header")
+
+ p = buf;
+
+ /* magic number */
+ if(HDmemcmp(p, H5HF_HDR_MAGIC, H5HF_SIZEOF_MAGIC))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong fractal heap header signature")
+ p += H5HF_SIZEOF_MAGIC;
+
+ /* version */
+ if(*p++ != H5HF_HDR_VERSION)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong fractal heap header version")
+
+ /* Metadata flags (unused, currently) */
+/* XXX: Plan out metadata flags (including "read-only duplicate" feature) */
+ if(*p++ != 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unknown metadata flag in fractal heap header")
+
+ /* Metadata checksum (unused, currently) */
+ UINT32DECODE(p, metadata_chksum);
+/* XXX: Verify checksum */
+ if(metadata_chksum != 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect metadata checksum for fractal heap header")
+
+ /* Fractal heap type */
+ heap_type = *p++;
+ HDassert(H5HF_ABSOLUTE == 0);
+ if(heap_type > H5HF_MAPPED)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect fractal heap type")
+
+ /* Initialize shared fractal heap info */
+ if(H5HF_shared_init(f, fh, heap_type) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't create shared fractal heap info")
+
+ /* Set return value */
+ ret_value = fh;
+
+done:
+ if(buf)
+ H5FL_BLK_FREE(header_block, buf);
+ if(!ret_value && fh)
+ (void)H5HF_cache_hdr_dest(f, fh);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_cache_hdr_flush
+ *
+ * Purpose: Flushes a dirty fractal heap header to disk.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_t *fh)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5HF_cache_hdr_flush, FAIL)
+
+ /* check arguments */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(fh);
+
+ if(fh->cache_info.is_dirty) {
+ H5HF_shared_t *shared; /* Shared fractal heap information */
+ uint8_t *buf = NULL; /* Temporary raw data buffer */
+ uint8_t *p; /* Pointer into raw data buffer */
+ size_t size; /* Header size on disk */
+
+ /* Get the pointer to the shared B-tree info */
+ shared = H5RC_GET_OBJ(fh->shared);
+ HDassert(shared);
+
+ /* Compute the size of the B-tree header on disk */
+ size = H5HF_HEADER_SIZE(f);
+
+ /* Allocate temporary buffer */
+ if((buf = H5FL_BLK_MALLOC(header_block, size)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ p = buf;
+
+ /* Magic number */
+ HDmemcpy(p, H5HF_HDR_MAGIC, H5HF_SIZEOF_MAGIC);
+ p += H5HF_SIZEOF_MAGIC;
+
+ /* Version # */
+ *p++ = H5HF_HDR_VERSION;
+
+ /* Metadata status flags */
+/* XXX: Set this? */
+ *p++ = 0;
+
+ /* Metadata checksum */
+/* XXX: Set this! (After all the metadata is in the buffer) */
+ HDmemset(p, 0, 4);
+ p += 4;
+
+ /* Fractal heap type */
+ *p++ = shared->type;
+
+ /* Write the B-tree header. */
+ HDassert((size_t)(p - buf) == size);
+ if(H5F_block_write(f, H5FD_MEM_FHEAP_HDR, addr, size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFLUSH, FAIL, "unable to save fractal heap header to disk")
+
+ H5FL_BLK_FREE(header_block, buf);
+
+ fh->cache_info.is_dirty = FALSE;
+ } /* end if */
+
+ if(destroy)
+ if(H5HF_cache_hdr_dest(f, fh) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap header")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5HF_cache_hdr_flush() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_cache_hdr_dest
+ *
+ * Purpose: Destroys a fractal heap header in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+herr_t
+H5HF_cache_hdr_dest(H5F_t UNUSED *f, H5HF_t *fh)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_dest)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(fh);
+
+ /* Decrement reference count on shared fractal heap info */
+ if(fh->shared)
+ H5RC_DEC(fh->shared);
+
+ /* Free fractal heap header info */
+ H5FL_FREE(H5HF_t, fh);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5HF_cache_hdr_dest() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_cache_hdr_clear
+ *
+ * Purpose: Mark a fractal heap header in memory as non-dirty.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5HF_cache_hdr_clear(H5F_t *f, H5HF_t *fh, hbool_t destroy)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_hdr_clear)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(fh);
+
+ /* Reset the dirty flag. */
+ fh->cache_info.is_dirty = FALSE;
+
+ if(destroy)
+ if(H5HF_cache_hdr_dest(f, fh) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap header")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_cache_hdr_clear() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_cache_hdr_size
+ *
+ * Purpose: Compute the size in bytes of a fractal heap header
+ * on disk, and return it in *size_ptr. On failure,
+ * the value of *size_ptr is undefined.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5HF_cache_hdr_size(const H5F_t *f, const H5HF_t UNUSED *fh, size_t *size_ptr)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_size)
+
+ /* check arguments */
+ HDassert(f);
+ HDassert(size_ptr);
+
+ /* Set size value */
+ *size_ptr = H5HF_HEADER_SIZE(f);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5HF_cache_hdr_size() */
+
diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c
new file mode 100644
index 0000000..cb6476c
--- /dev/null
+++ b/src/H5HFdbg.c
@@ -0,0 +1,129 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5HFdbg.c
+ * Feb 24 2006
+ * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ *
+ * Purpose: Dump debugging information about a fractal heap
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_hdr_debug
+ *
+ * Purpose: Prints debugging info about a fractal heap header.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 24 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth)
+{
+ H5HF_t *fh = NULL; /* Fractal heap header info */
+ H5HF_shared_t *shared; /* Shared fractal heap information */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5HF_hdr_debug, FAIL)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
+
+ /*
+ * Load the fractal heap header.
+ */
+ if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_READ)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
+
+ /* Get the pointer to the shared fractal heap info */
+ shared = H5RC_GET_OBJ(fh->shared);
+ HDassert(shared);
+
+ /* Print opening message */
+ HDfprintf(stream, "%*sFractal Heap Header...\n", indent, "");
+
+ /*
+ * Print the values.
+ */
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Heap addressing method:",
+ ((shared->type) == H5HF_ABSOLUTE ? "Absolute" :
+ ((shared->type) == H5HF_MAPPED ? "Mapped" :
+ "Unknown!")));
+
+done:
+ if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release fractal heap header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_hdr_debug() */
+
diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h
new file mode 100644
index 0000000..d311aff
--- /dev/null
+++ b/src/H5HFpkg.h
@@ -0,0 +1,155 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Friday, February 24, 2006
+ *
+ * Purpose: This file contains declarations which are visible only within
+ * the H5HF package. Source files outside the H5HF package should
+ * include H5HFprivate.h instead.
+ */
+#ifndef H5HF_PACKAGE
+#error "Do not include this file outside the H5HF package!"
+#endif
+
+#ifndef _H5HFpkg_H
+#define _H5HFpkg_H
+
+/* Get package's private header */
+#include "H5HFprivate.h"
+
+/* Other private headers needed by this file */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5RCprivate.h" /* Reference counted object functions */
+
+/**************************/
+/* Package Private Macros */
+/**************************/
+
+/* Size of signature information (on disk) */
+#define H5HF_SIZEOF_MAGIC 4
+
+/* Fractal heap signatures */
+#define H5HF_HDR_MAGIC "FRHP" /* Header */
+
+/* Size of the fractal heap header on disk */
+#define H5HF_HEADER_SIZE(f) ( \
+ /* General metadata fields */ \
+ 4 /* Signature */ \
+ + 1 /* Version */ \
+ + 1 /* Metadata flags */ \
+ + 4 /* Metadata checksum */ \
+ \
+ /* Fractal heap header specific fields */ \
+ + 1 /* Heap type */ \
+ )
+
+/****************************/
+/* Package Private Typedefs */
+/****************************/
+
+/* Doubling-table info */
+typedef struct H5HF_dtable_param_t {
+ /* Immutable, pre-set information for table */
+ unsigned width; /* Number of columns in the table (must be power of 2) */
+ hsize_t start_block_size; /* Starting block size for table (must be power of 2) */
+ hsize_t max_direct_size; /* Maximum size of a direct block (must be power of 2) */
+ hsize_t max_index; /* Maximum ID/offset for table (must be power of 2) */
+ unsigned start_root_rows; /* Starting number of rows for root indirect block */
+ /* 0 indicates to create the full indirect block for the root,
+ * right from the start. Doesn't have to be power of 2
+ */
+
+ /* Derived information that varies during lifetime of table */
+ haddr_t table_addr; /* Address of first block for table */
+ /* Undefined if no space allocated for table */
+ unsigned curr_root_rows; /* Current number of rows in the root indirect block */
+ /* 0 indicates that the TABLE_ADDR field points
+ * to direct block (of START_BLOCK_SIZE) instead
+ * of indirect root block.
+ */
+} H5HF_dtable_param_t;
+
+/* Each fractal heap has certain information that can be shared across all
+ * the instances of blocks in that fractal heap.
+ */
+typedef struct H5HF_shared_t {
+ /* Shared internal information */
+ hsize_t next_man_block; /* Offset of next direct managed block */
+ hsize_t next_std_block; /* Offset of next direct standalone block */
+ hsize_t total_man_free; /* Total amount of free space in managed blocks */
+ hsize_t total_std_free; /* Total # of free standalone ID entries */
+
+ /* Doubling table information */
+ /* (Partially set by user, partially derived/updated internally) */
+ H5HF_dtable_param_t man_dtable_info; /* Doubling-table info for managed objects */
+ H5HF_dtable_param_t std_dtable_info; /* Doubling-table info for standalone objects */
+
+ /* Information set by user */
+ H5HF_type_t type; /* Type of address mapping */
+ size_t standalone_size; /* Size of object to store standalone */
+ size_t fixed_len_size; /* Size of objects (only for heaps w/fixed-length objects) */
+
+ /* Information derived from user parameters */
+ hbool_t fixed_len_obj; /* Are objects in the heap fixed length? */
+ hbool_t ref_count_obj; /* Are objects in the heap ref. counted? */
+ hbool_t have_io_filter; /* Does the heap have I/O filters for the direct blocks? */
+ hbool_t write_once; /* Is heap being written in "write once" mode? */
+} H5HF_shared_t;
+
+/* The fractal heap information */
+typedef struct H5HF_t {
+ /* Information for H5AC cache functions, _must_ be first field in structure */
+ H5AC_info_t cache_info;
+
+ /* Internal fractal heap information */
+ H5RC_t *shared; /* Ref-counted shared info */
+} H5HF_t;
+
+
+/*****************************/
+/* Package Private Variables */
+/*****************************/
+
+/* H5HF header inherits cache-like properties from H5AC */
+H5_DLLVAR const H5AC_class_t H5AC_FHEAP_HDR[1];
+
+/* Declare a free list to manage the H5HF_t struct */
+H5FL_EXTERN(H5HF_t);
+
+
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
+/* Routines for managing shared fractal heap info */
+H5_DLL herr_t H5HF_shared_init(H5F_t *f, H5HF_t *fh, H5HF_type_t type);
+
+/* Metadata cache callbacks */
+H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_t *b);
+
+/* Debugging routines for dumping file structures */
+H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
+ FILE *stream, int indent, int fwidth);
+
+/* Testing routines */
+#ifdef H5HF_TESTING
+H5_DLL herr_t H5HF_get_addrmap_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
+ H5HF_type_t *heap_type);
+#endif /* H5HF_TESTING */
+
+#endif /* _H5HFpkg_H */
+
diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h
new file mode 100644
index 0000000..49c11c9
--- /dev/null
+++ b/src/H5HFprivate.h
@@ -0,0 +1,65 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5HFprivate.h
+ * Feb 24 2006
+ * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ *
+ * Purpose: Private header for library accessible fractal heap routines.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef _H5HFprivate_H
+#define _H5HFprivate_H
+
+/* Include package's public header */
+#include "H5HFpublic.h"
+
+/* Private headers needed by this file */
+#include "H5Fprivate.h" /* File access */
+
+/**************************/
+/* Library Private Macros */
+/**************************/
+
+
+/****************************/
+/* Library Private Typedefs */
+/****************************/
+
+/* Types of heaps */
+typedef enum {
+ H5HF_ABSOLUTE, /* The heap uses absolute internal addressing */
+ H5HF_MAPPED /* The heap maps internal addresses to allow compaction */
+} H5HF_type_t;
+
+
+/*****************************/
+/* Library-private Variables */
+/*****************************/
+
+/***************************************/
+/* Library-private Function Prototypes */
+/***************************************/
+H5_DLL herr_t H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_type_t type,
+ haddr_t *addr_p);
+H5_DLL herr_t H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
+ const void *obj, void *id/*out*/);
+
+#endif /* _H5HFprivate_H */
+
+
diff --git a/src/H5HFpublic.h b/src/H5HFpublic.h
new file mode 100644
index 0000000..70453dc
--- /dev/null
+++ b/src/H5HFpublic.h
@@ -0,0 +1,53 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5HFpublic.h
+ * Feb 24 2006
+ * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ *
+ * Purpose: Public declarations for the fractal heap package.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef _H5HFpublic_H
+#define _H5HFpublic_H
+
+/* Public headers needed by this file */
+#include "H5public.h"
+
+/*****************/
+/* Public Macros */
+/*****************/
+
+/*******************/
+/* Public Typedefs */
+/*******************/
+
+/**********************************/
+/* Public API Function Prototypes */
+/**********************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _H5HFpublic_H */
+
diff --git a/src/H5HFtest.c b/src/H5HFtest.c
new file mode 100644
index 0000000..e9a3eeb
--- /dev/null
+++ b/src/H5HFtest.c
@@ -0,0 +1,112 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Thursday, February 3, 2005
+ *
+ * Purpose: Fractal heap testing functions.
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
+#define H5HF_TESTING /*suppress warning about H5HF testing funcs*/
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5Eprivate.h" /* Error handling */
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_get_addrmap_test
+ *
+ * Purpose: Retrieve the address mapping type
+ *
+ * Return: Success: non-negative
+ *
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Friday, February 24, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_get_addrmap_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, H5HF_type_t *heap_type)
+{
+ H5HF_t *fh = NULL; /* Pointer to the B-tree header */
+ H5HF_shared_t *shared; /* Shared fractal heap information */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_get_addrmap_test)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(H5F_addr_defined(fh_addr));
+ HDassert(heap_type);
+
+ /* Look up the fractal heap header */
+ if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_READ)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap header")
+
+ /* Get the pointer to the shared fractal heap info */
+ shared = H5RC_GET_OBJ(fh->shared);
+ HDassert(shared);
+
+ /* Get fractal heap address mapping */
+ *heap_type = shared->type;
+
+done:
+ /* Release fractal heap header node */
+ if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, fh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header info")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5HF_get_addrmap_test() */
+
diff --git a/src/H5err.txt b/src/H5err.txt
index 65c4e1f..88eb01c 100644
--- a/src/H5err.txt
+++ b/src/H5err.txt
@@ -71,7 +71,6 @@ MAJOR, H5E_TST, Ternary Search Trees
MAJOR, H5E_RS, Reference Counted Strings
MAJOR, H5E_ERROR, Error API
MAJOR, H5E_SLIST, Skip Lists
-MAJOR, H5E_BLKTRK, Block tracker
# Sections (for grouping minor errors)
SECTION, ARGS, Argument errors
@@ -91,7 +90,6 @@ SECTION, MPI, Parallel MPI errors
SECTION, HEAP, Heap errors
SECTION, FPH5, FPHDF5 errors
SECTION, PIPELINE, I/O pipeline errors
-SECTION, BLKTRK, Block tracker errors
SECTION, SYSTEM, System level errors
# Minor errors
@@ -223,8 +221,5 @@ MINOR, PIPELINE, H5E_CANAPPLY, Error from filter 'can apply' callback
MINOR, PIPELINE, H5E_SETLOCAL, Error from filter 'set local' callback
MINOR, PIPELINE, H5E_NOENCODER, Filter present but encoding disabled
-# Block tracker errors
-MINOR, BLKTRK, H5E_OVERLAPS, Blocks overlap
-
# System level errors
MINOR, SYSTEM, H5E_SYSERRSTR, System error message
diff --git a/src/Makefile.am b/src/Makefile.am
index d8c82d0..dc3629a 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,6 +55,7 @@ libhdf5_la_SOURCES= H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \
H5Gstab.c \
H5Gtest.c \
H5Gtraverse.c \
+ H5HF.c H5HFcache.c H5HFdbg.c H5HFtest.c \
H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c \
H5MP.c H5MPtest.c \
H5O.c \
@@ -83,7 +84,7 @@ include_HEADERS =H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \
H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \
H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \
H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h H5FPpublic.h \
- H5Gpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \
+ H5Gpublic.h H5HFpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \
H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \
H5Tpublic.h H5Zpublic.h H5pubconf.h hdf5.h H5api_adpt.h
diff --git a/src/Makefile.in b/src/Makefile.in
index 7a58aa4..1b5ea41 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -92,21 +92,22 @@ am_libhdf5_la_OBJECTS = H5.lo H5A.lo H5AC.lo H5B.lo H5Bcache.lo \
H5FDstdio.lo H5FDstream.lo H5FL.lo H5FO.lo H5FP.lo \
H5FPclient.lo H5FPserver.lo H5FS.lo H5G.lo H5Gent.lo \
H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo \
- H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HG.lo H5HGdbg.lo \
- H5HL.lo H5HLdbg.lo H5HP.lo H5I.lo H5MF.lo H5MM.lo H5MP.lo \
- H5MPtest.lo H5O.lo H5Oattr.lo H5Obogus.lo H5Ocache.lo \
- H5Ocont.lo H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Oginfo.lo \
- H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omtime.lo H5Oname.lo \
- H5Onull.lo H5Opline.lo H5Osdspace.lo H5Oshared.lo H5Ostab.lo \
- H5P.lo H5Pacpl.lo H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo \
- H5Pgcpl.lo H5Pocpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo H5S.lo \
- H5Sall.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \
- H5Sselect.lo H5Stest.lo H5SL.lo H5ST.lo H5T.lo H5Tarray.lo \
- H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo \
- H5Tenum.lo H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo \
- H5Tnative.lo H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo \
- H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo H5Tvlen.lo H5TS.lo H5V.lo \
- H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \
+ H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFcache.lo \
+ H5HFdbg.lo H5HFtest.lo H5HG.lo H5HGdbg.lo H5HL.lo H5HLdbg.lo \
+ H5HP.lo H5I.lo H5MF.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo \
+ H5Oattr.lo H5Obogus.lo H5Ocache.lo H5Ocont.lo H5Odtype.lo \
+ H5Oefl.lo H5Ofill.lo H5Oginfo.lo H5Olayout.lo H5Olinfo.lo \
+ H5Olink.lo H5Omtime.lo H5Oname.lo H5Onull.lo H5Opline.lo \
+ H5Osdspace.lo H5Oshared.lo H5Ostab.lo H5P.lo H5Pacpl.lo \
+ H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo H5Pgcpl.lo \
+ H5Pocpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo H5S.lo H5Sall.lo \
+ H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \
+ H5Stest.lo H5SL.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo \
+ H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tenum.lo \
+ H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo \
+ H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo \
+ H5Tprecis.lo H5Tstrpad.lo H5Tvlen.lo H5TS.lo H5V.lo H5Z.lo \
+ H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \
H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo
libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS)
PROGRAMS = $(noinst_PROGRAMS)
@@ -406,6 +407,7 @@ libhdf5_la_SOURCES = H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \
H5Gstab.c \
H5Gtest.c \
H5Gtraverse.c \
+ H5HF.c H5HFcache.c H5HFdbg.c H5HFtest.c \
H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c \
H5MP.c H5MPtest.c \
H5O.c \
@@ -434,7 +436,7 @@ include_HEADERS = H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \
H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \
H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \
H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h H5FPpublic.h \
- H5Gpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \
+ H5Gpublic.h H5HFpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \
H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \
H5Tpublic.h H5Zpublic.h H5pubconf.h hdf5.h H5api_adpt.h
@@ -613,6 +615,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gstab.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gtest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gtraverse.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HF.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFcache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFdbg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFtest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HG.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HGdbg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HL.Plo@am__quote@
diff --git a/test/Makefile.am b/test/Makefile.am
index 8e22514..c924995 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -32,7 +32,7 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
# executed, generally most specific tests to least specific tests.
# As an exception, long-running tests should occur earlier in the list.
# This gives them more time to run when tests are executing in parallel.
-TEST_PROG=testhdf5 lheap ohdr stab gheap btree2 cache cache_api \
+TEST_PROG=testhdf5 lheap fheap ohdr stab gheap btree2 cache cache_api \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
@@ -94,7 +94,7 @@ flush2.chkexe_: flush1.chkexe_
# prefix or low-level driver with environment variables will influence
# the temporary file name in ways that the makefile is not aware of.
CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5\
- tfile[1-4].h5 th5s[1-3].h5 lheap.h5 ohdr.h5 stab[1-2].h5 \
+ tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab[1-2].h5 \
extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2]\
links.h5 links[1-3].h5 big.data big[0-9][0-9][0-9][0-9][0-9].h5 \
dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 2be16e9..7be578d 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -31,7 +31,7 @@
#
-SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c fillval.c flush1.c flush2.c gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
+SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c fheap.c fillval.c flush1.c flush2.c gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -73,14 +73,14 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
libh5test_la_LIBADD =
am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo
libh5test_la_OBJECTS = $(am_libh5test_la_OBJECTS)
-am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
- stab$(EXEEXT) gheap$(EXEEXT) btree2$(EXEEXT) cache$(EXEEXT) \
- cache_api$(EXEEXT) pool$(EXEEXT) hyperslab$(EXEEXT) \
- istore$(EXEEXT) bittests$(EXEEXT) dt_arith$(EXEEXT) \
- dtypes$(EXEEXT) dsets$(EXEEXT) cmpd_dset$(EXEEXT) \
- extend$(EXEEXT) external$(EXEEXT) objcopy$(EXEEXT) \
- links$(EXEEXT) unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) \
- fillval$(EXEEXT) mount$(EXEEXT) flush1$(EXEEXT) \
+am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) fheap$(EXEEXT) \
+ ohdr$(EXEEXT) stab$(EXEEXT) gheap$(EXEEXT) btree2$(EXEEXT) \
+ cache$(EXEEXT) cache_api$(EXEEXT) pool$(EXEEXT) \
+ hyperslab$(EXEEXT) istore$(EXEEXT) bittests$(EXEEXT) \
+ dt_arith$(EXEEXT) dtypes$(EXEEXT) dsets$(EXEEXT) \
+ cmpd_dset$(EXEEXT) extend$(EXEEXT) external$(EXEEXT) \
+ objcopy$(EXEEXT) links$(EXEEXT) unlink$(EXEEXT) big$(EXEEXT) \
+ mtime$(EXEEXT) fillval$(EXEEXT) mount$(EXEEXT) flush1$(EXEEXT) \
flush2$(EXEEXT) enum$(EXEEXT) set_extent$(EXEEXT) \
ttsafe$(EXEEXT) stream_test$(EXEEXT) getname$(EXEEXT) \
vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
@@ -161,6 +161,10 @@ external_SOURCES = external.c
external_OBJECTS = external.$(OBJEXT)
external_LDADD = $(LDADD)
external_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
+fheap_SOURCES = fheap.c
+fheap_OBJECTS = fheap.$(OBJEXT)
+fheap_LDADD = $(LDADD)
+fheap_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
fillval_SOURCES = fillval.c
fillval_OBJECTS = fillval.$(OBJEXT)
fillval_LDADD = $(LDADD)
@@ -320,25 +324,25 @@ LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c \
cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c \
dtransform.c dtypes.c enum.c err_compat.c error_test.c \
- extend.c external.c fillval.c flush1.c flush2.c gen_deflate.c \
- gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c \
- gen_new_mtime.c gen_new_super.c gen_noencoder.c \
- gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c \
- links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
- reserved.c set_extent.c space_overflow.c stab.c stream_test.c \
- $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
- vfd.c
+ extend.c external.c fheap.c fillval.c flush1.c flush2.c \
+ gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c \
+ gen_new_group.c gen_new_mtime.c gen_new_super.c \
+ gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c \
+ istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \
+ ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c \
+ stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) \
+ unlink.c vfd.c
DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \
cache.c cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c \
dtransform.c dtypes.c enum.c err_compat.c error_test.c \
- extend.c external.c fillval.c flush1.c flush2.c gen_deflate.c \
- gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c \
- gen_new_mtime.c gen_new_super.c gen_noencoder.c \
- gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c \
- links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
- reserved.c set_extent.c space_overflow.c stab.c stream_test.c \
- $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
- vfd.c
+ extend.c external.c fheap.c fillval.c flush1.c flush2.c \
+ gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c \
+ gen_new_group.c gen_new_mtime.c gen_new_super.c \
+ gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c \
+ istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \
+ ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c \
+ stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) \
+ unlink.c vfd.c
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -586,9 +590,9 @@ TRACE = perl $(top_srcdir)/bin/trace
# the temporary file name in ways that the makefile is not aware of.
CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \
compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \
- tfile[1-4].h5 th5s[1-3].h5 lheap.h5 ohdr.h5 stab[1-2].h5 \
- extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \
- dt_arith[1-2] links.h5 links[1-3].h5 big.data \
+ tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \
+ stab[1-2].h5 extern_[1-3].h5 extern_[1-4][ab].raw \
+ gheap[0-4].h5 dt_arith[1-2] links.h5 links[1-3].h5 big.data \
big[0-9][0-9][0-9][0-9][0-9].h5 dtypes[1-8].h5 \
dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 unlink.h5 \
unicode.h5 fillval_[0-9].h5 fillval.raw mount_[0-9].h5 \
@@ -612,7 +616,7 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
# executed, generally most specific tests to least specific tests.
# As an exception, long-running tests should occur earlier in the list.
# This gives them more time to run when tests are executing in parallel.
-TEST_PROG = testhdf5 lheap ohdr stab gheap btree2 cache cache_api \
+TEST_PROG = testhdf5 lheap fheap ohdr stab gheap btree2 cache cache_api \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
@@ -773,6 +777,9 @@ extend$(EXEEXT): $(extend_OBJECTS) $(extend_DEPENDENCIES)
external$(EXEEXT): $(external_OBJECTS) $(external_DEPENDENCIES)
@rm -f external$(EXEEXT)
$(LINK) $(external_LDFLAGS) $(external_OBJECTS) $(external_LDADD) $(LIBS)
+fheap$(EXEEXT): $(fheap_OBJECTS) $(fheap_DEPENDENCIES)
+ @rm -f fheap$(EXEEXT)
+ $(LINK) $(fheap_LDFLAGS) $(fheap_OBJECTS) $(fheap_LDADD) $(LIBS)
fillval$(EXEEXT): $(fillval_OBJECTS) $(fillval_DEPENDENCIES)
@rm -f fillval$(EXEEXT)
$(LINK) $(fillval_LDFLAGS) $(fillval_OBJECTS) $(fillval_LDADD) $(LIBS)
@@ -899,6 +906,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extend.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/external.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fheap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fillval.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush2.Po@am__quote@
diff --git a/test/fheap.c b/test/fheap.c
new file mode 100644
index 0000000..b1fce69
--- /dev/null
+++ b/test/fheap.c
@@ -0,0 +1,251 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Friday, February 24, 2006
+ */
+#include "h5test.h"
+
+/*
+ * This file needs to access private datatypes from the H5HF package.
+ * This file also needs to access the fractal heap testing code.
+ */
+#define H5HF_PACKAGE
+#define H5HF_TESTING
+#include "H5HFpkg.h"
+
+/* Other private headers that this test requires */
+#include "H5Iprivate.h"
+
+const char *FILENAME[] = {
+ "fheap",
+ NULL
+};
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_create
+ *
+ * Purpose: Create fractal heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Friday, February 24, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_create(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_type_t heap_type, test_heap_type; /* Type of address mapping for fractal heap */
+ haddr_t fh_addr; /* Address of fractal heap created */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /*
+ * Test fractal heap creation (w/absolute address mapping)
+ */
+ TESTING("Fractal heap creation (w/absolute address mapping)");
+ heap_type = H5HF_ABSOLUTE;
+ if(H5HF_create(f, H5P_DATASET_XFER_DEFAULT, heap_type, &fh_addr/*out*/) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ PASSED()
+
+ /* Query the type of address mapping */
+ TESTING("Query absolute address mapping setting");
+ test_heap_type = H5HF_MAPPED;
+ if(H5HF_get_addrmap_test(f, H5P_DATASET_XFER_DEFAULT, fh_addr, &test_heap_type) < 0)
+ FAIL_STACK_ERROR
+ if(test_heap_type != heap_type)
+ FAIL_STACK_ERROR
+ PASSED()
+
+ /*
+ * Test fractal heap creation (w/mapped address mapping)
+ */
+ TESTING("Fractal heap creation (w/mapped address mapping)");
+ heap_type = H5HF_MAPPED;
+ if(H5HF_create(f, H5P_DATASET_XFER_DEFAULT, heap_type, &fh_addr/*out*/) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ PASSED()
+
+ /* Query the type of address mapping */
+ TESTING("Query mapped address mapping setting");
+ test_heap_type = H5HF_ABSOLUTE;
+ if(H5HF_get_addrmap_test(f, H5P_DATASET_XFER_DEFAULT, fh_addr, &test_heap_type) < 0)
+ FAIL_STACK_ERROR
+ if(test_heap_type != heap_type)
+ FAIL_STACK_ERROR
+ PASSED()
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_insert_first
+ *
+ * Purpose: Test inserting first object into absolute heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Friday, February 24, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_insert_first(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ haddr_t fh_addr; /* Address of fractal heap created */
+ unsigned char obj[10]; /* Buffer for object to insert */
+ haddr_t heap_id; /* Heap ID for object inserted */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic error return value */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(H5HF_create(f, dxpl, H5HF_ABSOLUTE, &fh_addr/*out*/) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+#ifdef QAK
+HDfprintf(stdout, "Fractal heap header address = %a\n", fh_addr);
+#endif /* QAK */
+
+ /* Initialize object buffer */
+ for(u = 0; u < sizeof(obj); u++)
+ obj[u] = u;
+
+ /*
+ * Test inserting first (small) object into absolute heap
+ */
+ TESTING("Inserting first (small) object into absolute heap");
+ heap_id = HADDR_UNDEF;
+ if(H5HF_insert(f, dxpl, fh_addr, sizeof(obj), obj, &heap_id) < 0)
+ FAIL_STACK_ERROR
+#ifdef QAK
+HDfprintf(stdout, "heap_id = %a\n", heap_id);
+#endif /* QAK */
+ PASSED()
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_insert_first() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Test the fractal heap code
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Quincey Koziol
+ * Friday, February 24, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t fapl = -1; /* File access property list for data files */
+ unsigned nerrors = 0; /* Cumulative error count */
+
+ /* Reset library */
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ /* Test fractal heap creation */
+ nerrors += test_create(fapl);
+
+ /* Test fractal heap object insertion */
+ nerrors += test_abs_insert_first(fapl);
+
+ if(nerrors)
+ goto error;
+ puts("All fractal heap tests passed.");
+#ifndef QAK
+ h5_cleanup(FILENAME, fapl);
+#else /* QAK */
+HDfprintf(stderr, "Uncomment cleanup!\n");
+#endif /* QAK */
+ return 0;
+
+error:
+ puts("*** TESTS FAILED ***");
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+ return 1;
+}
+
diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c
index 0228d98..b93ec2a 100644
--- a/tools/misc/h5debug.c
+++ b/tools/misc/h5debug.c
@@ -28,25 +28,28 @@
#define H5O_PACKAGE /*suppress error about including H5Opkg */
#define H5B2_PACKAGE /*suppress error about including H5B2pkg */
#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/
+#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
#include "H5private.h" /* Generic Functions */
-#include "H5Bprivate.h"
-#include "H5B2pkg.h" /* B-trees */
-#include "H5Dprivate.h"
+#include "H5Bprivate.h" /* B-trees */
+#include "H5B2pkg.h" /* v2 B-trees */
+#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h"
-#include "H5Gprivate.h"
-#include "H5HGprivate.h"
-#include "H5HLprivate.h"
-#include "H5Iprivate.h"
-#include "H5Opkg.h"
-#include "H5Pprivate.h"
+#include "H5Fpkg.h" /* File access */
+#include "H5Gprivate.h" /* Groups */
+#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5HGprivate.h" /* Global Heaps */
+#include "H5HLprivate.h" /* Local Heaps */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Opkg.h" /* Object headers */
+#include "H5Pprivate.h" /* Property lists */
/* File drivers */
#include "H5FDfamily.h"
#define INDENT 3
#define VCOL 50
+#define SIGLEN H5F_SIGNATURE_LEN /* Size of signature buffer */
/*-------------------------------------------------------------------------
@@ -72,7 +75,7 @@ main(int argc, char *argv[])
hid_t fid, fapl, dxpl;
H5F_t *f;
haddr_t addr=0, extra=0, extra2=0;
- uint8_t sig[16];
+ uint8_t sig[SIGLEN];
int i;
herr_t status = SUCCEED;
@@ -114,16 +117,13 @@ main(int argc, char *argv[])
/*
* Parse command arguments.
*/
- if (argc > 2) {
-/* printf("New address: %s\n", argv[2]); */
+ if (argc > 2)
addr = HDstrtoll(argv[2], NULL, 0);
- }
- if (argc > 3) {
+ if (argc > 3)
extra = HDstrtoll(argv[3], NULL, 0);
- }
- if (argc > 4) {
+ if (argc > 4)
extra2 = HDstrtoll(argv[4], NULL, 0);
- }
+
/*
* Read the signature at the specified file position.
*/
@@ -134,7 +134,7 @@ main(int argc, char *argv[])
}
if (!HDmemcmp(sig, H5F_SIGNATURE, H5F_SIGNATURE_LEN)) {
/*
- * Debug the boot block.
+ * Debug the file's super block.
*/
status = H5F_debug(f, H5P_DATASET_XFER_DEFAULT, stdout, 0, VCOL);
@@ -166,18 +166,18 @@ main(int argc, char *argv[])
unsigned ndims;
switch (subtype) {
- case H5B_SNODE_ID:
- status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra);
- break;
-
- case H5B_ISTORE_ID:
- ndims = (unsigned)extra;
- status = H5D_istore_debug (f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, ndims);
- break;
-
- default:
- fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
+ case H5B_SNODE_ID:
+ status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra);
+ break;
+
+ case H5B_ISTORE_ID:
+ ndims = (unsigned)extra;
+ status = H5D_istore_debug (f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, ndims);
+ break;
+
+ default:
+ fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
+ HDexit(4);
}
} else if (!HDmemcmp(sig, H5B2_HDR_MAGIC, H5B2_SIZEOF_MAGIC)) {
@@ -234,6 +234,12 @@ main(int argc, char *argv[])
HDexit(4);
} /* end switch */
+ } else if (!HDmemcmp(sig, H5HF_HDR_MAGIC, H5HF_SIZEOF_MAGIC)) {
+ /*
+ * Debug a fractal heap header.
+ */
+ status = H5HF_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
+
} else if (sig[0] == H5O_VERSION) {
/*
* This could be an object header. Since they don't have a signature
@@ -246,7 +252,7 @@ main(int argc, char *argv[])
* Got some other unrecognized signature.
*/
printf("%-*s ", VCOL, "Signature:");
- for (i = 0; i < 8; i++) {
+ for (i = 0; i < sizeof(sig); i++) {
if (sig[i] > ' ' && sig[i] <= '~' && '\\' != sig[i]) {
HDputchar(sig[i]);
} else if ('\\' == sig[i]) {
@@ -270,5 +276,7 @@ main(int argc, char *argv[])
H5Pclose(dxpl);
H5Pclose(fapl);
H5Fclose(fid);
+
return 0;
}
+