summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-04-06 14:12:32 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-04-06 14:12:32 (GMT)
commit97ad052c7730b618fdf2ad2817e732f2d6c742dd (patch)
tree65658dd3561377855ba3d59674e3db34cfa60588 /src
parentd28a427769c4bc1ff3076a74dcff524db29e593b (diff)
parent043aabe8cbd1abcc41ea2fb887b3a8ddd706500c (diff)
downloadhdf5-97ad052c7730b618fdf2ad2817e732f2d6c742dd.zip
hdf5-97ad052c7730b618fdf2ad2817e732f2d6c742dd.tar.gz
hdf5-97ad052c7730b618fdf2ad2817e732f2d6c742dd.tar.bz2
Merging in latest from upstream (HDFFV/hdf5:refs/heads/hdf5_1_8)
* commit '043aabe8cbd1abcc41ea2fb887b3a8ddd706500c': Made corrections according to code review. 1) Change fprintf to HDfprintf in hl/test/test_dset_opt.c 2) Remove extra line in src/H5Dpkg.h 3) Add one more test to hl/test/test_dset_opt.c Tested on mayll and osx1010test. Incorporate patch from GE Heathcare (HDFFV-9934) 1) Integrate the patch 2) Fix bugs when debugging the patch 3) Add test to hl/test/test_dset_opt.c Tested on moohan, ostrich, platypus, emu, osx1010test, quail, kituo, mayll.
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c43
-rw-r--r--src/H5Dchunk.c306
-rw-r--r--src/H5Dio.c210
-rw-r--r--src/H5Dpkg.h3
-rw-r--r--src/H5Dpublic.h11
-rw-r--r--src/H5Pdxpl.c28
6 files changed, 473 insertions, 128 deletions
diff --git a/src/H5D.c b/src/H5D.c
index cd3d989..7f2a96d 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -416,7 +416,7 @@ H5Dclose(hid_t dset_id)
/*
* Decrement the counter on the dataset. It will be freed if the count
- * reaches zero.
+ * reaches zero.
*
* Pass in TRUE for the 3rd parameter to tell the function to remove
* dataset's ID even though the freeing function might fail. Please
@@ -1002,3 +1002,44 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dset_extent() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Dget_chunk_storage_size
+ *
+ * Purpose: Returns the size of an allocated of chunk.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Matthew Strong (GE Healthcare)
+ * 20 October 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_nbytes)
+{
+ H5D_t *dset = NULL;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("h", "i", dset_id);
+
+ /* Check arguments */
+ if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ if( NULL == offset )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)")
+ if( NULL == chunk_nbytes )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)")
+
+ if(H5D_CHUNKED != dset->shared->layout.type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
+
+ /* Call private function */
+ if(H5D__get_chunk_storage_size(dset, H5AC_ind_dxpl_id, offset, chunk_nbytes) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk")
+
+done:
+ FUNC_LEAVE_API(ret_value);
+}
+
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 3bac996..a55a156 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -242,6 +242,9 @@ static herr_t H5D__chunk_collective_fill(const H5D_t *dset, hid_t dxpl_id,
H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, const void *fill_buf);
#endif /* H5_HAVE_PARALLEL */
+static int
+H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata);
+
/*********************/
/* Package Variables */
/*********************/
@@ -303,8 +306,7 @@ H5FL_BLK_DEFINE_STATIC(chunk);
/*-------------------------------------------------------------------------
* Function: H5D__chunk_direct_write
*
- * Purpose: Internal routine to write a chunk
- * directly into the file.
+ * Purpose: Internal routine to write a chunk directly into the file.
*
* Return: Non-negative on success/Negative on failure
*
@@ -314,16 +316,16 @@ H5FL_BLK_DEFINE_STATIC(chunk);
*-------------------------------------------------------------------------
*/
herr_t
-H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsize_t *offset,
+H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsize_t *offset,
uint32_t data_size, const void *buf)
{
const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */
H5D_chunk_ud_t udata; /* User data for querying chunk info */
- hsize_t chunk_idx;
+ hsize_t chunk_idx; /* Index of chunk cache entry */
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */
- int space_ndims; /* Dataset's space rank */
+ unsigned space_ndims; /* Dataset's space rank */
hsize_t space_dim[H5O_LAYOUT_NDIMS]; /* Dataset's dataspace dimensions */
herr_t ret_value = SUCCEED; /* Return value */
@@ -331,17 +333,16 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz
/* Allocate data space and initialize it if it hasn't been. */
if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage))
- /* Allocate storage */
+ /* Allocate storage */
if(H5D__alloc_storage(dset, dxpl_id, H5D_ALLOC_WRITE, FALSE, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage")
/* Retrieve the dataset dimensions */
- if((space_ndims = H5S_get_simple_extent_dims(dset->shared->space, space_dim, NULL)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get simple dataspace info")
+ space_ndims = dset->shared->layout.u.chunk.ndims - 1;
/* Calculate the index of this chunk */
- if(H5VM_chunk_index((unsigned)space_ndims, offset,
- layout->u.chunk.dim, layout->u.chunk.down_chunks, &chunk_idx) < 0)
+ if(H5VM_chunk_index(space_ndims, offset,
+ layout->u.chunk.dim, layout->u.chunk.down_chunks, &chunk_idx) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get chunk index")
/* Find out the file address of the chunk */
@@ -354,28 +355,28 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz
* the 'insert' operation could resize it)
*/
{
- H5D_chk_idx_info_t idx_info; /* Chunked index info */
+ H5D_chk_idx_info_t idx_info; /* Chunked index info */
- /* Compose chunked index info struct */
- idx_info.f = dset->oloc.file;
- idx_info.dxpl_id = dxpl_id;
- idx_info.pline = &(dset->shared->dcpl_cache.pline);
- idx_info.layout = &(dset->shared->layout.u.chunk);
- idx_info.storage = &(dset->shared->layout.storage.u.chunk);
+ /* Compose chunked index info struct */
+ idx_info.f = dset->oloc.file;
+ idx_info.dxpl_id = dxpl_id;
+ idx_info.pline = &(dset->shared->dcpl_cache.pline);
+ idx_info.layout = &(dset->shared->layout.u.chunk);
+ idx_info.storage = &(dset->shared->layout.storage.u.chunk);
- /* Set up the size of chunk for user data */
- udata.nbytes = data_size;
+ /* Set up the size of chunk for user data */
+ udata.nbytes = data_size;
/* Create the chunk it if it doesn't exist, or reallocate the chunk
* if its size changed.
*/
- if((dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk")
+ if((dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk")
- /* Make sure the address of the chunk is returned. */
- if(!H5F_addr_defined(udata.addr))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined")
- } /* end if */
+ /* Make sure the address of the chunk is returned. */
+ if(!H5F_addr_defined(udata.addr))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined")
+ }
/* Fill the DXPL cache values for later use */
if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0)
@@ -385,7 +386,7 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz
* it to disk */
if(UINT_MAX != udata.idx_hint)
if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, rdcc->slot[udata.idx_hint], FALSE) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk")
/* Write the data to the file */
if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, data_size, dxpl_id, buf) < 0)
@@ -395,6 +396,222 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__chunk_direct_write() */
+/*-------------------------------------------------------------------------
+ * Function: H5D__chunk_direct_read
+ *
+ * Purpose: Internal routine to read a chunk directly from the file.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Matthew Strong (GE Healthcare)
+ * 14 February 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D__chunk_direct_read(const H5D_t *dset, hid_t dxpl_id, hsize_t *offset,
+ uint32_t* filters, void *buf)
+{
+ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */
+ const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */
+ H5D_chunk_ud_t udata; /* User data for querying chunk info */
+ unsigned space_ndims; /* Dataset's space rank */
+ hsize_t space_dim[H5O_LAYOUT_NDIMS]; /* Dataset's dataspace dimensions */
+ hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Dataset's chunk offset */
+ hsize_t chunk_idx; /* Index of chunk cache entry */
+ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
+ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Check args */
+ HDassert(dset && H5D_CHUNKED == layout->type);
+ HDassert(offset);
+ HDassert(filters);
+ HDassert(buf);
+
+ /* Retrieve the dataset dimensions */
+ space_ndims = dset->shared->layout.u.chunk.ndims - 1;
+
+ /* Check if chunk storage is allocated for dataset */
+ if(H5D__chunk_is_space_alloc(&(layout->storage)) == FALSE)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "storage is not initialized")
+
+ /* Initialize the chunk offset */
+ HDmemcpy(chunk_offset, offset, (space_ndims * sizeof(chunk_offset[0])));
+ chunk_offset[space_ndims] = (hsize_t)0;
+
+ /* Calculate the index of this chunk */
+ if(H5VM_chunk_index(space_ndims, chunk_offset,
+ layout->u.chunk.dim, layout->u.chunk.down_chunks, &chunk_idx) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get chunk index")
+
+ /* Reset fields about the chunk we are looking for */
+ udata.nbytes = 0;
+ udata.filter_mask = 0;
+ udata.addr = HADDR_UNDEF;
+ udata.idx_hint = UINT_MAX;
+
+ /* Find out the file address of the chunk */
+ if(H5D__chunk_lookup(dset, dxpl_id, chunk_offset, chunk_idx, &udata) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address")
+
+ /* Check if the requested chunk exists in the chunk cache */
+ if(UINT_MAX != udata.idx_hint) {
+ H5D_rdcc_ent_t *ent = rdcc->slot[udata.idx_hint];
+
+ /* Sanity checks */
+ HDassert(udata->idx_hint < rdcc->nslots);
+ HDassert(rdcc->slot[udata->idx_hint]);
+
+ /* If the cached chunk is dirty, it must be flushed to get accurate size */
+ if( ent->dirty == TRUE ) {
+ /* Fill the DXPL cache values for later use */
+ if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache")
+
+ /* Flush the chunk to disk and clear the cache entry */
+ if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, rdcc->slot[udata.idx_hint], TRUE) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk")
+
+ /* Reset fields about the chunk we are looking for */
+ udata.nbytes = 0;
+ udata.filter_mask = 0;
+ udata.addr = HADDR_UNDEF;
+ udata.idx_hint = UINT_MAX;
+
+ /* Get the new file address / chunk size after flushing */
+ if(H5D__chunk_lookup(dset, dxpl_id, chunk_offset, chunk_idx, &udata) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address")
+ }
+ }
+
+ /* Make sure the address of the chunk is returned. */
+ if(!H5F_addr_defined(udata.addr))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined")
+
+ /* Read the chunk data into the supplied buffer */
+ if(H5F_block_read(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, udata.nbytes, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk")
+
+ /* Return the filter mask */
+ *filters = udata.filter_mask;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D__chunk_direct_read() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5D__get_chunk_storage_size
+ *
+ * Purpose: Internal routine to read the storage size of a chunk on disk.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Matthew Strong (GE Healthcare)
+ * 20 October 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D__get_chunk_storage_size(H5D_t *dset, hid_t dxpl_id, const hsize_t *offset, hsize_t *storage_size)
+{
+ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */
+ const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */
+ H5D_chunk_ud_t udata; /* User data for querying chunk info */
+ unsigned space_ndims; /* Dataset's space rank */
+ hsize_t space_dim[H5O_LAYOUT_NDIMS]; /* Dataset's dataspace dimensions */
+ hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Dataset's chunk offset */
+ hsize_t chunk_idx; /* Index of chunk cache entry */
+ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
+ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Check args */
+ HDassert(dset && H5D_CHUNKED == layout->type);
+ HDassert(offset);
+ HDassert(filters);
+ HDassert(buf);
+
+ /* Retrieve the dataset dimensions */
+ space_ndims = dset->shared->layout.u.chunk.ndims - 1;
+
+ if(H5D__chunk_is_space_alloc(&(layout->storage)) == FALSE) {
+ *storage_size = 0;
+ HGOTO_DONE(SUCCEED)
+ }
+
+ /* Initialize the chunk offset */
+ HDmemcpy(chunk_offset, offset, (space_ndims * sizeof(chunk_offset[0])));
+ chunk_offset[space_ndims] = (hsize_t)0;
+
+ /* Calculate the index of this chunk */
+ if(H5VM_chunk_index(space_ndims, chunk_offset,
+ layout->u.chunk.dim, layout->u.chunk.down_chunks, &chunk_idx) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get chunk index")
+
+ /* Reset fields about the chunk we are looking for */
+ udata.nbytes = 0;
+ udata.addr = HADDR_UNDEF;
+ udata.idx_hint = UINT_MAX;
+
+ /* Find out the file address of the chunk */
+ if(H5D__chunk_lookup(dset, dxpl_id, chunk_offset, chunk_idx, &udata) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address")
+
+ /* The requested chunk is not in cache or on disk */
+ if(!H5F_addr_defined(udata.addr) && UINT_MAX == udata.idx_hint)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk storage is not allocated")
+
+ /* Check if there are filters registered to the dataset */
+ if( dset->shared->dcpl_cache.pline.nused > 0 ) {
+ /* Check if the requested chunk exists in the chunk cache */
+ if(UINT_MAX != udata.idx_hint) {
+ /* Sanity checks */
+ HDassert(udata->idx_hint < rdcc->nslots);
+ HDassert(rdcc->slot[udata->idx_hint]);
+ H5D_rdcc_ent_t *ent = rdcc->slot[udata.idx_hint];
+
+ /* If the cached chunk is dirty, it must be flushed to get accurate size */
+ if( ent->dirty == TRUE ) {
+ /* Fill the DXPL cache values for later use */
+ if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache")
+
+ /* Flush the chunk to disk and clear the cache entry */
+ if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, rdcc->slot[udata.idx_hint], TRUE) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk")
+
+ /* Reset fields about the chunk we are looking for */
+ udata.nbytes = 0;
+ udata.addr = HADDR_UNDEF;
+ udata.idx_hint = UINT_MAX;
+
+ /* Get the new file address / chunk size after flushing */
+ if(H5D__chunk_lookup(dset, dxpl_id, chunk_offset, chunk_idx, &udata) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address")
+ }
+ }
+
+ /* Make sure the address of the chunk is returned. */
+ if(!H5F_addr_defined(udata.addr))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined")
+
+ /* Return the chunk size on disk */
+ *storage_size = udata.nbytes;
+ }
+ /* There are no filters registered, return the chunk size from the storage layout */
+ else
+ *storage_size = dset->shared->layout.u.chunk.size;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5D__get_chunk_storage_size */
+
+
/*-------------------------------------------------------------------------
* Function: H5D__chunk_set_info_real
@@ -2636,25 +2853,25 @@ H5D__chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t
HDassert(ent->idx < rdcc->nslots);
if(flush) {
- /* Flush */
- if(H5D__chunk_flush_entry(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0)
- HDONE_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer")
+ /* Flush */
+ if(H5D__chunk_flush_entry(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0)
+ HDONE_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer")
} /* end if */
else {
/* Don't flush, just free chunk */
- if(ent->chunk != NULL)
- ent->chunk = (uint8_t *)H5D__chunk_xfree(ent->chunk, &(dset->shared->dcpl_cache.pline));
+ if(ent->chunk != NULL)
+ ent->chunk = (uint8_t *)H5D__chunk_xfree(ent->chunk, &(dset->shared->dcpl_cache.pline));
} /* end else */
/* Unlink from list */
if(ent->prev)
- ent->prev->next = ent->next;
+ ent->prev->next = ent->next;
else
- rdcc->head = ent->next;
+ rdcc->head = ent->next;
if(ent->next)
- ent->next->prev = ent->prev;
+ ent->next->prev = ent->prev;
else
- rdcc->tail = ent->prev;
+ rdcc->tail = ent->prev;
ent->prev = ent->next = NULL;
/* Remove from cache */
@@ -3534,7 +3751,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite,
} /* end if */
else {
#endif /* H5_HAVE_PARALLEL */
- if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, chunk_size,
+ if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, chunk_size,
dxpl_id, fb_info.fill_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file")
#ifdef H5_HAVE_PARALLEL
@@ -3600,7 +3817,7 @@ done:
* Function: H5D__chunk_collective_fill
*
* Purpose: Use MPIO collective write to fill the chunks (if number of
- * chunks to fill is greater than the number of MPI procs;
+ * chunks to fill is greater than the number of MPI procs;
* otherwise use independent I/O).
*
* Return: Non-negative on success/Negative on failure
@@ -3683,13 +3900,13 @@ H5D__chunk_collective_fill(const H5D_t *dset, hid_t dxpl_id,
distributing. If there are, then round robin the distribution
to processes 0 -> leftover. */
if(leftover && leftover > mpi_rank) {
- chunk_disp_array[blocks] = (MPI_Aint)chunk_info->addr[blocks*mpi_size + mpi_rank];
+ chunk_disp_array[blocks] = (MPI_Aint)chunk_info->addr[blocks*mpi_size + mpi_rank];
block_lens[blocks] = block_len;
blocks++;
}
/* MSC
- * should not have a special case for blocks == 0, but ompi (as of 1.8.1) has a bug
+ * should not have a special case for blocks == 0, but ompi (as of 1.8.1) has a bug
* in file_set_view when a zero size datatype is create with hindexed or hvector.
*/
if(0 == blocks) {
@@ -3701,11 +3918,11 @@ H5D__chunk_collective_fill(const H5D_t *dset, hid_t dxpl_id,
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
}
else {
- /* MSC
- * should use this if MPI_type_create_hindexed block is working
+ /* MSC
+ * should use this if MPI_type_create_hindexed block is working
* mpi_code = MPI_Type_create_hindexed_block(blocks, block_len, chunk_disp_array, MPI_BYTE, &file_type);
*/
- mpi_code = MPI_Type_create_hindexed(blocks, block_lens, chunk_disp_array,
+ mpi_code = MPI_Type_create_hindexed(blocks, block_lens, chunk_disp_array,
MPI_BYTE, &file_type);
if(mpi_code != MPI_SUCCESS)
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
@@ -3740,7 +3957,7 @@ H5D__chunk_collective_fill(const H5D_t *dset, hid_t dxpl_id,
}
/* low level write */
- if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, (haddr_t)0, (blocks) ? (size_t)1 : (size_t)0,
+ if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, (haddr_t)0, (blocks) ? (size_t)1 : (size_t)0,
data_dxpl_id, fill_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file")
@@ -5158,7 +5375,7 @@ H5D__chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset)
if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0)
nerrors++;
} /* end for */
-
+
/* Continue even if there are failures. */
if(nerrors)
HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks")
@@ -5351,4 +5568,3 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info,
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__nonexistent_readvv() */
-
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 58031e8..58fc855 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -55,7 +55,7 @@
static herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id,
const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist,
const void *buf);
-static herr_t H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
+static herr_t H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf);
/* Setup/teardown routines */
@@ -127,9 +127,13 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf/*out*/)
{
H5D_t *dset = NULL;
+ H5P_genplist_t *plist; /* Property list pointer */
const H5S_t *mem_space = NULL;
const H5S_t *file_space = NULL;
herr_t ret_value = SUCCEED; /* Return value */
+ hsize_t *direct_offset = NULL;
+ hbool_t direct_read = FALSE;
+ uint32_t direct_filters = 0;
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id,
@@ -137,28 +141,28 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
/* check arguments */
if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(NULL == dset->oloc.file)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(mem_space_id < 0 || file_space_id < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
if(H5S_ALL != mem_space_id) {
- if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+ if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
- /* Check for valid selection */
- if(H5S_SELECT_VALID(mem_space) != TRUE)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent")
+ /* Check for valid selection */
+ if(H5S_SELECT_VALID(mem_space) != TRUE)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent")
} /* end if */
if(H5S_ALL != file_space_id) {
- if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+ if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
- /* Check for valid selection */
- if(H5S_SELECT_VALID(file_space) != TRUE)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent")
+ /* Check for valid selection */
+ if(H5S_SELECT_VALID(file_space) != TRUE)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent")
} /* end if */
/* Get the default dataset transfer property list if the user didn't provide one */
@@ -168,9 +172,58 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
- /* read raw data */
- if(H5D__read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
+ /* Get the dataset transfer property list */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list")
+
+ /* Retrieve the 'direct read' flag */
+ if(H5P_get(plist, H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME, &direct_read) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting flag for direct chunk read")
+
+ if(direct_read) {
+ unsigned u;
+ int ndims = 0;
+ hsize_t dims[H5O_LAYOUT_NDIMS];
+ hsize_t internal_offset[H5O_LAYOUT_NDIMS];
+
+ if(H5D_CHUNKED != dset->shared->layout.type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
+ /* Get the direct chunk offset property */
+ if(H5P_get(plist, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME, &direct_offset) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting direct offset from xfer properties")
+
+ /* The library's chunking code requires the offset terminates with a zero. So transfer the
+ * offset array to an internal offset array */
+ if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dims, NULL)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims")
+
+ for(u = 0; u < ndims; u++) {
+ /* Make sure the offset doesn't exceed the dataset's dimensions */
+ if(direct_offset[u] > dims[u])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset")
+
+ /* Make sure the offset fall right on a chunk's boundary */
+ if(direct_offset[u] % dset->shared->layout.u.chunk.dim[u])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary")
+
+ internal_offset[u] = direct_offset[u];
+ } /* end for */
+
+ /* Terminate the offset with a zero */
+ internal_offset[ndims] = 0;
+
+ /* Read the raw chunk */
+ if(H5D__chunk_direct_read(dset, plist_id, internal_offset, &direct_filters, buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read chunk directly")
+ /* Set the chunk filter mask property */
+ if(H5P_set(plist, H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME, &direct_filters) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error setting filter mask xfer property")
+ }
+ else {
+ /* read raw data */
+ if(H5D__read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
+ }
done:
FUNC_LEAVE_API(ret_value)
@@ -225,9 +278,9 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
/* check arguments */
if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(NULL == dset->oloc.file)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
@@ -249,26 +302,26 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
if(mem_space_id < 0 || file_space_id < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
- if(H5S_ALL != mem_space_id) {
- if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
-
- /* Check for valid selection */
- if(H5S_SELECT_VALID(mem_space) != TRUE)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "memory selection+offset not within extent")
- } /* end if */
- if(H5S_ALL != file_space_id) {
- if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
-
- /* Check for valid selection */
- if(H5S_SELECT_VALID(file_space) != TRUE)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "file selection+offset not within extent")
- } /* end if */
+ if(H5S_ALL != mem_space_id) {
+ if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ /* Check for valid selection */
+ if(H5S_SELECT_VALID(mem_space) != TRUE)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "memory selection+offset not within extent")
+ } /* end if */
+ if(H5S_ALL != file_space_id) {
+ if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ /* Check for valid selection */
+ if(H5S_SELECT_VALID(file_space) != TRUE)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "file selection+offset not within extent")
+ } /* end if */
}
- if(H5D__pre_write(dset, direct_write, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't prepare for writing data")
+ if(H5D__pre_write(dset, direct_write, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't prepare for writing data")
done:
FUNC_LEAVE_API(ret_value)
@@ -278,7 +331,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5D__pre_write
*
- * Purpose: Preparation for writing data.
+ * Purpose: Preparation for writing data.
*
* Return: Non-negative on success/Negative on failure
*
@@ -288,8 +341,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
- const H5S_t *mem_space, const H5S_t *file_space,
+H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
+ const H5S_t *mem_space, const H5S_t *file_space,
hid_t dxpl_id, const void *buf)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -302,17 +355,17 @@ H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
uint32_t direct_filters;
hsize_t *direct_offset;
uint32_t direct_datasize;
- int ndims = 0;
- hsize_t dims[H5O_LAYOUT_NDIMS];
- hsize_t internal_offset[H5O_LAYOUT_NDIMS];
- unsigned u;
+ int ndims = 0;
+ hsize_t dims[H5O_LAYOUT_NDIMS];
+ hsize_t internal_offset[H5O_LAYOUT_NDIMS];
+ unsigned u;
/* Get the dataset transfer property list */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list")
if(H5D_CHUNKED != dset->shared->layout.type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Retrieve parameters for direct chunk write */
if(H5P_get(plist, H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME, &direct_filters) < 0)
@@ -322,34 +375,34 @@ H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id,
if(H5P_get(plist, H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME, &direct_datasize) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data size for direct chunk write")
- /* The library's chunking code requires the offset terminates with a zero. So transfer the
- * offset array to an internal offset array */
- if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dims, NULL)) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims")
+ /* The library's chunking code requires the offset terminates with a zero. So transfer the
+ * offset array to an internal offset array */
+ if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dims, NULL)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims")
- for(u = 0; u < ndims; u++) {
- /* Make sure the offset doesn't exceed the dataset's dimensions */
+ for(u = 0; u < ndims; u++) {
+ /* Make sure the offset doesn't exceed the dataset's dimensions */
if(direct_offset[u] > dims[u])
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset")
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset")
/* Make sure the offset fall right on a chunk's boundary */
- if(direct_offset[u] % dset->shared->layout.u.chunk.dim[u])
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary")
-
- internal_offset[u] = direct_offset[u];
- } /* end for */
-
- /* Terminate the offset with a zero */
- internal_offset[ndims] = 0;
-
- /* write raw data */
- if(H5D__chunk_direct_write(dset, dxpl_id, direct_filters, internal_offset, direct_datasize, buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write chunk directly")
+ if(direct_offset[u] % dset->shared->layout.u.chunk.dim[u])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary")
+
+ internal_offset[u] = direct_offset[u];
+ } /* end for */
+
+ /* Terminate the offset with a zero */
+ internal_offset[ndims] = 0;
+
+ /* write raw data */
+ if(H5D__chunk_direct_write(dset, dxpl_id, direct_filters, internal_offset, direct_datasize, buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write chunk directly")
} /* end if */
else { /* Normal write */
/* write raw data */
if(H5D__write(dset, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
} /* end else */
done:
@@ -430,7 +483,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
#ifdef H5_HAVE_PARALLEL
/* Collective access is not permissible without a MPI based VFD */
- if(dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE &&
+ if(dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE &&
!(H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI)))
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based drivers only")
#endif /*H5_HAVE_PARALLEL*/
@@ -459,16 +512,16 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set")
/* H5S_select_shape_same() has been modified to accept topologically identical
- * selections with different rank as having the same shape (if the most
- * rapidly changing coordinates match up), but the I/O code still has
+ * selections with different rank as having the same shape (if the most
+ * rapidly changing coordinates match up), but the I/O code still has
* difficulties with the notion.
*
- * To solve this, we check to see if H5S_select_shape_same() returns true,
- * and if the ranks of the mem and file spaces are different. If the are,
- * construct a new mem space that is equivalent to the old mem space, and
+ * To solve this, we check to see if H5S_select_shape_same() returns true,
+ * and if the ranks of the mem and file spaces are different. If the are,
+ * construct a new mem space that is equivalent to the old mem space, and
* use that instead.
*
- * Note that in general, this requires us to touch up the memory buffer as
+ * Note that in general, this requires us to touch up the memory buffer as
* well.
*/
if(TRUE == H5S_select_shape_same(mem_space, file_space) &&
@@ -715,17 +768,17 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
if(!(H5S_has_extent(mem_space)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set")
- /* H5S_select_shape_same() has been modified to accept topologically
- * identical selections with different rank as having the same shape
- * (if the most rapidly changing coordinates match up), but the I/O
+ /* H5S_select_shape_same() has been modified to accept topologically
+ * identical selections with different rank as having the same shape
+ * (if the most rapidly changing coordinates match up), but the I/O
* code still has difficulties with the notion.
*
- * To solve this, we check to see if H5S_select_shape_same() returns
- * true, and if the ranks of the mem and file spaces are different.
- * If the are, construct a new mem space that is equivalent to the
+ * To solve this, we check to see if H5S_select_shape_same() returns
+ * true, and if the ranks of the mem and file spaces are different.
+ * If the are, construct a new mem space that is equivalent to the
* old mem space, and use that instead.
*
- * Note that in general, this requires us to touch up the memory buffer
+ * Note that in general, this requires us to touch up the memory buffer
* as well.
*/
if(TRUE == H5S_select_shape_same(mem_space, file_space) &&
@@ -1237,4 +1290,3 @@ H5D__typeinfo_term(const H5D_type_info_t *type_info)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__typeinfo_term() */
-
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index ff01041..91cf5f3 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -538,6 +538,7 @@ H5_DLL herr_t H5D__get_space_status(H5D_t *dset, H5D_space_status_t *allocation,
H5_DLL herr_t H5D__alloc_storage(const H5D_t *dset, hid_t dxpl_id, H5D_time_alloc_t time_alloc,
hbool_t full_overwrite, hsize_t old_dim[]);
H5_DLL herr_t H5D__get_storage_size(H5D_t *dset, hid_t dxpl_id, hsize_t *storage_size);
+H5_DLL herr_t H5D__get_chunk_storage_size(H5D_t *dset, hid_t dxpl_id, const hsize_t *offset, hsize_t *storage_size);
H5_DLL haddr_t H5D__get_offset(const H5D_t *dset);
H5_DLL void *H5D__vlen_get_buf_size_alloc(size_t size, void *info);
H5_DLL herr_t H5D__vlen_get_buf_size(void *elem, hid_t type_id, unsigned ndim,
@@ -638,6 +639,8 @@ H5_DLL herr_t H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
H5O_storage_t *store);
H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters,
hsize_t *offset, uint32_t data_size, const void *buf);
+H5_DLL herr_t H5D__chunk_direct_read(const H5D_t *dset, hid_t dxpl_id, hsize_t *offset,
+ uint32_t *filters, void *buf);
#ifdef H5D_CHUNK_DEBUG
H5_DLL herr_t H5D__chunk_stats(const H5D_t *dset, hbool_t headers);
#endif /* H5D_CHUNK_DEBUG */
diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h
index e7ae3ae..2eb5ff8 100644
--- a/src/H5Dpublic.h
+++ b/src/H5Dpublic.h
@@ -34,12 +34,17 @@
#define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t) -1)
#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0f)
-/* Property names for H5LTDdirect_chunk_write */
+/* Property names for H5LTDdirect_chunk_write */
#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag"
#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME "direct_chunk_filters"
#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME "direct_chunk_offset"
#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME "direct_chunk_datasize"
-
+
+/* Property names for H5LTDdirect_chunk_read */
+#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME "direct_chunk_read_flag"
+#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME "direct_chunk_read_offset"
+#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME "direct_chunk_read_filters"
+
/*******************/
/* Public Typedefs */
/*******************/
@@ -128,6 +133,7 @@ H5_DLL hid_t H5Dget_type(hid_t dset_id);
H5_DLL hid_t H5Dget_create_plist(hid_t dset_id);
H5_DLL hid_t H5Dget_access_plist(hid_t dset_id);
H5_DLL hsize_t H5Dget_storage_size(hid_t dset_id);
+H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes);
H5_DLL haddr_t H5Dget_offset(hid_t dset_id);
H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf/*out*/);
@@ -170,4 +176,3 @@ H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]);
}
#endif
#endif /* _H5Dpublic_H */
-
diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c
index ce16036..d9e7ec7 100644
--- a/src/H5Pdxpl.c
+++ b/src/H5Pdxpl.c
@@ -137,6 +137,13 @@
#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_DEF NULL
#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_SIZE sizeof(uint32_t)
#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_DEF 0
+/* Definitions for properties of direct chunk read */
+#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_SIZE sizeof(hbool_t)
+#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_DEF FALSE
+#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_SIZE sizeof(uint32_t)
+#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_DEF 0
+#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_SIZE sizeof(hsize_t *)
+#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_DEF NULL
/******************/
/* Local Typedefs */
@@ -241,6 +248,9 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass)
uint32_t direct_chunk_filters = H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_DEF; /* Default value for the filters of direct chunk write */
hsize_t *direct_chunk_offset = H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_DEF; /* Default value for the offset of direct chunk write */
uint32_t direct_chunk_datasize = H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_DEF; /* Default value for the datasize of direct chunk write */
+ hbool_t direct_chunk_read_flag = H5D_XFER_DIRECT_CHUNK_READ_FLAG_DEF; /* Default value for the flag of direct chunk read */
+ hsize_t *direct_chunk_read_offset = H5D_XFER_DIRECT_CHUNK_READ_OFFSET_DEF; /* Default value for the offset of direct chunk read */
+ uint32_t direct_chunk_read_filters = H5D_XFER_DIRECT_CHUNK_READ_FILTERS_DEF; /* Default value for the filters of direct chunk read */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -365,6 +375,24 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the property of flag for direct chunk read */
+ /* (Note: this property should not have an encode/decode callback) */
+ if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME, H5D_XFER_DIRECT_CHUNK_READ_FLAG_SIZE, &direct_chunk_read_flag,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ /* Register the property of filter for direct chunk read */
+ /* (Note: this property should not have an encode/decode callback) */
+ if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME, H5D_XFER_DIRECT_CHUNK_READ_FILTERS_SIZE, &direct_chunk_read_filters,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ /* Register the property of offset for direct chunk read */
+ /* (Note: this property should not have an encode/decode callback) */
+ if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_SIZE, &direct_chunk_read_offset,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_reg_prop() */