summaryrefslogtreecommitdiffstats
path: root/src/H5Defl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Defl.c')
-rw-r--r--src/H5Defl.c110
1 files changed, 86 insertions, 24 deletions
diff --git a/src/H5Defl.c b/src/H5Defl.c
index 647f02c..8b2da6a 100644
--- a/src/H5Defl.c
+++ b/src/H5Defl.c
@@ -32,6 +32,7 @@
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
+#include "H5HLprivate.h" /* Local Heaps */
/****************/
@@ -49,8 +50,7 @@
/********************/
/* Layout operation callbacks */
-static herr_t H5D_efl_new(H5F_t *f, hid_t dxpl_id, H5D_t *dset,
- const H5P_genplist_t *dc_plist);
+static herr_t H5D_efl_construct(H5F_t *f, H5D_t *dset);
static herr_t H5D_efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
H5D_chunk_map_t *cm);
@@ -74,7 +74,9 @@ static herr_t H5D_efl_write(const H5O_efl_t *efl, haddr_t addr, size_t size,
/* External File List (EFL) storage layout I/O ops */
const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{
- H5D_efl_new,
+ H5D_efl_construct,
+ NULL,
+ H5D_efl_is_space_alloc,
H5D_efl_io_init,
H5D_contig_read,
H5D_contig_write,
@@ -84,6 +86,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{
#endif /* H5_HAVE_PARALLEL */
H5D_efl_readvv,
H5D_efl_writevv,
+ NULL,
NULL
}};
@@ -95,7 +98,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5D_efl_new
+ * Function: H5D_efl_construct
*
* Purpose: Constructs new EFL layout information for dataset
*
@@ -107,10 +110,9 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_efl_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset,
- const H5P_genplist_t UNUSED *dc_plist)
+H5D_efl_construct(H5F_t *f, H5D_t *dset)
{
- const H5T_t *type = dset->shared->type; /* Convenience pointer to dataset's datatype */
+ size_t dt_size; /* Size of datatype */
hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */
hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */
hssize_t tmp_size; /* Temporary holder for raw data size */
@@ -120,19 +122,17 @@ H5D_efl_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset,
int i; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_efl_new)
+ FUNC_ENTER_NOAPI_NOINIT(H5D_efl_construct)
/* Sanity checks */
HDassert(f);
HDassert(dset);
- HDassert(dc_plist);
/*
* The maximum size of the dataset cannot exceed the storage size.
* Also, only the slowest varying dimension of a simple data space
* can be extendible (currently only for external data storage).
*/
- dset->shared->layout.u.contig.addr = HADDR_UNDEF; /* Initialize to no address */
/* Check for invalid dataset dimensions */
if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dim, max_dim)) < 0)
@@ -141,28 +141,57 @@ H5D_efl_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset,
if(max_dim[i] > dim[i])
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "only the first dimension can be extendible")
+ /* Retrieve the size of the dataset's datatype */
+ if(0 == (dt_size = H5T_get_size(dset->shared->type)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size")
+
/* Check for storage overflows */
max_points = H5S_get_npoints_max(dset->shared->space);
max_storage = H5O_efl_total_size(&dset->shared->dcpl_cache.efl);
if(H5S_UNLIMITED == max_points) {
if(H5O_EFL_UNLIMITED != max_storage)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unlimited data space but finite storage")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unlimited dataspace but finite storage")
} /* end if */
- else if(max_points * H5T_get_size(type) < max_points)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data space * type size overflowed")
- else if(max_points * H5T_get_size(type) > max_storage)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data space size exceeds external storage size")
+ else if((max_points * dt_size) < max_points)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace * type size overflowed")
+ else if((max_points * dt_size) > max_storage)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace size exceeds external storage size")
/* Compute the total size of dataset */
- tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * H5T_get_size(type);
- H5_ASSIGN_OVERFLOW(dset->shared->layout.u.contig.size, tmp_size, hssize_t, hsize_t);
+ tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * dt_size;
+ H5_ASSIGN_OVERFLOW(dset->shared->layout.storage.u.contig.size, tmp_size, hssize_t, hsize_t);
/* Get the sieve buffer size for this dataset */
dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(f);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_efl_new() */
+} /* end H5D_efl_construct() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_efl_is_space_alloc
+ *
+ * Purpose: Query if space is allocated for layout
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, January 15, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5D_efl_is_space_alloc(const H5O_storage_t UNUSED *storage)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_efl_is_space_alloc)
+
+ /* Sanity checks */
+ HDassert(storage);
+
+ /* EFL storage is currently always treated as allocated */
+ FUNC_LEAVE_NOAPI(TRUE)
+} /* end H5D_efl_is_space_alloc() */
/*-------------------------------------------------------------------------
@@ -257,12 +286,11 @@ H5D_efl_read(const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf)
#else /* NDEBUG */
to_read = MIN((size_t)(efl->slot[u].size-skip), size);
#endif /* NDEBUG */
- if ((n=HDread (fd, buf, to_read))<0) {
- HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file")
- } else if ((size_t)n<to_read) {
- HDmemset (buf+n, 0, to_read-n);
- }
- HDclose (fd);
+ if((n = HDread(fd, buf, to_read)) < 0)
+ HGOTO_ERROR(H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file")
+ else if((size_t)n < to_read)
+ HDmemset(buf + n, 0, to_read - (size_t)n);
+ HDclose(fd);
fd = -1;
size -= to_read;
buf += to_read;
@@ -528,3 +556,37 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_efl_writevv() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_efl_bh_size
+ *
+ * Purpose: Retrieve the amount of heap storage used for External File
+ * List message
+ *
+ * Return: Success: Non-negative
+ * Failure: negative
+ *
+ * Programmer: Vailin Choi; August 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_efl_bh_info(H5F_t *f, hid_t dxpl_id, H5O_efl_t *efl, hsize_t *heap_size)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5D_efl_bh_info, FAIL)
+
+ /* Check args */
+ HDassert(f);
+ HDassert(efl);
+ HDassert(H5F_addr_defined(efl->heap_addr));
+ HDassert(heap_size);
+
+ /* Get the size of the local heap for EFL's file list */
+ if(H5HL_heapsize(f, dxpl_id, efl->heap_addr, heap_size) < 0)
+ HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, FAIL, "unable to retrieve local heap info")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_chunk_bh_info() */