summaryrefslogtreecommitdiffstats
path: root/src/H5Defl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Defl.c')
-rw-r--r--src/H5Defl.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/H5Defl.c b/src/H5Defl.c
index 7dac29b..15bcd60 100644
--- a/src/H5Defl.c
+++ b/src/H5Defl.c
@@ -49,6 +49,8 @@
/********************/
/* 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_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);
@@ -72,6 +74,7 @@ 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_io_init,
H5D_contig_read,
H5D_contig_write,
@@ -92,6 +95,77 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{
/*-------------------------------------------------------------------------
+ * Function: H5D_efl_new
+ *
+ * Purpose: Constructs new EFL layout information for dataset
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, May 22, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5D_efl_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset,
+ const H5P_genplist_t *dc_plist)
+{
+ const H5T_t *type = dset->shared->type; /* Convenience pointer to dataset's 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 */
+ hsize_t max_points; /* Maximum elements */
+ hsize_t max_storage; /* Maximum storage size */
+ int ndims; /* Rank of dataspace */
+ int i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5D_efl_new)
+
+ /* 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)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage")
+ for(i = 1; i < ndims; i++)
+ if(max_dim[i] > dim[i])
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "only the first dimension can be extendible")
+
+ /* 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")
+ } /* 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")
+
+ /* 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);
+
+ /* 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() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D_efl_io_init
*
* Purpose: Performs initialization before any sort of I/O on the raw data