summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2019-09-25 20:10:37 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2019-09-25 20:10:37 (GMT)
commit6632780f419d48b7ca21f5b5dcd912f9698f67e7 (patch)
treecec40a78acdc04e2a53d32ec58f1bcfa15ca4ba1
parentf77d8f04fd703868d016a3ff824829bcb277b80f (diff)
parent2a4bc8c63e842d5e7551e6e75a9ca95c0c2d2886 (diff)
downloadhdf5-6632780f419d48b7ca21f5b5dcd912f9698f67e7.zip
hdf5-6632780f419d48b7ca21f5b5dcd912f9698f67e7.tar.gz
hdf5-6632780f419d48b7ca21f5b5dcd912f9698f67e7.tar.bz2
Merge pull request #1943 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop
* commit '2a4bc8c63e842d5e7551e6e75a9ca95c0c2d2886': Merge Binh-Minh's changes for code improvement to chunk_info.c (PR #1942) to develop branch.
-rw-r--r--test/chunk_info.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/test/chunk_info.c b/test/chunk_info.c
index d3e5751..70f6eb6 100644
--- a/test/chunk_info.c
+++ b/test/chunk_info.c
@@ -43,7 +43,9 @@
#include "H5Dpkg.h"
#include "testhdf5.h"
+#ifdef H5_HAVE_FILTER_DEFLATE
#include "zlib.h"
+#endif
/* Test file names, using H5F_libver_t as indices */
const char *FILENAME[] = {
@@ -467,7 +469,7 @@ test_get_chunk_info_highest_v18(hid_t fapl)
hid_t dset = H5I_INVALID_HID; /* Dataset ID */
hid_t cparms = H5I_INVALID_HID; /* Creation plist */
hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */
- int direct_buf[NUM_CHUNKS][CHUNK_NX][CHUNK_NY]; /* Data in chunks */
+ int direct_buf[CHUNK_NX][CHUNK_NY]; /* Data chunk */
hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* 2 unlimited dims */
hsize_t out_offset[2]; /* Buffer to get offset coordinates */
hsize_t size = 0; /* Size of an allocated/written chunk */
@@ -480,11 +482,13 @@ test_get_chunk_info_highest_v18(hid_t fapl)
int fillvalue = -1; /* Fill value */
int aggression = 9; /* Compression aggression setting */
hsize_t offset[2] = {0, 0}; /* Offset coordinates of a chunk */
+#ifdef H5_HAVE_FILTER_DEFLATE
const Bytef *z_src = (const Bytef*)(direct_buf);
Bytef *z_dst; /*destination buffer */
uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(CHK_SIZE);
uLong z_src_nbytes = (uLong)CHK_SIZE;
- void *outbuf = NULL; /* Pointer to new buffer */
+#endif /* end H5_HAVE_FILTER_DEFLATE */
+ void *inbuf = NULL; /* Pointer to new buffer */
hsize_t chunk_size = CHK_SIZE; /* Size of a chunk, can be compressed or not */
hsize_t ii, jj; /* Array indices */
int n; /* Used as chunk index, but int to avoid conversion warning */
@@ -523,16 +527,19 @@ test_get_chunk_info_highest_v18(hid_t fapl)
dset = H5Dcreate2(chunkfile, SIMPLE_CHUNKED_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, H5P_DEFAULT);
if(dset < 0) TEST_ERROR
- /* Initialize the array of chunk data for all NUM_CHUNKS chunks */
- for(n = 0; n < NUM_CHUNKS; n++)
- for(ii = 0; ii < CHUNK_NX; ii++)
- for(jj = 0; jj < CHUNK_NY; jj++)
- direct_buf[n][ii][jj] = (int)(ii*jj) + 1;
+ /* Initialize a chunk of data */
+ for(ii = 0; ii < CHUNK_NX; ii++)
+ for(jj = 0; jj < CHUNK_NY; jj++)
+ direct_buf[ii][jj] = (int)(ii*jj) + 1;
#ifdef H5_HAVE_FILTER_DEFLATE
- /* Allocate output (compressed) buffer */
- outbuf = malloc(z_dst_nbytes);
- z_dst = (Bytef *)outbuf;
+ /* Allocate input (compressed) buffer */
+ inbuf = malloc(z_dst_nbytes);
+
+ /* Set chunk size to the compressed chunk size and the chunk point
+ to the compressed data chunk */
+ chunk_size = (hsize_t)z_dst_nbytes;
+ z_dst = (Bytef *)inbuf;
/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
@@ -548,6 +555,10 @@ test_get_chunk_info_highest_v18(hid_t fapl)
fprintf(stderr, "other deflate error");
TEST_ERROR
}
+#else
+ /* Allocate input (non-compressed) buffer */
+ inbuf = malloc(CHK_SIZE);
+ HDmemcpy(inbuf, direct_buf, CHK_SIZE);
#endif /* end H5_HAVE_FILTER_DEFLATE */
/* Write only NUM_CHUNKS_WRITTEN chunks at the following logical coords:
@@ -555,21 +566,15 @@ test_get_chunk_info_highest_v18(hid_t fapl)
n = 0;
for(ii = START_CHK_X; ii < END_CHK_X; ii++)
for(jj = START_CHK_Y; jj < END_CHK_Y; jj++, n++) {
-
-#ifdef H5_HAVE_FILTER_DEFLATE
- /* Set chunk size to the compressed chunk size and the chunk point
- to the compressed data chunk */
- chunk_size = (hsize_t)z_dst_nbytes;
-#endif /* end H5_HAVE_FILTER_DEFLATE */
offset[0] = ii * CHUNK_NX;
offset[1] = jj * CHUNK_NY;
- ret = H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, chunk_size, (void*)outbuf);
+ ret = H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, chunk_size, (void*)inbuf);
if(ret < 0) TEST_ERROR
}
- /* Free the read buffer */
- if(outbuf)
- HDfree(outbuf);
+ /* Free the input buffer */
+ if(inbuf)
+ HDfree(inbuf);
if(H5Fflush(dset, H5F_SCOPE_LOCAL) < 0)
TEST_ERROR