summaryrefslogtreecommitdiffstats
path: root/hl/src
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-04-03 02:18:16 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-04-03 02:18:16 (GMT)
commitea1bb348c5da7195e7767bad66707a0dd1c18de1 (patch)
tree243369b3d67a60a909661fc3aff0ffdb156b6af2 /hl/src
parentf5694482bdc66db6f4946bc709cbfbe92f193980 (diff)
downloadhdf5-ea1bb348c5da7195e7767bad66707a0dd1c18de1.zip
hdf5-ea1bb348c5da7195e7767bad66707a0dd1c18de1.tar.gz
hdf5-ea1bb348c5da7195e7767bad66707a0dd1c18de1.tar.bz2
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 'hl/src')
-rw-r--r--hl/src/H5DO.c78
-rw-r--r--hl/src/H5DOpublic.h13
2 files changed, 87 insertions, 4 deletions
diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c
index 99dbd93..151481e 100644
--- a/hl/src/H5DO.c
+++ b/hl/src/H5DO.c
@@ -29,7 +29,7 @@
/*-------------------------------------------------------------------------
* Function: H5DOwrite_chunk
*
- * Purpose: Writes an entire chunk to the file directly.
+ * Purpose: Writes an entire chunk to the file directly.
*
* Return: Non-negative on success/Negative on failure
*
@@ -39,14 +39,15 @@
*-------------------------------------------------------------------------
*/
herr_t
-H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset,
+H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset,
size_t data_size, const void *buf)
{
hbool_t created_dxpl = FALSE; /* Whether we created a DXPL */
hbool_t do_direct_write = TRUE; /* Flag for direct writes */
+ hbool_t tt=FALSE; /* Flag for direct writes */
uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */
herr_t ret_value = FAIL; /* Return value */
-
+
/* Check arguments */
if(dset_id < 0)
goto done;
@@ -89,11 +90,80 @@ done:
if(H5Pclose(dxpl_id) < 0)
ret_value = FAIL;
} /* end if */
- else
+ else {
/* Reset the direct write flag on user DXPL */
+ do_direct_write = FALSE;
if(H5Pset(dxpl_id, H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME, &do_direct_write) < 0)
ret_value = FAIL;
+ }
return(ret_value);
} /* end H5DOwrite_chunk() */
+/*-------------------------------------------------------------------------
+ * Function: H5DOread_chunk
+ *
+ * Purpose: Reads an entire chunk from the file directly.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Matthew Strong (GE Healthcare)
+ * 14 February 2016
+ *
+ *------------ -------------------------------------------------------------
+ */
+herr_t
+H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters,
+ void *buf)
+{
+ hbool_t created_dxpl = FALSE; /* Whether we created a DXPL */
+ hbool_t do_direct_read = TRUE; /* Flag for direct writes */
+ herr_t ret_value = FAIL; /* Return value */
+
+ /* Check arguments */
+ if(dset_id < 0)
+ goto done;
+ if(!buf)
+ goto done;
+ if(!offset)
+ goto done;
+ if(!filters)
+ goto done;
+
+ /* If the user passed in a default DXPL, create one to pass to H5Dwrite() */
+ if(H5P_DEFAULT == dxpl_id) {
+ if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ goto done;
+ created_dxpl = TRUE;
+ } /* end if */
+
+ /* Set direct write parameters */
+ if(H5Pset(dxpl_id, H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME, &do_direct_read) < 0)
+ goto done;
+ if(H5Pset(dxpl_id, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME, &offset) < 0)
+ goto done;
+
+ /* Read chunk */
+ if(H5Dread(dset_id, 0, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0)
+ goto done;
+ /* Get the filter mask */
+ if(H5Pget(dxpl_id, H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME, filters) < 0)
+ goto done;
+
+ /* Indicate success */
+ ret_value = SUCCEED;
+
+done:
+ if(created_dxpl) {
+ if(H5Pclose(dxpl_id) < 0)
+ ret_value = FAIL;
+ } /* end if */
+ else {
+ /* Reset the direct read flag on user DXPL */
+ do_direct_read = FALSE;
+ if(H5Pset(dxpl_id, H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME, &do_direct_read) < 0)
+ ret_value = FAIL;
+ }
+
+ return(ret_value);
+} /* end H5DOread_chunk() */
diff --git a/hl/src/H5DOpublic.h b/hl/src/H5DOpublic.h
index 774709e..52c6a09 100644
--- a/hl/src/H5DOpublic.h
+++ b/hl/src/H5DOpublic.h
@@ -34,6 +34,19 @@ H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id,
size_t data_size,
const void *buf);
+/*-------------------------------------------------------------------------
+ *
+ * Direct chunk read function
+ *
+ *-------------------------------------------------------------------------
+ */
+
+H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, /*in*/
+ hid_t dxpl_id, /*in*/
+ const hsize_t *offset, /*in*/
+ uint32_t *filters, /*out*/
+ void *buf); /*out*/
+
#ifdef __cplusplus
}
#endif