From 12d47d9348974c23cbaf5cfb6d0c17caf02d4e60 Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 16:24:19 +0200 Subject: [PATCH 01/13] add fast fix and tests --- src/h5cpp/node/dataset.hpp | 13 ++++++++++++- test/node/dataset_direct_chunk_test.cpp | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/h5cpp/node/dataset.hpp b/src/h5cpp/node/dataset.hpp index fcf8eb9307..a21f33c5ac 100644 --- a/src/h5cpp/node/dataset.hpp +++ b/src/h5cpp/node/dataset.hpp @@ -949,7 +949,18 @@ std::uint32_t Dataset::read_chunk(T &data, std::uint32_t filter_mask; if(mem_type.get_class() == datatype::Class::Integer) { -#if H5_VERSION_GE(1,10,3) +#if H5_VERSION_GE(2,0,0) + if(H5Dread_chunk1(static_cast(*this), + static_cast(dtpl), + offset.data(), + &filter_mask, + dataspace::ptr(data))<0) + { + std::stringstream ss; + ss<<"Failure to read chunk data from dataset ["<(*this), static_cast(dtpl), offset.data(), diff --git a/test/node/dataset_direct_chunk_test.cpp b/test/node/dataset_direct_chunk_test.cpp index 4bf81ac902..898cf82b52 100644 --- a/test/node/dataset_direct_chunk_test.cpp +++ b/test/node/dataset_direct_chunk_test.cpp @@ -112,6 +112,13 @@ SCENARIO("testing dataset access via chunks") { REQUIRE(frame == read_value); } } + THEN("we can read chunk the data back") { + UShorts read_chunk_value(xdim * ydim); + for (long long unsigned int i = 0; i != nframe; i++) { + dataset.read_chunk(read_chunk_value, {i, 0, 0}); + REQUIRE(frame == read_chunk_value); + } + } } } From 839cce759f7d18e4cba99951f06cbb5ad24bc974 Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 16:40:04 +0200 Subject: [PATCH 02/13] improve test case --- test/node/dataset_direct_chunk_test.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/node/dataset_direct_chunk_test.cpp b/test/node/dataset_direct_chunk_test.cpp index 898cf82b52..6f7d7bcc9b 100644 --- a/test/node/dataset_direct_chunk_test.cpp +++ b/test/node/dataset_direct_chunk_test.cpp @@ -111,13 +111,13 @@ SCENARIO("testing dataset access via chunks") { dataset.read(read_value, framespace); REQUIRE(frame == read_value); } - } - THEN("we can read chunk the data back") { - UShorts read_chunk_value(xdim * ydim); - for (long long unsigned int i = 0; i != nframe; i++) { - dataset.read_chunk(read_chunk_value, {i, 0, 0}); - REQUIRE(frame == read_chunk_value); - } + AND_THEN("we can read chunk the data back") { + UShorts read_chunk_value(xdim * ydim); + for (long long unsigned int i = 0; i != nframe; i++) { + dataset.read_chunk(read_chunk_value, {i, 0, 0}); + REQUIRE(frame == read_chunk_value); + } + } } } } From 317537a6fe12b40f1344709afe308a2019eb59b8 Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 18:42:37 +0200 Subject: [PATCH 03/13] add pixi tests --- .github/workflows/cmake-build.yml | 27 ++++++++- .github/workflows/pixi/recipe.yaml | 86 ++++++++++++++++++++++++++++ .github/workflows/pixi/variants.yaml | 4 ++ pixi.toml | 14 +++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pixi/recipe.yaml create mode 100644 .github/workflows/pixi/variants.yaml create mode 100644 pixi.toml diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index cda19e1003..883b738d9e 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -363,4 +363,29 @@ jobs: - name: Stop the docker run: | docker exec --user root build /bin/bash -c "chown -R 1001 /home/p00user/src " - docker container stop build + docker container stop build + + pixi_tests: + runs-on: ubuntu-latest + container: + image: debian:trixie + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + + - name: install pixi + shell: bash + run: | + apt-get update + apt-get -qq -y dist-upgrade + apt-get -qq update && apt-get install -qq -y flake8 python3 curl bash + curl -fsSL https://pixi.sh/install.sh | sh + export PATH=/github/home/.pixi/bin:$PATH + pixi shell-hook > .sh.sh + source .sh.sh + pixi add rattler-build compilers hdf5=2.0.0 + - name: build h5cpp + shell: bash + run: | + source .sh.sh + pixi run rattler-build build --recipe .github/workflows/pixi/recipe.yaml diff --git a/.github/workflows/pixi/recipe.yaml b/.github/workflows/pixi/recipe.yaml new file mode 100644 index 0000000000..7ab8dd136a --- /dev/null +++ b/.github/workflows/pixi/recipe.yaml @@ -0,0 +1,86 @@ +context: + version: 0.7.1 + +package: + name: h5cpp + version: ${{ version }} + +source: + url: https://github.com/ess-dmsc/h5cpp/archive/refs/tags/v${{ version }}.tar.gz + sha256: e832fb729aaf328d0f30b34e577645f33fdaccda0e1b0c06cb9a3d412a728ad3 + patches: + - relax_version_checks.patch + - if: win + then: + - remove-findhdf5.patch + +build: + number: 2 + script: + - if: win + then: + - set CL=/DH5_BUILT_AS_DYNAMIC_LIB=1 %CL% + - cmake -B build -G Ninja %CMAKE_ARGS% -DH5CPP_CONAN=DISABLE -DHDF5_FIND_DEBUG=ON -DHDF5_USE_STATIC_LIBRARIES=OFF + - if: linux + then: cmake -B build ${CMAKE_ARGS} -DH5CPP_CONAN=DISABLE + - if: osx and build_platform == target_platform + then: cmake -B build ${CMAKE_ARGS} -DH5CPP_CONAN=DISABLE + - if: osx and build_platform != target_platform + then: cmake -B build ${CMAKE_ARGS} -DH5CPP_CONAN=DISABLE -DH5CPP_DISABLE_TESTS=ON + - cmake --build build + - cmake --install build + - if: win + then: ctest --test-dir build --extra-verbose --no-tests=error + - if: linux + then: ctest --test-dir build --extra-verbose --no-tests=error --exclude-regex='signed integer properties - char|signed integer properties with cref - char' + - if: osx and build_platform == target_platform + then: ctest --test-dir build --extra-verbose --no-tests=error --exclude-regex='signed integer properties - char|signed integer properties with cref - char' + +requirements: + build: + - cmake + - ninja + - if: not win + then: make + host: + - hdf5 + - catch2 + - zlib + run_exports: + - ${{ pin_subpackage("h5cpp", upper_bound="x.x") }} + +tests: + - package_contents: + include: + - h5cpp/file/file.hpp + - h5cpp/core/*.hpp + - h5cpp/attribute/*.hpp + - h5cpp/dataspace/*.hpp + - h5cpp/datatype/*.hpp + - h5cpp/error/*.hpp + - h5cpp/file/*.hpp + - h5cpp/filter/*.hpp + - h5cpp/node/*.hpp + - h5cpp/property/*.hpp + - h5cpp/utilities/*.hpp + - h5cpp/contrib/nexus/ebool.hpp + - h5cpp/contrib/stl/*.hpp + lib: + - h5cpp + +about: + homepage: https://github.com/ess-dmsc/h5cpp + license: LGPL-2.1-only + license_file: LICENSE + summary: C++ wrapper for hdf5 + description: | + h5cpp is C++ wrapper for hdf5 + which significantly simplifies development of HDF5 code. + It provides a high level abstraction to the HDF5 low-level types. + documentation: https://ess-dmsc.github.io/h5cpp + repository: https://github.com/ess-dmsc/h5cpp + +extra: + recipe-maintainers: + - jkotan + - yuelongyu diff --git a/.github/workflows/pixi/variants.yaml b/.github/workflows/pixi/variants.yaml new file mode 100644 index 0000000000..87771d73d0 --- /dev/null +++ b/.github/workflows/pixi/variants.yaml @@ -0,0 +1,4 @@ +zlib: + - 1 +hdf5: + - 2.0.0 diff --git a/pixi.toml b/pixi.toml new file mode 100644 index 0000000000..d902763b63 --- /dev/null +++ b/pixi.toml @@ -0,0 +1,14 @@ +[workspace] +authors = ["Jan Kotanski "] +channels = ["conda-forge"] +name = "h5cpp" +platforms = ["linux-64", "linux-aarch64", "osx-arm64", "osx-64", "win-64"] +version = "0.7.1" + +[tasks] + +[dependencies] +rattler-build = ">=0.60.0,<0.61" +ipython = ">=9.11.0,<10" +python = "==3.14" +conda-smithy = ">=3.56.3,<4" From b57c081752c885ccce3e494ec395691a981597cc Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 18:45:32 +0200 Subject: [PATCH 04/13] update config --- pixi.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pixi.toml b/pixi.toml index d902763b63..c68a864d71 100644 --- a/pixi.toml +++ b/pixi.toml @@ -2,7 +2,8 @@ authors = ["Jan Kotanski "] channels = ["conda-forge"] name = "h5cpp" -platforms = ["linux-64", "linux-aarch64", "osx-arm64", "osx-64", "win-64"] +platforms = ["linux-64"] +# platforms = ["linux-64", "linux-aarch64", "osx-arm64", "osx-64", "win-64"] version = "0.7.1" [tasks] From 2f2529e6c9f37d463c84340d0cc6e6c256682f8c Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 18:48:14 +0200 Subject: [PATCH 05/13] update variants --- .github/workflows/cmake-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 883b738d9e..b57c9248b5 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -383,7 +383,7 @@ jobs: export PATH=/github/home/.pixi/bin:$PATH pixi shell-hook > .sh.sh source .sh.sh - pixi add rattler-build compilers hdf5=2.0.0 + pixi add rattler-build compilers - name: build h5cpp shell: bash run: | From 7fec7b32f43f41fd000fd42be4aaffe21363454a Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 18:50:25 +0200 Subject: [PATCH 06/13] update variants --- .github/workflows/pixi/recipe.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pixi/recipe.yaml b/.github/workflows/pixi/recipe.yaml index 7ab8dd136a..a3fd873cca 100644 --- a/.github/workflows/pixi/recipe.yaml +++ b/.github/workflows/pixi/recipe.yaml @@ -6,13 +6,7 @@ package: version: ${{ version }} source: - url: https://github.com/ess-dmsc/h5cpp/archive/refs/tags/v${{ version }}.tar.gz - sha256: e832fb729aaf328d0f30b34e577645f33fdaccda0e1b0c06cb9a3d412a728ad3 - patches: - - relax_version_checks.patch - - if: win - then: - - remove-findhdf5.patch + - path: ../../../ build: number: 2 From f01a13147a14de5202db971ad16c2d2a87e45c2a Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 18:55:01 +0200 Subject: [PATCH 07/13] comment out hdf5 --- .github/workflows/pixi/variants.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pixi/variants.yaml b/.github/workflows/pixi/variants.yaml index 87771d73d0..b638de6ce5 100644 --- a/.github/workflows/pixi/variants.yaml +++ b/.github/workflows/pixi/variants.yaml @@ -1,4 +1,4 @@ zlib: - 1 -hdf5: - - 2.0.0 +# hdf5: +# - 2.0.0 From e657874f9fd0ffc8985d05255ffd1df94494a6bb Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 18:57:58 +0200 Subject: [PATCH 08/13] add zlib --- .github/workflows/pixi/recipe.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pixi/recipe.yaml b/.github/workflows/pixi/recipe.yaml index a3fd873cca..497acdea27 100644 --- a/.github/workflows/pixi/recipe.yaml +++ b/.github/workflows/pixi/recipe.yaml @@ -32,8 +32,10 @@ build: requirements: build: + - hdf5 - cmake - ninja + - zlib - if: not win then: make host: From 4af170987ad22ab7b0ebaea28cfa9f4c3fe81051 Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 19:04:16 +0200 Subject: [PATCH 09/13] add V200 --- src/h5cpp/property/file_access.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/h5cpp/property/file_access.hpp b/src/h5cpp/property/file_access.hpp index 7926a78fa2..1442cce087 100644 --- a/src/h5cpp/property/file_access.hpp +++ b/src/h5cpp/property/file_access.hpp @@ -48,6 +48,9 @@ enum class LibVersion : std::underlying_type::type { #endif #if H5_VERSION_GE(1,13,0) V114 = H5F_LIBVER_V114, +#endif +#if H5_VERSION_GE(2,0,0) + V200 = H5F_LIBVER_V200, #endif Earliest = H5F_LIBVER_EARLIEST }; From f83dc5fe0c16157da5416fcee8692985f3d498bb Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 1 Apr 2026 19:22:08 +0200 Subject: [PATCH 10/13] udpate prefix --- .github/workflows/pixi/recipe.yaml | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pixi/recipe.yaml b/.github/workflows/pixi/recipe.yaml index 497acdea27..d8e5f7b3b0 100644 --- a/.github/workflows/pixi/recipe.yaml +++ b/.github/workflows/pixi/recipe.yaml @@ -11,24 +11,10 @@ source: build: number: 2 script: - - if: win - then: - - set CL=/DH5_BUILT_AS_DYNAMIC_LIB=1 %CL% - - cmake -B build -G Ninja %CMAKE_ARGS% -DH5CPP_CONAN=DISABLE -DHDF5_FIND_DEBUG=ON -DHDF5_USE_STATIC_LIBRARIES=OFF - - if: linux - then: cmake -B build ${CMAKE_ARGS} -DH5CPP_CONAN=DISABLE - - if: osx and build_platform == target_platform - then: cmake -B build ${CMAKE_ARGS} -DH5CPP_CONAN=DISABLE - - if: osx and build_platform != target_platform - then: cmake -B build ${CMAKE_ARGS} -DH5CPP_CONAN=DISABLE -DH5CPP_DISABLE_TESTS=ON + - cmake -B build ${CMAKE_ARGS} -DH5CPP_CONAN=DISABLE -DCMAKE_INSTALL_PREFIX=${PREFIX} - cmake --build build - cmake --install build - - if: win - then: ctest --test-dir build --extra-verbose --no-tests=error - - if: linux - then: ctest --test-dir build --extra-verbose --no-tests=error --exclude-regex='signed integer properties - char|signed integer properties with cref - char' - - if: osx and build_platform == target_platform - then: ctest --test-dir build --extra-verbose --no-tests=error --exclude-regex='signed integer properties - char|signed integer properties with cref - char' + - ctest --test-dir build --extra-verbose --no-tests=error requirements: build: @@ -36,8 +22,7 @@ requirements: - cmake - ninja - zlib - - if: not win - then: make + - make host: - hdf5 - catch2 From eb0b43abe122a56b915adfd4d00a3ccd9155a045 Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Thu, 2 Apr 2026 17:30:36 +0200 Subject: [PATCH 11/13] add read_chunk with byte_size --- src/h5cpp/node/dataset.hpp | 90 +++++++++++++++++++++++++ test/node/dataset_direct_chunk_test.cpp | 7 ++ 2 files changed, 97 insertions(+) diff --git a/src/h5cpp/node/dataset.hpp b/src/h5cpp/node/dataset.hpp index a21f33c5ac..6be528ca52 100644 --- a/src/h5cpp/node/dataset.hpp +++ b/src/h5cpp/node/dataset.hpp @@ -415,6 +415,50 @@ class DLL_EXPORT Dataset : public Node property::DatasetTransferList::get()) const; + //! + //! \brief read dataset chunk (*since hdf5 1.10.2*) + //! + //! Read a chunk from a dataset to an instance of T with given byte size. + //! + //! \throws std::runtime_error in case of a failure + //! \tparam T source type + //! \param data reference to the source instance of T + //! \param byte_size of data + //! \param offset logical position of the first element of the chunk in the dataset's dataspace + //! \param dtpl reference to a dataset transfer property list + //! \return filter_mask mask of which filters are used with the chunk + //! + template + std::uint32_t read_chunk(T &data, + size_t byte_size, + std::vector offset, + const property::DatasetTransferList &dtpl = + property::DatasetTransferList::get()) const; + + + //! + //! \brief read dataset chunk + //! + //! Read a chunk from a dataset to an instance of T. + //! + //! \throws std::runtime_error in case of a failure + //! \tparam T source type + //! \param data reference to the source instance of T + //! \param byte_size of data + //! \param mem_type reference to the memory data type + //! \param offset logical position of the first element of the chunk in the dataset's dataspace + //! \param dtpl reference to a dataset transfer property list + //! \return filter_mask mask of which filters are used with the chunk + //! + template + std::uint32_t read_chunk(T &data, + size_t byte_size, + const datatype::Datatype &mem_type, + std::vector & offset, + const property::DatasetTransferList &dtpl = + property::DatasetTransferList::get()) const; + + //! //! \brief read dataset chunk //! @@ -940,6 +984,16 @@ std::uint32_t Dataset::read_chunk(T &data, return read_chunk(data, mem_type_holder.get(data), offset, dtpl); } +template +std::uint32_t Dataset::read_chunk(T &data, + size_t byte_size, + std::vector offset, + const property::DatasetTransferList &dtpl) const +{ + hdf5::datatype::DatatypeHolder mem_type_holder; + return read_chunk(data, byte_size, mem_type_holder.get(data), offset, dtpl); +} + template std::uint32_t Dataset::read_chunk(T &data, const datatype::Datatype &mem_type, @@ -993,6 +1047,42 @@ std::uint32_t Dataset::read_chunk(T &data, return filter_mask; } + +template +std::uint32_t Dataset::read_chunk(T &data, + size_t byte_size, + const datatype::Datatype &mem_type, + std::vector & offset, + const property::DatasetTransferList &dtpl) const +{ + std::uint32_t filter_mask; + if(mem_type.get_class() == datatype::Class::Integer) + { +#if H5_VERSION_GE(2,0,0) + if(H5Dread_chunk(static_cast(*this), + static_cast(dtpl), + offset.data(), + &filter_mask, + dataspace::ptr(data), byte_size)<0) + { + std::stringstream ss; + ss<<"Failure to read chunk data from dataset ["< diff --git a/test/node/dataset_direct_chunk_test.cpp b/test/node/dataset_direct_chunk_test.cpp index 6f7d7bcc9b..6edfa5775d 100644 --- a/test/node/dataset_direct_chunk_test.cpp +++ b/test/node/dataset_direct_chunk_test.cpp @@ -117,6 +117,13 @@ SCENARIO("testing dataset access via chunks") { dataset.read_chunk(read_chunk_value, {i, 0, 0}); REQUIRE(frame == read_chunk_value); } + AND_THEN("we can read chunk the data back with given buffer byte_size") { + UShorts read_chunk_value(xdim * ydim); + for (long long unsigned int i = 0; i != nframe; i++) { + dataset.read_chunk(read_chunk_value, xdim * ydim * sizeof(UShorts), {i, 0, 0}); + REQUIRE(frame == read_chunk_value); + } + } } } } From 237c67d0f86b34a7df6dbbc13699ed1a9db5729a Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Thu, 2 Apr 2026 17:34:19 +0200 Subject: [PATCH 12/13] fix typo --- src/h5cpp/node/dataset.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/h5cpp/node/dataset.hpp b/src/h5cpp/node/dataset.hpp index 6be528ca52..707ce98bb3 100644 --- a/src/h5cpp/node/dataset.hpp +++ b/src/h5cpp/node/dataset.hpp @@ -1070,7 +1070,7 @@ std::uint32_t Dataset::read_chunk(T &data, error::Singleton::instance().throw_with_stack(ss.str()); } #else - read_chunk(data, men_type, offset, dtpl); + read_chunk(data, mem_type, offset, dtpl); #endif } else From 4c0a01d38e08b0e383e6a4c8bf47c7d732750a55 Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Thu, 2 Apr 2026 17:42:24 +0200 Subject: [PATCH 13/13] fix typo --- src/h5cpp/node/dataset.hpp | 2 +- test/node/dataset_direct_chunk_test.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/h5cpp/node/dataset.hpp b/src/h5cpp/node/dataset.hpp index 707ce98bb3..6db2598e56 100644 --- a/src/h5cpp/node/dataset.hpp +++ b/src/h5cpp/node/dataset.hpp @@ -1063,7 +1063,7 @@ std::uint32_t Dataset::read_chunk(T &data, static_cast(dtpl), offset.data(), &filter_mask, - dataspace::ptr(data), byte_size)<0) + dataspace::ptr(data), &byte_size)<0) { std::stringstream ss; ss<<"Failure to read chunk data from dataset ["<