mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-11 16:01:00 +08:00
Merge remote-tracking branch 'origin/develop' into merge_func_enter_vol
This commit is contained in:
commit
eb69e5b683
@ -62,6 +62,14 @@
|
||||
#define OVERWRITE_CHUNK_NY 2
|
||||
#define OVERWRITE_VALUE 42
|
||||
|
||||
/* Defines used in test_single_chunk_latest() */
|
||||
#define FILE "single_latest.h5"
|
||||
#define DATASET "dataset"
|
||||
#define DIM0 4
|
||||
#define DIM1 32
|
||||
#define CHUNK0 DIM0
|
||||
#define CHUNK1 DIM1
|
||||
|
||||
/* Local prototypes for filter functions */
|
||||
static size_t filter_bogus1(unsigned int flags, size_t cd_nelmts,
|
||||
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
|
||||
@ -1968,6 +1976,139 @@ error:
|
||||
return 1;
|
||||
} /* test_read_unallocated_chunk() */
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_single_chunk_latest
|
||||
*
|
||||
* Purpose: This is to verify the fix for jira issue HDFFV-10425.
|
||||
* The problem was due to a bug in the internal ilbrary routine
|
||||
* H5D__chunk_direct_write() which passed a null dataset
|
||||
* pointer to the insert callback for the chunk index type.
|
||||
* Currently, the single chunk index is the only one that
|
||||
* used the dataset pointer in the insert callback.
|
||||
*
|
||||
* This routine is based on the test program attached to
|
||||
* this jira issue:
|
||||
* Create a file with the latest format and a chunked dataset
|
||||
* with one single chunk. The library will use single chunk
|
||||
* index for the dataset.
|
||||
* Verify that the data read is the same as the written data.
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: 1
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
test_single_chunk_latest(void)
|
||||
{
|
||||
hid_t fid; /* File ID */
|
||||
hid_t fapl; /* File access property list ID */
|
||||
hid_t sid; /* Dataspace ID */
|
||||
hid_t did; /* Dataset ID */
|
||||
hid_t dcpl; /* Dataset creation property list */
|
||||
hsize_t dims[2] = {DIM0, DIM1}; /* Dimension sizes */
|
||||
hsize_t chunk[2] = {CHUNK0, CHUNK1}; /* Chunk dimension sizes */
|
||||
hsize_t offset[2] = {0,0}; /* Offset for writing */
|
||||
int wdata[DIM0][DIM1]; /* Write buffer */
|
||||
int rdata[DIM0][DIM1]; /* Read buffer */
|
||||
int i, j; /* Local index variable */
|
||||
|
||||
TESTING("H5DOwrite_chunk with single chunk and latest format");
|
||||
|
||||
/* Initialize data */
|
||||
for (i=0; i<DIM0; i++) {
|
||||
for (j=0; j< DIM1; j++)
|
||||
wdata[i][j] = j/CHUNK0;
|
||||
}
|
||||
|
||||
/* Create a new file with the latest format */
|
||||
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
||||
goto error;
|
||||
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
|
||||
goto error;
|
||||
if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
|
||||
goto error;
|
||||
|
||||
/* Create dataspace */
|
||||
if((sid = H5Screate_simple(2, dims, NULL)) < 0)
|
||||
goto error;
|
||||
|
||||
/* Create the dataset creation property list and set the chunk size */
|
||||
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
||||
goto error;
|
||||
if(H5Pset_chunk(dcpl, 2, chunk) < 0)
|
||||
goto error;
|
||||
|
||||
/* Create the dataset */
|
||||
if((did = H5Dcreate(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
|
||||
/* Write the data directly to the dataset */
|
||||
if(H5DOwrite_chunk(did, H5P_DEFAULT, 0, offset, CHUNK0*CHUNK1*4, (void *)wdata) < 0)
|
||||
goto error;
|
||||
|
||||
/*
|
||||
* Close and release resources.
|
||||
*/
|
||||
if(H5Pclose(dcpl) < 0)
|
||||
goto error;
|
||||
if(H5Dclose(did) < 0)
|
||||
goto error;
|
||||
if(H5Sclose(sid) < 0)
|
||||
goto error;
|
||||
if(H5Pclose(fapl) < 0)
|
||||
goto error;
|
||||
if(H5Fclose(fid) < 0)
|
||||
goto error;
|
||||
|
||||
/* Open the file and dataset with default properties */
|
||||
if((fid = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((did = H5Dopen(fid, DATASET, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
|
||||
/* Retrieve dataset creation property list */
|
||||
if((dcpl = H5Dget_create_plist(did)) < 0)
|
||||
goto error;
|
||||
|
||||
/* Read the data */
|
||||
if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0)
|
||||
goto error;
|
||||
|
||||
/* Verify that the data read was correct. */
|
||||
for (i = 0; i < DIM0; i++) {
|
||||
for (j = 0; j < DIM1; j++) {
|
||||
if(rdata[i][j] != wdata[i][j])
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Close and release resources
|
||||
*/
|
||||
if(H5Pclose(dcpl) < 0)
|
||||
goto error;
|
||||
if(H5Dclose(did) < 0)
|
||||
goto error;
|
||||
if(H5Fclose(fid) < 0)
|
||||
goto error;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY {
|
||||
H5Dclose(did);
|
||||
H5Sclose(sid);
|
||||
H5Pclose(dcpl);
|
||||
H5Pclose(fapl);
|
||||
H5Fclose(fid);
|
||||
} H5E_END_TRY;
|
||||
|
||||
H5_FAILED();
|
||||
return 1;
|
||||
} /* test_single_chunk_latest() */
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: Main function
|
||||
*
|
||||
@ -2012,6 +2153,8 @@ int main( void )
|
||||
nerrors += test_read_unfiltered_dset(file_id);
|
||||
nerrors += test_read_unallocated_chunk(file_id);
|
||||
|
||||
nerrors += test_single_chunk_latest();
|
||||
|
||||
if(H5Fclose(file_id) < 0)
|
||||
goto error;
|
||||
|
||||
|
@ -319,6 +319,22 @@ Bug Fixes since HDF5-1.10.1 release
|
||||
|
||||
Library
|
||||
-------
|
||||
- The data read after a direct chunk write to a chunked dataset
|
||||
was incorrect.
|
||||
|
||||
The problem was due to the passing of a null dataset pointer to
|
||||
the insert callback for the chunk index in the routine
|
||||
H5D__chunk_direct_write() in H5Dchunk.c
|
||||
The dataset was a single-chunked dataset which will use the
|
||||
single chunk index when latest format was enabled on file creation.
|
||||
The single chunk index was the only index that used this pointer
|
||||
in the insert callback.
|
||||
|
||||
Pass the dataset pointer to the insert callback for the chunk
|
||||
index in H5D__chunk_direct_write().
|
||||
|
||||
(VC - 2018/03/20, HDFFV-10425)
|
||||
|
||||
- Add public routine H5DOread_chunk to the high-level C library
|
||||
|
||||
As we have H5DOwrite_chunk() to write an entire chunk to the file
|
||||
|
Loading…
Reference in New Issue
Block a user