mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-25 17:00:45 +08:00
[svn-r4965] Purpose:
Bug Fix Description: If a non-zero fill-value is used for a chunked dataset, any non-existent chunked read with an "all" selection (or a contiguous hyperslab selection) will return zero for those instead of the user's fill-value. Solution: Fixed I/O code to pass down fill-value to "optimized" I/O routines, so it will be available to fill the user's buffer with. Platforms tested: FreeBSD 4.5 (sleipnir)
This commit is contained in:
parent
a1c37b6eb8
commit
5883b9d67d
@ -106,6 +106,9 @@ Library
|
||||
* Fixed bug where a preempted chunk in the chunk data could still be
|
||||
used by an internal pointer and cause an assertion failure or core
|
||||
dump. QAK - 2/13/02
|
||||
* Fixed bug where non-zero fill-value was not being read correctly from
|
||||
certain chunked datasets when using an "all" or contiguous hyperslab
|
||||
selection. QAK - 2/14/02
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
13
src/H5D.c
13
src/H5D.c
@ -2238,11 +2238,13 @@ printf("%s: check 1.1, \n",FUNC);
|
||||
#endif
|
||||
if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get pipeline");
|
||||
if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve fill value");
|
||||
if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get external file list");
|
||||
status = (sconv->read)(dataset->ent.file, &(dataset->layout), &pline,
|
||||
&efl, H5T_get_size(dataset->type), file_space,
|
||||
mem_space, dxpl_id, buf/*out*/, &must_convert);
|
||||
&fill, &efl, H5T_get_size(dataset->type), file_space,
|
||||
mem_space, dxpl_id, buf/*out*/, &must_convert);
|
||||
|
||||
/* Supports only no conversion, type or space, for now. */
|
||||
if (status<0)
|
||||
@ -2725,11 +2727,14 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
|
||||
#endif
|
||||
if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get pipeline");
|
||||
if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve fill value");
|
||||
if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get external file list");
|
||||
status = (sconv->write)(dataset->ent.file, &(dataset->layout), &pline,
|
||||
&efl, H5T_get_size(dataset->type), file_space,
|
||||
mem_space, dxpl_id, buf/*out*/, &must_convert);
|
||||
&fill, &efl, H5T_get_size(dataset->type), file_space,
|
||||
mem_space, dxpl_id, buf/*out*/, &must_convert);
|
||||
|
||||
/* Supports only no conversion, type or space, for now. */
|
||||
if (status<0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed");
|
||||
|
15
src/H5Sall.c
15
src/H5Sall.c
@ -393,6 +393,7 @@ H5S_all_mscat (const void *tconv_buf, size_t elmt_size,
|
||||
*/
|
||||
herr_t
|
||||
H5S_all_read(H5F_t *f, const H5O_layout_t *layout, const H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space,
|
||||
const H5S_t *mem_space, hid_t dxpl_id, void *_buf/*out*/,
|
||||
hbool_t *must_convert/*out*/)
|
||||
@ -623,7 +624,7 @@ for (u=0; u<=mem_space->extent.u.simple.rank; u++)
|
||||
printf("file_offset[%u]=%lu\n",u,(unsigned long)file_offset[u]);
|
||||
#endif /* QAK */
|
||||
/* Read data from the file */
|
||||
if (H5F_arr_read(f, dxpl_id, layout, pline, NULL, efl, size,
|
||||
if (H5F_arr_read(f, dxpl_id, layout, pline, fill, efl, size,
|
||||
size, mem_offset, file_offset, buf/*out*/)<0) {
|
||||
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,
|
||||
"unable to read data from the file");
|
||||
@ -661,10 +662,12 @@ done:
|
||||
*/
|
||||
herr_t
|
||||
H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const H5O_pline_t *pline, const H5O_efl_t *efl,
|
||||
size_t elmt_size, const H5S_t *file_space,
|
||||
const H5S_t *mem_space, hid_t dxpl_id, const void *_buf,
|
||||
hbool_t *must_convert/*out*/)
|
||||
const H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const H5O_efl_t *efl,
|
||||
size_t elmt_size, const H5S_t *file_space,
|
||||
const H5S_t *mem_space, hid_t dxpl_id, const void *_buf,
|
||||
hbool_t *must_convert/*out*/)
|
||||
{
|
||||
H5S_hyper_span_t *file_span=NULL,*mem_span=NULL; /* Hyperslab span node */
|
||||
const char *buf=(const char*)_buf; /* Get pointer to buffer */
|
||||
@ -880,7 +883,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
} /* end if */
|
||||
|
||||
/* Write data to the file */
|
||||
if (H5F_arr_write(f, dxpl_id, layout, pline, NULL, efl, size,
|
||||
if (H5F_arr_write(f, dxpl_id, layout, pline, fill, efl, size,
|
||||
size, mem_offset, file_offset, buf)<0) {
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"unable to write data to the file");
|
||||
|
@ -551,6 +551,7 @@ H5S_mpio_space_type( const H5S_t *space, const size_t elmt_size,
|
||||
herr_t
|
||||
H5S_mpio_spaces_xfer(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t UNUSED *pline,
|
||||
const struct H5O_fill_t UNUSED *fill,
|
||||
const struct H5O_efl_t UNUSED *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, void *buf /*out*/,
|
||||
@ -720,6 +721,7 @@ done:
|
||||
herr_t
|
||||
H5S_mpio_spaces_read(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, void *buf/*out*/,
|
||||
@ -729,7 +731,7 @@ H5S_mpio_spaces_read(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
|
||||
FUNC_ENTER (H5S_mpio_spaces_read, FAIL);
|
||||
|
||||
ret_value = H5S_mpio_spaces_xfer(f, layout, pline, efl, elmt_size,
|
||||
ret_value = H5S_mpio_spaces_xfer(f, layout, pline, fill, efl, elmt_size,
|
||||
file_space, mem_space, dxpl_id,
|
||||
buf, must_convert/*out*/, 0/*read*/);
|
||||
|
||||
@ -755,17 +757,18 @@ H5S_mpio_spaces_read(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
*/
|
||||
herr_t
|
||||
H5S_mpio_spaces_write(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, const void *buf,
|
||||
hbool_t *must_convert/*out*/)
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, const void *buf,
|
||||
hbool_t *must_convert/*out*/)
|
||||
{
|
||||
herr_t ret_value = FAIL;
|
||||
|
||||
FUNC_ENTER (H5S_mpio_spaces_write, FAIL);
|
||||
|
||||
ret_value = H5S_mpio_spaces_xfer(f, layout, pline, efl, elmt_size,
|
||||
ret_value = H5S_mpio_spaces_xfer(f, layout, pline, fill, efl, elmt_size,
|
||||
file_space, mem_space, dxpl_id,
|
||||
(void*)buf, must_convert/*out*/,
|
||||
1/*write*/);
|
||||
|
12
src/H5Spkg.h
12
src/H5Spkg.h
@ -146,16 +146,18 @@ __DLL__ herr_t H5S_all_select_deserialize(H5S_t *space, const uint8_t *buf);
|
||||
__DLL__ herr_t H5S_all_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
|
||||
__DLL__ herr_t H5S_all_read(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, void *buf/*out*/,
|
||||
hbool_t *must_convert/*out*/);
|
||||
__DLL__ herr_t H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, const void *buf,
|
||||
hbool_t *must_convert/*out*/);
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, const void *buf,
|
||||
hbool_t *must_convert/*out*/);
|
||||
__DLL__ herr_t H5S_all_select_iterate(void *buf, hid_t type_id, H5S_t *space,
|
||||
H5D_operator_t op, void *operator_data);
|
||||
|
||||
|
@ -142,6 +142,7 @@ typedef struct H5S_conv_t {
|
||||
/* Read from file to application w/o intermediate scratch buffer */
|
||||
herr_t (*read)(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, void *buf/*out*/,
|
||||
@ -150,11 +151,12 @@ typedef struct H5S_conv_t {
|
||||
|
||||
/* Write directly from app buffer to file */
|
||||
herr_t (*write)(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, const void *buf,
|
||||
hbool_t *must_convert/*out*/);
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl, size_t elmt_size,
|
||||
const H5S_t *file_space, const H5S_t *mem_space,
|
||||
hid_t dxpl_id, const void *buf,
|
||||
hbool_t *must_convert/*out*/);
|
||||
|
||||
#ifdef H5S_DEBUG
|
||||
struct {
|
||||
@ -227,6 +229,7 @@ __DLL__ herr_t H5S_sel_iter_release(const H5S_t *space,
|
||||
__DLL__ herr_t H5S_mpio_spaces_read(H5F_t *f,
|
||||
const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl,
|
||||
size_t elmt_size, const H5S_t *file_space,
|
||||
const H5S_t *mem_space, hid_t dxpl_id,
|
||||
@ -235,13 +238,14 @@ __DLL__ herr_t H5S_mpio_spaces_read(H5F_t *f,
|
||||
|
||||
/* MPI-IO function to write directly from app buffer to file rky980813 */
|
||||
__DLL__ herr_t H5S_mpio_spaces_write(H5F_t *f,
|
||||
const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_efl_t *efl,
|
||||
size_t elmt_size, const H5S_t *file_space,
|
||||
const H5S_t *mem_space, hid_t dxpl_id,
|
||||
const void *buf,
|
||||
hbool_t *must_convert /*out*/ );
|
||||
const struct H5O_layout_t *layout,
|
||||
const struct H5O_pline_t *pline,
|
||||
const struct H5O_fill_t *fill,
|
||||
const struct H5O_efl_t *efl,
|
||||
size_t elmt_size, const H5S_t *file_space,
|
||||
const H5S_t *mem_space, hid_t dxpl_id,
|
||||
const void *buf,
|
||||
hbool_t *must_convert /*out*/ );
|
||||
#ifndef _H5S_IN_H5S_C
|
||||
/* Global var whose value comes from environment variable */
|
||||
__DLLVAR__ hbool_t H5_mpi_opt_types_g;
|
||||
|
81
test/tmisc.c
81
test/tmisc.c
@ -41,6 +41,16 @@ typedef struct {
|
||||
char *string;
|
||||
} misc2_struct;
|
||||
|
||||
/* Definitions for misc. test #3 */
|
||||
#define MISC3_FILE "tmisc3.h5"
|
||||
#define MISC3_RANK 2
|
||||
#define MISC3_DIM1 6
|
||||
#define MISC3_DIM2 6
|
||||
#define MISC3_CHUNK_DIM1 2
|
||||
#define MISC3_CHUNK_DIM2 2
|
||||
#define MISC3_FILL_VALUE 2
|
||||
#define MISC3_DSET_NAME "/chunked"
|
||||
|
||||
/****************************************************************
|
||||
**
|
||||
** test_misc1(): test unlinking a dataset from a group and immediately
|
||||
@ -252,7 +262,7 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name
|
||||
free(data_check.string);
|
||||
|
||||
ret = H5Aclose(att);
|
||||
CHECK(ret, FAIL, "HAclose");
|
||||
CHECK(ret, FAIL, "H5Aclose");
|
||||
|
||||
ret = H5Tclose(type);
|
||||
CHECK(ret, FAIL, "H5Tclose");
|
||||
@ -283,6 +293,73 @@ test_misc2(void)
|
||||
test_misc2_read_attribute(MISC2_FILE_2, MISC2_ATT_NAME_2);
|
||||
} /* end test_misc2() */
|
||||
|
||||
/****************************************************************
|
||||
**
|
||||
** test_misc3(): Test reading from chunked dataset with non-zero
|
||||
** fill value
|
||||
**
|
||||
****************************************************************/
|
||||
static void
|
||||
test_misc3(void)
|
||||
{
|
||||
hid_t file, dataspace, dataset, dcpl;
|
||||
int rank=MISC3_RANK;
|
||||
hsize_t dims[MISC3_RANK]={MISC3_DIM1,MISC3_DIM2};
|
||||
hsize_t chunk_dims[MISC3_RANK]={MISC3_CHUNK_DIM1,MISC3_CHUNK_DIM2};
|
||||
int fill=MISC3_FILL_VALUE;
|
||||
int read_buf[MISC3_DIM1][MISC3_DIM2];
|
||||
int i,j;
|
||||
herr_t ret;
|
||||
|
||||
/* Output message about test being performed */
|
||||
MESSAGE(5, ("Testing reading from chunked dataset with non-zero fill-value\n"));
|
||||
|
||||
file = H5Fcreate(MISC3_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
CHECK(file, FAIL, "H5Fcreate");
|
||||
|
||||
/* Create a simple dataspace */
|
||||
dataspace = H5Screate_simple(rank,dims,NULL);
|
||||
CHECK(dataspace, FAIL, "H5Screate_simple");
|
||||
|
||||
/* Create a dataset creation property list */
|
||||
dcpl = H5Pcreate(H5P_DATASET_CREATE);
|
||||
CHECK(dcpl, FAIL, "H5Pcreate");
|
||||
|
||||
/* Set the chunk information */
|
||||
ret = H5Pset_chunk(dcpl,rank,chunk_dims);
|
||||
CHECK(dcpl, FAIL, "H5Pset_chunk");
|
||||
|
||||
/* Set the fill-value information */
|
||||
ret = H5Pset_fill_value(dcpl,H5T_NATIVE_INT,&fill);
|
||||
CHECK(dcpl, FAIL, "H5Pset_fill_value");
|
||||
|
||||
/* Create the dataset */
|
||||
dataset = H5Dcreate(file, MISC3_DSET_NAME, H5T_NATIVE_INT, dataspace, dcpl);
|
||||
CHECK(dataset, FAIL, "H5Dcreate");
|
||||
|
||||
/* Read from the dataset (should be fill-values) */
|
||||
ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &read_buf);
|
||||
CHECK(ret, FAIL, "H5Dread");
|
||||
|
||||
for(i=0; i<MISC3_DIM1; i++)
|
||||
for(j=0; j<MISC3_DIM2; j++)
|
||||
VERIFY(read_buf[i][j],fill,"H5Dread");
|
||||
|
||||
/* Release resources */
|
||||
ret = H5Pclose(dcpl);
|
||||
CHECK(ret, FAIL, "H5Pclose");
|
||||
|
||||
ret = H5Sclose(dataspace);
|
||||
CHECK(ret, FAIL, "H5Sclose");
|
||||
|
||||
ret = H5Dclose(dataset);
|
||||
CHECK(ret, FAIL, "H5Dclose");
|
||||
|
||||
ret = H5Fclose(file);
|
||||
CHECK(ret, FAIL, "H5Fclose");
|
||||
} /* end test_misc3() */
|
||||
|
||||
|
||||
/****************************************************************
|
||||
**
|
||||
** test_misc(): Main misc. test routine.
|
||||
@ -296,6 +373,7 @@ test_misc(void)
|
||||
|
||||
test_misc1(); /* Test unlinking a dataset & immediately re-using name */
|
||||
test_misc2(); /* Test storing a VL-derived datatype in two different files */
|
||||
test_misc3(); /* Test reading from chunked dataset with non-zero fill value */
|
||||
|
||||
} /* test_misc() */
|
||||
|
||||
@ -320,4 +398,5 @@ cleanup_misc(void)
|
||||
remove(MISC1_FILE);
|
||||
remove(MISC2_FILE_1);
|
||||
remove(MISC2_FILE_2);
|
||||
remove(MISC3_FILE);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user