summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Adense.c75
-rw-r--r--src/H5Oattribute.c3
-rw-r--r--src/H5Oshared.c4
-rwxr-xr-xsrc/H5SM.c66
-rwxr-xr-xsrc/H5SMprivate.h3
-rw-r--r--test/tattr.c767
6 files changed, 762 insertions, 156 deletions
diff --git a/src/H5Adense.c b/src/H5Adense.c
index 6c0a907..d64bb89 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -112,7 +112,7 @@ typedef struct {
/*
* Data exchange structure to pass through the fractal heap layer for the
* H5HF_op function when copying an attribute stored in densely stored attributes.
- * (or the shared object heap)
+ * (or the shared message heap)
*/
typedef struct {
/* downward (internal) */
@@ -331,13 +331,13 @@ H5A_dense_open(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *name)
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared message heap address")
/* Open the fractal heap for shared header messages */
if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
@@ -411,13 +411,13 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, unsigned mesg_flags,
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address")
/* Open the fractal heap for shared header messages */
if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
@@ -629,13 +629,13 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, H5A_t *attr)
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address")
/* Open the fractal heap for shared header messages */
if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
@@ -761,13 +761,13 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *old_name,
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address")
/* Open the fractal heap for shared header messages */
if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
@@ -964,13 +964,13 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, haddr_t attr_fheap_addr
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address")
/* Open the fractal heap for shared header messages */
if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
@@ -1106,13 +1106,13 @@ H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *name)
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address")
/* Open the fractal heap for shared header messages */
if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
@@ -1188,13 +1188,13 @@ H5A_dense_exists(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *name)
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address")
/* Open the fractal heap for shared header messages */
if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
@@ -1334,17 +1334,20 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared")
- /* Get handle for shared object heap, if attributes are sharable */
+ /* Get handle for shared message heap, if attributes are sharable */
if(attr_sharable) {
haddr_t shared_fheap_addr; /* Address of fractal heap to use */
- /* Retrieve the address of the shared object's fractal heap */
- if(HADDR_UNDEF == (shared_fheap_addr = H5SM_get_fheap_addr(f, H5O_ATTR_ID, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared object heap address")
+ /* Retrieve the address of the shared message's fractal heap */
+ if(H5SM_get_fheap_addr(f, dxpl_id, H5O_ATTR_ID, &shared_fheap_addr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address")
- /* Open the fractal heap for shared header messages */
- if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ /* Check if there are any shared messages currently */
+ if(H5F_addr_defined(shared_fheap_addr)) {
+ /* Open the fractal heap for shared header messages */
+ if(NULL == (shared_fheap = H5HF_open(f, dxpl_id, shared_fheap_addr)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
+ } /* end if */
} /* end if */
/* Create the "udata" information for v2 B-tree 'delete' */
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 287f5c6..b1e8d31 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -1241,10 +1241,9 @@ H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id)
} /* end else */
/* Check for shifting from dense storage back to compact storage */
- if(H5F_addr_defined(oh->attr_fheap_addr) && oh->nattrs < oh->min_dense) {
+ if(H5F_addr_defined(oh->attr_fheap_addr) && (oh->nattrs == 0 || oh->nattrs < oh->min_dense)) {
/* Check if there's no more attributes */
if(oh->nattrs == 0) {
-/* XXX: Test this */
/* Delete the dense storage */
if(H5A_dense_delete(loc->file, dxpl_id, oh) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage")
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 4112865..6c5189d 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -37,7 +37,7 @@
#include "H5HFprivate.h" /* Fractal heap */
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
-#include "H5SMprivate.h" /*JAMES: for H5SM_get_fheap_addr. Change this? */
+#include "H5SMprivate.h" /* Shared messages */
static void *H5O_shared_decode(H5F_t*, hid_t dxpl_id, const uint8_t*);
static herr_t H5O_shared_encode(H5F_t*, uint8_t*, const void*);
@@ -139,7 +139,7 @@ H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
size_t buf_size;
/* Retrieve the fractal heap address for shared messages */
- if((fheap_addr = H5SM_get_fheap_addr(f, type->id, dxpl_id)) == HADDR_UNDEF)
+ if(H5SM_get_fheap_addr(f, dxpl_id, type->id, &fheap_addr) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get fheap address for shared messages")
/* Open the fractal heap */
diff --git a/src/H5SM.c b/src/H5SM.c
index 38d1b34..6e5dba8 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -106,7 +106,7 @@ H5FL_ARR_DEFINE(H5SM_sohm_t, H5O_SHMESG_MAX_LIST_SIZE);
*/
herr_t
H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, hid_t dxpl_id)
-{
+{
H5SM_master_table_t *table = NULL;
haddr_t table_addr = HADDR_UNDEF;
unsigned num_indexes;
@@ -346,7 +346,7 @@ H5SM_type_shared(H5F_t *f, unsigned type_id, hid_t dxpl_id)
} /* end if */
else
/* No shared messages of any type */
- HGOTO_DONE(FALSE)
+ HGOTO_DONE(FALSE)
/* Search the indexes until we find one that matches this flag or we've
* searched them all.
@@ -377,28 +377,34 @@ done:
*
*-------------------------------------------------------------------------
*/
-haddr_t
-H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, hid_t dxpl_id)
+herr_t
+H5SM_get_fheap_addr(H5F_t *f, hid_t dxpl_id, unsigned type_id, haddr_t *fheap_addr)
{
H5SM_master_table_t *table = NULL; /* Shared object master table */
ssize_t index_num; /* Which index */
- haddr_t ret_value;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5SM_get_fheap_addr, FAIL)
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(fheap_addr);
+
/* Look up the master SOHM table */
if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, NULL, NULL, H5AC_READ)))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, HADDR_UNDEF, "unable to load SOHM master table")
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table")
+ /* Look up index for message type */
if((index_num = H5SM_get_index(table, type_id)) < 0)
- HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, HADDR_UNDEF, "unable to find correct SOHM index")
+ HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to find correct SOHM index")
- ret_value = table->indexes[index_num].heap_addr;
+ /* Retrieve heap address for index */
+ *fheap_addr = table->indexes[index_num].heap_addr;
done:
/* Release the master SOHM table */
if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, table, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, HADDR_UNDEF, "unable to close SOHM master table")
+ HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_get_fheap_addr() */
@@ -492,7 +498,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5SM_create_index
+ * Function: H5SM_delete_index
*
* Purpose: De-allocates storage for an index whose header is HEADER.
*
@@ -519,12 +525,12 @@ H5SM_delete_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id, hbool_t
FUNC_ENTER_NOAPI(H5SM_delete_index, FAIL)
/* Determine whether index is a list or a B-tree. */
- if(header->index_type == H5SM_LIST) {
+ if(header->index_type == H5SM_LIST) {
/* Eject entry from cache */
if(H5AC_expunge_entry(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove list index from cache")
-
- /* Free the file space used */
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove list index from cache")
+
+ /* Free the file space used */
list_size = H5SM_LIST_SIZE(f, header->list_max);
if(H5MF_xfree(f, H5FD_MEM_SOHM_INDEX, dxpl_id, header->index_addr, list_size) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to free shared message list")
@@ -749,7 +755,7 @@ H5SM_convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header, hid_t dxpl_i
*/
if(H5B2_delete(f, dxpl_id, H5SM_INDEX, btree_addr, H5SM_convert_to_list_op, list) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete B-tree")
-
+
done:
/* Release the SOHM list from the cache */
if(list && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0)
@@ -784,7 +790,6 @@ htri_t
H5SM_try_share(H5F_t *f, hid_t dxpl_id, unsigned type_id, void *mesg)
{
size_t mesg_size;
- htri_t tri_ret;
H5SM_master_table_t *table = NULL;
unsigned cache_flags = H5AC__NO_FLAGS_SET;
ssize_t index_num;
@@ -804,21 +809,20 @@ H5SM_try_share(H5F_t *f, hid_t dxpl_id, unsigned type_id, void *mesg)
*/
if(type_id == H5O_DTYPE_ID)
{
+ htri_t tri_ret;
+
/* Don't share immutable datatypes */
if((tri_ret = H5T_is_immutable((H5T_t*) mesg)) > 0)
- {
- HGOTO_DONE(FALSE);
- }
- else if(tri_ret <0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is immutable")
+ HGOTO_DONE(FALSE)
+ else if(tri_ret < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is immutable")
+
/* Don't share committed datatypes */
if((tri_ret = H5T_committed((H5T_t*) mesg)) > 0)
- {
- HGOTO_DONE(FALSE);
- }
- else if(tri_ret <0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is comitted")
- }
+ HGOTO_DONE(FALSE)
+ else if(tri_ret < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is comitted")
+ } /* end if */
/* Look up the master SOHM table */
if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, NULL, NULL, H5AC_WRITE)))
@@ -1094,7 +1098,6 @@ H5SM_try_delete(H5F_t *f, hid_t dxpl_id, unsigned type_id,
/* Release the master SOHM table */
if(H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, table, cache_flags) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "unable to close SOHM master table")
-
table = NULL;
/* If buf was allocated, delete the message it holds. This message may
@@ -1226,7 +1229,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
HDassert(cache_flags);
HDassert(mesg->flags & H5O_SHARED_IN_HEAP_FLAG);
HDassert(*buf == NULL);
-
+
/* Open the heap that this message is in */
if(NULL == (fheap = H5HF_open(f, dxpl_id, header->heap_addr)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
@@ -1266,7 +1269,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
{
HDassert(header->index_type == H5SM_BTREE);
- /* If this returns failure, it means that the message wasn't found.
+ /* If this returns failure, it means that the message wasn't found.
* If it succeeds, a copy of the modified message will be returned. */
if(H5B2_modify(f, dxpl_id, H5SM_INDEX, header->index_addr, &key, H5SM_decr_ref, &message) <0)
HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index")
@@ -1311,8 +1314,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
--header->num_messages;
*cache_flags |= H5AC__DIRTIED_FLAG;
- /* If there are no messages left in the index, delete it
- */
+ /* If there are no messages left in the index, delete it */
if(header->num_messages <=0) {
/* Unprotect cache and release heap */
diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h
index 1a45fcc..8d395df 100755
--- a/src/H5SMprivate.h
+++ b/src/H5SMprivate.h
@@ -39,7 +39,8 @@ H5_DLL herr_t H5SM_try_delete(H5F_t *f, hid_t dxpl_id, unsigned type_id, const H
H5_DLL herr_t H5SM_get_info(H5F_t *f, unsigned *index_flags, unsigned *minsizes,
unsigned *list_max, unsigned *btree_min, hid_t dxpl_id);
H5_DLL htri_t H5SM_type_shared(H5F_t *f, unsigned type_id, hid_t dxpl_id);
-H5_DLL haddr_t H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, hid_t dxpl_id);
+H5_DLL herr_t H5SM_get_fheap_addr(H5F_t *f, hid_t dxpl_id, unsigned type_id,
+ haddr_t *fheap_addr);
H5_DLL herr_t H5SM_reconstitute(H5O_shared_t *sh_mesg, const uint8_t *heap_id);
#endif /*_H5SMprivate_H*/
diff --git a/test/tattr.c b/test/tattr.c
index 99e03ab..1f7a750 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -1873,7 +1873,6 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-/* XXX: Add similar check to other tests that use new storage */
/* Check size of file */
filesize = h5_get_file_size(FILENAME);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
@@ -1898,6 +1897,8 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
unsigned min_dense; /* Minimum # of attributes to store "densely" */
htri_t is_dense; /* Are attributes stored densely? */
unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -1907,6 +1908,19 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
@@ -1982,9 +1996,17 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
+ /* Unlink dataset with attributes */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_open() */
/****************************************************************
@@ -2006,6 +2028,8 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
unsigned min_dense; /* Minimum # of attributes to store "densely" */
htri_t is_dense; /* Are attributes stored densely? */
unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
int attr_count; /* # of attributes */
herr_t ret; /* Generic return value */
@@ -2016,6 +2040,19 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
@@ -2128,9 +2165,17 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
+ /* Unlink dataset with attributes */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_delete() */
/****************************************************************
@@ -2152,8 +2197,10 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
unsigned max_compact; /* Maximum # of attributes to store compactly */
unsigned min_dense; /* Minimum # of attributes to store "densely" */
htri_t is_dense; /* Are attributes stored densely? */
- unsigned u; /* Local index variable */
int attr_count; /* # of attributes */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2163,6 +2210,19 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
@@ -2262,9 +2322,17 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
+ /* Unlink dataset with attributes */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_rename() */
/****************************************************************
@@ -2285,9 +2353,11 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
unsigned max_compact; /* Maximum # of attributes to store compactly */
unsigned min_dense; /* Minimum # of attributes to store "densely" */
htri_t is_dense; /* Are attributes stored densely? */
- unsigned u; /* Local index variable */
int attr_count; /* # of attributes */
size_t mesg_count; /* # of shared messages */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2297,6 +2367,19 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
@@ -2374,152 +2457,416 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_unlink() */
/****************************************************************
**
-** test_attr_shared_write(): Test basic H5A (attribute) code.
-** Tests writing to shared attributes in "compact" & "dense" storage
+** test_attr_dense_limits(): Test basic H5A (attribute) code.
+** Tests attribute in "dense" storage limits
**
****************************************************************/
static void
-test_attr_shared_write(hid_t fcpl, hid_t fapl)
+test_attr_dense_limits(hid_t fcpl, hid_t fapl)
{
hid_t fid; /* HDF5 File ID */
- hid_t dataset, dataset2; /* Dataset ID2 */
+ hid_t dataset; /* Dataset ID */
hid_t sid; /* Dataspace ID */
hid_t attr; /* Attribute ID */
hid_t dcpl; /* Dataset creation property list ID */
char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ unsigned max_compact, rmax_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense, rmin_dense; /* Minimum # of attributes to store "densely" */
htri_t is_dense; /* Are attributes stored densely? */
- htri_t is_shared; /* Is attributes shared? */
- hsize_t shared_refcount; /* Reference count of shared attribute */
- unsigned attr_value; /* Attribute value */
unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
- MESSAGE(5, ("Testing Writing to Shared Attributes in Compact & Dense Storage\n"));
+ MESSAGE(5, ("Testing Phase Change Limits For Attributes in Dense Storage\n"));
/* Create file */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Set up to query the object creation properties */
+ /* Query the group creation properties */
dcpl = H5Pcreate(H5P_DATASET_CREATE);
CHECK(dcpl, FAIL, "H5Pcreate");
- /* Create datasets */
+ /* Change limits on compact/dense attribute storage */
+ max_compact = 0;
+ min_dense = 0;
+ ret = H5Pset_attr_phase_change(dcpl, max_compact, min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+
+ /* Create a dataset */
dataset = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
CHECK(dataset, FAIL, "H5Dcreate");
- dataset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
- CHECK(dataset2, FAIL, "H5Dcreate");
/* Retrieve limits for compact/dense attribute storage */
- ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ ret = H5Pget_attr_phase_change(dcpl, &rmax_compact, &rmin_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+ VERIFY(rmax_compact, max_compact, "H5Pget_attr_phase_change");
+ VERIFY(rmin_dense, min_dense, "H5Pget_attr_phase_change");
#ifdef QAK
HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
#endif /* QAK */
- /* Check on datasets' attribute storage status */
+
+ /* Check on dataset's attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- is_dense = H5O_is_attr_dense_test(dataset2);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- /* Add attributes to each dataset, until after converting to dense storage */
-/* XXX: Test with shared & committed datatype/dataspace also */
- for(u = 0; u < max_compact * 2; u++) {
- /* Create attribute name */
- sprintf(attrname, "attr %02u", u);
- /* Create attribute on first dataset */
- attr = H5Acreate(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate");
+ /* Add first attribute, which should be immediately in dense storage */
- /* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ /* Create attribute */
+ u = 0;
+ sprintf(attrname, "attr %02u", u);
+ attr = H5Acreate(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
- /* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ /* Write data into the attribute */
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
+ CHECK(ret, FAIL, "H5Awrite");
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
- /* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ /* Add second attribute, to allow deletions to be checked easily */
- /* Create attribute on second dataset */
- attr = H5Acreate(dataset2, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate");
+ /* Create attribute */
+ u = 1;
+ sprintf(attrname, "attr %02u", u);
+ attr = H5Acreate(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
- /* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ /* Write data into the attribute */
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
+ CHECK(ret, FAIL, "H5Awrite");
- /* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
- /* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Delete second attribute, attributes should still be stored densely */
+
+ /* Delete attribute */
+ ret = H5Adelete(dataset, attrname);
+ CHECK(ret, FAIL, "H5Adelete");
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+
+
+ /* Delete first attribute, attributes should not be stored densely */
+
+ /* Delete attribute */
+ u = 0;
+ sprintf(attrname, "attr %02u", u);
+ ret = H5Adelete(dataset, attrname);
+ CHECK(ret, FAIL, "H5Adelete");
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- /* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset2);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
- } /* end for */
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
- /* Close Datasets */
+ /* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
- ret = H5Dclose(dataset2);
- CHECK(ret, FAIL, "H5Dclose");
+
+ /* Unlink dataset */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+} /* test_attr_dense_limits() */
+#endif /* QAK */
+
+/****************************************************************
+**
+** test_attr_shared_write(): Test basic H5A (attribute) code.
+** Tests writing to shared attributes in "compact" & "dense" storage
+**
+****************************************************************/
+static void
+test_attr_shared_write(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t my_fcpl; /* File creation property list ID */
+ hid_t dataset, dataset2; /* Dataset IDs */
+ hid_t attr_tid; /* Attribute's datatype ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ htri_t is_shared; /* Is attributes shared? */
+ hsize_t shared_refcount; /* Reference count of shared attribute */
+ unsigned attr_value; /* Attribute value */
+ size_t mesg_count; /* # of shared messages */
+ unsigned test_shared; /* Index over shared component type */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Writing to Shared Attributes in Compact & Dense Storage\n"));
+
+ /* Loop over type of shared components */
+ for(test_shared = 0; test_shared < 1; test_shared++) {
+ /* Make copy of file creation property list */
+ my_fcpl = H5Pcopy(fcpl);
+ CHECK(my_fcpl, FAIL, "H5Pcopy");
+
+ /* Special setup for each type of shared components */
+ switch(test_shared) {
+ case 0:
+ /* Set up datatype for attributes */
+ attr_tid = H5Tcopy(H5T_NATIVE_UINT);
+ CHECK(attr_tid, FAIL, "H5Tcopy");
+
+ /* Set up copy of file creation property list */
+ break;
+
+ case 1:
+ /* Set up datatype for attributes */
+ attr_tid = H5Tcopy(H5T_NATIVE_UINT);
+ CHECK(attr_tid, FAIL, "H5Tcopy");
+
+ /* Set up copy of file creation property list */
+
+ /* Make attributes & datatypes > 1 byte shared (i.e. all of them :-) */
+ ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)1, H5O_MESG_ATTR_FLAG, (unsigned)1);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+ ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)2, H5O_MESG_DTYPE_FLAG, (unsigned)1);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+ break;
+ } /* end switch */
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, my_fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Close FCPL copy */
+ ret = H5Pclose(my_fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Create dataspace for dataset */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Set up to query the object creation properties */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Create datasets */
+ dataset = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset, FAIL, "H5Dcreate");
+ dataset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset2, FAIL, "H5Dcreate");
+
+ /* Check on datatype storage status */
+ /* (dataset's datatypes are immutable and shouldn't be shared) */
+ switch(test_shared) {
+ case 1:
+ ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ break;
+ } /* end switch */
+
+ /* Retrieve limits for compact/dense attribute storage */
+ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+#ifdef QAK
+ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
+#endif /* QAK */
+
+ /* Check on datasets' attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+
+ /* Add attributes to each dataset, until after converting to dense storage */
+/* XXX: Test with shared & committed datatype/dataspace also */
+ for(u = 0; u < max_compact * 2; u++) {
+ /* Create attribute name */
+ sprintf(attrname, "attr %02u", u);
+
+ /* Create attribute on first dataset */
+ attr = H5Acreate(dataset, attrname, attr_tid, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
+
+ /* Check that attribute is shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+
+ /* Check refcount for attribute */
+ ret = H5A_get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A_get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+
+ /* Write data into the attribute */
+ attr_value = u + 1;
+ ret = H5Awrite(attr, attr_tid, &attr_value);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+
+
+ /* Create attribute on second dataset */
+ attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
+
+ /* Check that attribute is shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+
+ /* Check refcount for attribute */
+ ret = H5A_get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A_get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+
+ /* Write data into the attribute */
+ attr_value = u + 1;
+ ret = H5Awrite(attr, attr_tid, &attr_value);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Check refcount for attribute */
+ ret = H5A_get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A_get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ } /* end for */
+
+ /* Close attribute's datatype */
+ ret = H5Tclose(attr_tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close Datasets */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Dclose(dataset2);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Unlink datasets with attributes */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+ ret = H5Gunlink(fid, DSET2_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+ /* Check on attribute storage status */
+ ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ switch(test_shared) {
+ case 1:
+ /* Check on datatype storage status */
+ ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ break;
+ } /* end switch */
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end for */
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_shared_write() */
+#ifndef QAK
/****************************************************************
**
** test_attr_shared_rename(): Test basic H5A (attribute) code.
@@ -2543,6 +2890,8 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
hsize_t shared_refcount; /* Reference count of shared attribute */
unsigned attr_value; /* Attribute value */
unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2552,6 +2901,19 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
@@ -2747,11 +3109,20 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
ret = H5Dclose(dataset2);
CHECK(ret, FAIL, "H5Dclose");
+ /* Unlink datasets with attributes */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+ ret = H5Gunlink(fid, DSET2_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_shared_rename() */
-#endif /* QAK */
/****************************************************************
**
@@ -2775,6 +3146,8 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
hsize_t shared_refcount; /* Reference count of shared attribute */
unsigned attr_value; /* Attribute value */
unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2784,6 +3157,19 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
@@ -2923,13 +3309,226 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
ret = H5Dclose(dataset2);
CHECK(ret, FAIL, "H5Dclose");
+ /* Unlink datasets with attributes */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+ ret = H5Gunlink(fid, DSET2_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_shared_delete() */
/****************************************************************
**
+** test_attr_shared_unlink(): Test basic H5A (attribute) code.
+** Tests unlinking object with shared attributes in "compact" & "dense" storage
+**
+****************************************************************/
+static void
+test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset, dataset2; /* Dataset ID2 */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ htri_t is_shared; /* Is attributes shared? */
+ hsize_t shared_refcount; /* Reference count of shared attribute */
+ unsigned attr_value; /* Attribute value */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Unlinking Object with Shared Attributes in Compact & Dense Storage\n"));
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Create dataspace for dataset */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Set up to query the object creation properties */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Create datasets */
+ dataset = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset, FAIL, "H5Dcreate");
+ dataset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset2, FAIL, "H5Dcreate");
+
+ /* Retrieve limits for compact/dense attribute storage */
+ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+#ifdef QAK
+HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
+#endif /* QAK */
+
+ /* Check on datasets' attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+
+ /* Add attributes to each dataset, until after converting to dense storage */
+/* XXX: Test with shared & committed datatype/dataspace also */
+ for(u = 0; u < max_compact * 2; u++) {
+ /* Create attribute name */
+ sprintf(attrname, "attr %02u", u);
+
+ /* Create attribute on first dataset */
+ attr = H5Acreate(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
+
+ /* Check that attribute is shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+
+ /* Check refcount for attribute */
+ ret = H5A_get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A_get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+
+ /* Write data into the attribute */
+ attr_value = u + 1;
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+
+
+ /* Create attribute on second dataset */
+ attr = H5Acreate(dataset2, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
+
+ /* Check that attribute is shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+
+ /* Check refcount for attribute */
+ ret = H5A_get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A_get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+
+ /* Write data into the attribute */
+ attr_value = u + 1;
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Check refcount for attribute */
+ ret = H5A_get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A_get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ } /* end for */
+
+
+ /* Close second dataset */
+ ret = H5Dclose(dataset2);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Unlink second dataset */
+ ret = H5Gunlink(fid, DSET2_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+
+ /* Check on first dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+
+ /* Check ref count on attributes of first dataset */
+ for(u = 0; u < max_compact * 2; u++) {
+ /* Create attribute name */
+ sprintf(attrname, "attr %02u", u);
+
+ /* Open attribute on first dataset */
+ attr = H5Aopen_name(dataset, attrname);
+ CHECK(attr, FAIL, "H5Acreate");
+
+ /* Check that attribute is shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+
+ /* Check refcount for attribute */
+ ret = H5A_get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A_get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+ } /* end for */
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close Datasets */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Unlink first dataset */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+} /* test_attr_shared_unlink() */
+#endif /* QAK */
+
+/****************************************************************
+**
** test_attr(): Main H5A (attribute) testing routine.
**
****************************************************************/
@@ -3032,15 +3631,17 @@ test_attr(void)
test_attr_dense_delete(my_fcpl, fapl2); /* Test deleting attributes in dense storage */
test_attr_dense_rename(my_fcpl, fapl2); /* Test renaming attributes in dense storage */
test_attr_dense_unlink(my_fcpl, fapl2); /* Test unlinking object with attributes in dense storage */
+ test_attr_dense_limits(my_fcpl, fapl2); /* Test dense attribute storage limits */
} /* end for */
- /* Tests with both "new format" and "shared" attributes */
+ /* More complex tests with both "new format" and "shared" attributes */
test_attr_shared_write(fcpl2, fapl2); /* Test writing to shared attributes in compact & dense storage */
test_attr_shared_rename(fcpl2, fapl2); /* Test renaming shared attributes in compact & dense storage */
test_attr_shared_delete(fcpl2, fapl2); /* Test deleting shared attributes in compact & dense storage */
-/* XXX: Unlinking object */
+ test_attr_shared_unlink(fcpl2, fapl2); /* Test unlinking object with shared attributes in compact & dense storage */
#else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n");
+ test_attr_shared_write(fcpl2, fapl2); /* Test writing to shared attributes in compact & dense storage */
#endif /* QAK */
/* Close FCPLs */