summaryrefslogtreecommitdiffstats
path: root/src/H5Dlayout.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dlayout.c')
-rw-r--r--src/H5Dlayout.c204
1 files changed, 98 insertions, 106 deletions
diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c
index 94d4c6b..71f64ba 100644
--- a/src/H5Dlayout.c
+++ b/src/H5Dlayout.c
@@ -15,49 +15,40 @@
/* Module Setup */
/****************/
-#define H5D_PACKAGE /*suppress error about including H5Dpkg */
-
+#define H5D_PACKAGE /*suppress error about including H5Dpkg */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Dpkg.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HLprivate.h" /* Local heaps */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Dpkg.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HLprivate.h" /* Local heaps */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Local Prototypes */
/********************/
-
/*********************/
/* Package Variables */
/*********************/
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5D__layout_set_io_ops
*
@@ -74,7 +65,7 @@
herr_t
H5D__layout_set_io_ops(const H5D_t *dataset)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -82,9 +73,9 @@ H5D__layout_set_io_ops(const H5D_t *dataset)
HDassert(dataset);
/* Set the I/O functions for each layout type */
- switch(dataset->shared->layout.type) {
+ switch (dataset->shared->layout.type) {
case H5D_CONTIGUOUS:
- if(dataset->shared->dcpl_cache.efl.nused > 0)
+ if (dataset->shared->dcpl_cache.efl.nused > 0)
dataset->shared->layout.ops = H5D_LOPS_EFL;
else
dataset->shared->layout.ops = H5D_LOPS_CONTIG;
@@ -112,7 +103,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__layout_set_io_ops() */
-
/*-------------------------------------------------------------------------
* Function: H5D__layout_meta_size
*
@@ -131,7 +121,7 @@ done:
size_t
H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data)
{
- size_t ret_value;
+ size_t ret_value;
FUNC_ENTER_PACKAGE
@@ -139,20 +129,20 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ
HDassert(f);
HDassert(layout);
- ret_value = 1 + /* Version number */
- 1; /* layout class type */
+ ret_value = 1 + /* Version number */
+ 1; /* layout class type */
- switch(layout->type) {
+ switch (layout->type) {
case H5D_COMPACT:
/* Size of raw data */
ret_value += 2;
- if(include_compact_data)
- ret_value += layout->storage.u.compact.size;/* data for compact dataset */
+ if (include_compact_data)
+ ret_value += layout->storage.u.compact.size; /* data for compact dataset */
break;
case H5D_CONTIGUOUS:
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
- ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */
+ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
+ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */
break;
case H5D_CHUNKED:
@@ -164,7 +154,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ
ret_value += layout->u.chunk.ndims * 4;
/* B-tree address */
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
+ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
break;
case H5D_LAYOUT_ERROR:
@@ -177,7 +167,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__layout_meta_size() */
-
/*-------------------------------------------------------------------------
* Function: H5D__layout_oh_create
*
@@ -192,13 +181,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset,
- hid_t dapl_id)
+H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, hid_t dapl_id)
{
- H5O_layout_t *layout; /* Dataset's layout information */
- const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */
- hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5O_layout_t * layout; /* Dataset's layout information */
+ const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */
+ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -208,20 +196,21 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset,
HDassert(dset);
/* Set some local variables, for convenience */
- layout = &dset->shared->layout;
+ layout = &dset->shared->layout;
fill_prop = &dset->shared->dcpl_cache.fill;
/* Update the filters message, if this is a chunked dataset */
- if(layout->type == H5D_CHUNKED) {
- H5O_pline_t *pline; /* Dataset's I/O pipeline information */
+ if (layout->type == H5D_CHUNKED) {
+ H5O_pline_t *pline; /* Dataset's I/O pipeline information */
pline = &dset->shared->dcpl_cache.pline;
- if(pline->nused > 0 && H5O_msg_append_oh(file, dxpl_id, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, pline) < 0)
+ if (pline->nused > 0 &&
+ H5O_msg_append_oh(file, dxpl_id, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, pline) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message")
} /* end if */
/* Initialize the layout information for the new dataset */
- if(dset->shared->layout.ops->init && (dset->shared->layout.ops->init)(file, dxpl_id, dset, dapl_id) < 0)
+ if (dset->shared->layout.ops->init && (dset->shared->layout.ops->init)(file, dxpl_id, dset, dapl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize layout information")
/* Indicate that the layout information was initialized */
@@ -231,41 +220,41 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset,
* Allocate storage if space allocate time is early; otherwise delay
* allocation until later.
*/
- if(fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY)
- if(H5D__alloc_storage(dset, dxpl_id, H5D_ALLOC_CREATE, FALSE, NULL) < 0)
+ if (fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY)
+ if (H5D__alloc_storage(dset, dxpl_id, H5D_ALLOC_CREATE, FALSE, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage")
/* Update external storage message, if it's used */
- if(dset->shared->dcpl_cache.efl.nused > 0) {
+ if (dset->shared->dcpl_cache.efl.nused > 0) {
H5O_efl_t *efl = &dset->shared->dcpl_cache.efl; /* Dataset's external file list */
- H5HL_t *heap; /* Pointer to local heap for EFL file names */
- size_t heap_size = H5HL_ALIGN(1);
- size_t u;
+ H5HL_t * heap; /* Pointer to local heap for EFL file names */
+ size_t heap_size = H5HL_ALIGN(1);
+ size_t u;
/* Determine size of heap needed to stored the file names */
- for(u = 0; u < efl->nused; ++u)
+ for (u = 0; u < efl->nused; ++u)
heap_size += H5HL_ALIGN(HDstrlen(efl->slot[u].name) + 1);
/* Create the heap for the EFL file names */
- if(H5HL_create(file, dxpl_id, heap_size, &efl->heap_addr/*out*/) < 0)
+ if (H5HL_create(file, dxpl_id, heap_size, &efl->heap_addr /*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create EFL file name heap")
/* Pin the heap down in memory */
- if(NULL == (heap = H5HL_protect(file, dxpl_id, efl->heap_addr, H5AC_WRITE)))
+ if (NULL == (heap = H5HL_protect(file, dxpl_id, efl->heap_addr, H5AC_WRITE)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect EFL file name heap")
/* Insert "empty" name first */
- if((size_t)(-1) == H5HL_insert(file, dxpl_id, heap, (size_t)1, "")) {
+ if ((size_t)(-1) == H5HL_insert(file, dxpl_id, heap, (size_t)1, "")) {
H5HL_unprotect(heap);
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap")
} /* end if */
- for(u = 0; u < efl->nused; ++u) {
- size_t offset; /* Offset of file name in heap */
+ for (u = 0; u < efl->nused; ++u) {
+ size_t offset; /* Offset of file name in heap */
/* Insert file name into heap */
- if((size_t)(-1) == (offset = H5HL_insert(file, dxpl_id, heap,
- HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name))) {
+ if ((size_t)(-1) == (offset = H5HL_insert(file, dxpl_id, heap, HDstrlen(efl->slot[u].name) + 1,
+ efl->slot[u].name))) {
H5HL_unprotect(heap);
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap")
} /* end if */
@@ -276,34 +265,38 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset,
} /* end for */
/* Release the heap */
- if(H5HL_unprotect(heap) < 0)
+ if (H5HL_unprotect(heap) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to unprotect EFL file name heap")
heap = NULL;
/* Insert EFL message into dataset object header */
- if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, 0, efl) < 0)
+ if (H5O_msg_append_oh(file, dxpl_id, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, 0, efl) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message")
} /* end if */
/* Create layout message */
- /* (Don't make layout message constant unless allocation time is early, since space may not be allocated) */
+ /* (Don't make layout message constant unless allocation time is early, since space may not be allocated)
+ */
/* (Note: this is relying on H5D__alloc_storage not calling H5O_msg_write during dataset creation) */
- if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID, ((fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type) ? H5O_MSG_FLAG_CONSTANT : 0), 0, layout) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout")
+ if (H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID,
+ ((fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type)
+ ? H5O_MSG_FLAG_CONSTANT
+ : 0),
+ 0, layout) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout")
done:
/* Error cleanup */
- if(ret_value < 0) {
- if(dset->shared->layout.type == H5D_CHUNKED && layout_init) {
- if(H5D__chunk_dest(file, dxpl_id, dset) < 0)
+ if (ret_value < 0) {
+ if (dset->shared->layout.type == H5D_CHUNKED && layout_init) {
+ if (H5D__chunk_dest(file, dxpl_id, dset) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache")
} /* end if */
- } /* end if */
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__layout_oh_create() */
-
/*-------------------------------------------------------------------------
* Function: H5D__layout_oh_read
*
@@ -320,8 +313,8 @@ done:
herr_t
H5D__layout_oh_read(H5D_t *dataset, hid_t dxpl_id, hid_t dapl_id, H5P_genplist_t *plist)
{
- htri_t msg_exists; /* Whether a particular type of message exists */
- herr_t ret_value = SUCCEED; /* Return value */
+ htri_t msg_exists; /* Whether a particular type of message exists */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -330,15 +323,15 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dxpl_id, hid_t dapl_id, H5P_genplist_t
HDassert(plist);
/* Get the optional filters message */
- if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_PLINE_ID, dxpl_id)) < 0)
+ if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_PLINE_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists")
- if(msg_exists) {
+ if (msg_exists) {
/* Retrieve the I/O pipeline message */
- if(NULL == H5O_msg_read(&(dataset->oloc), H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline, dxpl_id))
+ if (NULL == H5O_msg_read(&(dataset->oloc), H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline, dxpl_id))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message")
/* Set the I/O pipeline info in the property list */
- if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0)
+ if (H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set pipeline")
} /* end if */
@@ -348,19 +341,19 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dxpl_id, hid_t dapl_id, H5P_genplist_t
* values are copied to the dataset create plist so the user can query
* them.
*/
- if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id))
+ if (NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message")
/* Check for external file list message (which might not exist) */
- if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_EFL_ID, dxpl_id)) < 0)
+ if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_EFL_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists")
- if(msg_exists) {
+ if (msg_exists) {
/* Retrieve the EFL message */
- if(NULL == H5O_msg_read(&(dataset->oloc), H5O_EFL_ID, &dataset->shared->dcpl_cache.efl, dxpl_id))
+ if (NULL == H5O_msg_read(&(dataset->oloc), H5O_EFL_ID, &dataset->shared->dcpl_cache.efl, dxpl_id))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message")
/* Set the EFL info in the property list */
- if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->dcpl_cache.efl) < 0)
+ if (H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->dcpl_cache.efl) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set external file list")
/* Set the dataset's I/O operations */
@@ -371,66 +364,66 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dxpl_id, hid_t dapl_id, H5P_genplist_t
HDassert(dataset->shared->layout.ops);
/* Adjust chunk dimensions to omit datatype size (in last dimension) for creation property */
- if(H5D_CHUNKED == dataset->shared->layout.type)
+ if (H5D_CHUNKED == dataset->shared->layout.type)
dataset->shared->layout.u.chunk.ndims--;
/* Copy layout to the DCPL */
- if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0)
+ if (H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout")
/* Adjust chunk dimensions back again (*sigh*) */
- if(H5D_CHUNKED == dataset->shared->layout.type)
+ if (H5D_CHUNKED == dataset->shared->layout.type)
dataset->shared->layout.u.chunk.ndims++;
- switch(dataset->shared->layout.type) {
- case H5D_CONTIGUOUS:
- {
- hsize_t tmp_size; /* Temporary holder for raw data size */
- size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */
+ switch (dataset->shared->layout.type) {
+ case H5D_CONTIGUOUS: {
+ hsize_t tmp_size; /* Temporary holder for raw data size */
+ size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */
/* Compute the size of the contiguous storage for versions of the
* layout message less than version 3 because versions 1 & 2 would
* truncate the dimension sizes to 32-bits of information. - QAK 5/26/04
*/
- if(dataset->shared->layout.version < 3) {
- hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
- hsize_t nelmts; /* Number of elements in dataspace */
- size_t dt_size; /* Size of datatype */
+ if (dataset->shared->layout.version < 3) {
+ hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
+ hsize_t nelmts; /* Number of elements in dataspace */
+ size_t dt_size; /* Size of datatype */
/* Retrieve the number of elements in the dataspace */
- if((snelmts = H5S_GET_EXTENT_NPOINTS(dataset->shared->space)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
+ if ((snelmts = H5S_GET_EXTENT_NPOINTS(dataset->shared->space)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
+ "unable to retrieve number of elements in dataspace")
nelmts = (hsize_t)snelmts;
/* Get the datatype's size */
- if(0 == (dt_size = H5T_GET_SIZE(dataset->shared->type)))
+ if (0 == (dt_size = H5T_GET_SIZE(dataset->shared->type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype")
/* Compute the size of the dataset's contiguous storage */
tmp_size = nelmts * dt_size;
/* Check for overflow during multiplication */
- if(nelmts != (tmp_size / dt_size))
+ if (nelmts != (tmp_size / dt_size))
HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
/* Assign the dataset's contiguous storage size */
dataset->shared->layout.storage.u.contig.size = tmp_size;
- } else
+ }
+ else
tmp_size = dataset->shared->layout.storage.u.contig.size;
- /* Get the sieve buffer size for the file */
- tmp_sieve_buf_size = H5F_SIEVE_BUF_SIZE(dataset->oloc.file);
+ /* Get the sieve buffer size for the file */
+ tmp_sieve_buf_size = H5F_SIEVE_BUF_SIZE(dataset->oloc.file);
- /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size
- * from the file access property. (SLU - 2012/3/30) */
- if(tmp_size < tmp_sieve_buf_size)
- dataset->shared->cache.contig.sieve_buf_size = tmp_size;
- else
- dataset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size;
- }
- break;
+ /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size
+ * from the file access property. (SLU - 2012/3/30) */
+ if (tmp_size < tmp_sieve_buf_size)
+ dataset->shared->cache.contig.sieve_buf_size = tmp_size;
+ else
+ dataset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size;
+ } break;
case H5D_CHUNKED:
/* Initialize the chunk cache for the dataset */
- if(H5D__chunk_init(dataset->oloc.file, dxpl_id, dataset, dapl_id) < 0)
+ if (H5D__chunk_init(dataset->oloc.file, dxpl_id, dataset, dapl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache")
break;
@@ -447,7 +440,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__layout_oh_read() */
-
/*-------------------------------------------------------------------------
* Function: H5D__layout_oh_write
*
@@ -464,7 +456,7 @@ done:
herr_t
H5D__layout_oh_write(H5D_t *dataset, hid_t dxpl_id, H5O_t *oh, unsigned update_flags)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -473,10 +465,10 @@ H5D__layout_oh_write(H5D_t *dataset, hid_t dxpl_id, H5O_t *oh, unsigned update_f
HDassert(oh);
/* Write the layout message to the dataset's header */
- if(H5O_msg_write_oh(dataset->oloc.file, dxpl_id, oh, H5O_LAYOUT_ID, H5O_MSG_FLAG_CONSTANT, update_flags, &dataset->shared->layout) < 0)
+ if (H5O_msg_write_oh(dataset->oloc.file, dxpl_id, oh, H5O_LAYOUT_ID, H5O_MSG_FLAG_CONSTANT, update_flags,
+ &dataset->shared->layout) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout message")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__layout_oh_write() */
-