Skip to content

Commit

Permalink
H5Ztrans: (feature) Improved H5Z_xform_noop() and H5Z_xform_create() … (
Browse files Browse the repository at this point in the history
#933)

* H5Ztrans: (feature) Improved H5Z_xform_noop() and H5Z_xform_create() function

- Made a small improvement for H5Z_xform_noop() function. Now,
  the function will also return TRUE if the data transform function
  expression = "x". For this case, the HDF5 library behaves in a
  similar fashion as the case when no data transform function has been
  specified.
- Improved the inline documentation of the function
  H5Z_xform_create() such it is more inline with the rest of the
  code.

* Committing clang-format changes

* H5Ztrans: (feature) Added 3 tests for improved H5Z_xform_noop() function

- Added serial test with data transform expression = "x" to
  verify the improved H5Z_xform_noop() function behaves as expected.
- Added 2 parallel tests with data transform expression = "x"
  in combination with a filter. Before, these tests will fail but
  with the improved H5Z_xform_noop() function they work and result
  in the expected behavior.
- Small bug fix for one of parallel filter tests.

* Committing clang-format changes

* H5Ztrans: (feature) Added release note about detection of the
           simple data transform function "x".

- Added a brief explanation about the implemented improvement
  of the detection of the simple data transform function "x"
  to the RELEASE.txt file.

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Jan-Willem Blokland and github-actions[bot] authored Sep 13, 2021
1 parent f6f1a02 commit 7c973de
Show file tree
Hide file tree
Showing 5 changed files with 473 additions and 6 deletions.
11 changes: 11 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,17 @@ Bug Fixes since HDF5-1.12.0 release
===================================
Library
-------
- Detection of simple data transform function "x"

In the case of the simple data transform function "x" the (parallel)
library recognizes this is the same as not applying this data transform
function. This improves the I/O performance. In the case of the parallel
library, it also avoids breaking to independent I/O, which makes it
possible to apply a filter when writing or reading data to or from
teh HDF5 file.

(JWSB - 2021/09/13)

- Fixed an invalid read and memory leak when parsing corrupt file space
info messages

Expand Down
18 changes: 13 additions & 5 deletions src/H5Ztrans.c
Original file line number Diff line number Diff line change
Expand Up @@ -1547,11 +1547,11 @@ H5Z_xform_create(const char *expr)
(HDisdigit(expr[i - 1]) || (expr[i - 1] == '.')) &&
(HDisdigit(expr[i + 1]) || (expr[i + 1] == '-') || (expr[i + 1] == '+')))
continue;
}
} /* end if */

count++;
}
}
} /* end if */
} /* end for */

/* When there are no "x"'s in the equation (ie, simple transform case),
* we don't need to allocate any space since no array will have to be
Expand Down Expand Up @@ -1749,11 +1749,19 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop)
hbool_t
H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop)
{
hbool_t ret_value = FALSE; /* Return value */
hbool_t ret_value = TRUE; /* Return value */

FUNC_ENTER_NOAPI_NOINIT_NOERR

ret_value = (data_xform_prop ? FALSE : TRUE);
if (data_xform_prop) {
ret_value = FALSE;

/* Check for trivial data tranformation: expression = "x" */
if ((HDstrlen(data_xform_prop->xform_exp) == 1) && data_xform_prop->dat_val_pointers &&
(data_xform_prop->dat_val_pointers->num_ptrs == 1)) {
ret_value = TRUE;
} /* end if */
} /* end if */

FUNC_LEAVE_NOAPI(ret_value)
} /* H5Z_xform_noop() */
Expand Down
27 changes: 27 additions & 0 deletions test/dtransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ test_specials(hid_t file)
const char *special4 = "-x";
const char *special5 = "+x";
const char *special6 = "2e+1*x";
const char *special7 = "x";

TESTING("data transform of some special cases")

Expand Down Expand Up @@ -726,6 +727,32 @@ test_specials(hid_t file)

COMPARE_INT(read_buf, data_res)

if (H5Dclose(dset_id) < 0)
TEST_ERROR

/*-----------------------------
* Operation 7: x
* This operation will be
* treated if no function has
* been specified.
*----------------------------*/
if (H5Pset_data_transform(dxpl_id, special7) < 0)
TEST_ERROR;

for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++)
data_res[row][col] = transformData[row][col];

if ((dset_id = H5Dcreate2(file, "/special7", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0)
TEST_ERROR
if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0)
TEST_ERROR

COMPARE_INT(read_buf, data_res)

if (H5Dclose(dset_id) < 0)
TEST_ERROR

Expand Down
Loading

0 comments on commit 7c973de

Please sign in to comment.