ATLAS Offline Software
Loading...
Searching...
No Matches
addLz4ToPlist.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "H5Cpp.h"
8
9#include <stdexcept>
10#include <array>
11#include <mutex>
12
13// Forward declare the filter struct from H5Zlz4.c (C linkage)
14extern "C" {
15 extern const H5Z_class2_t H5Z_LZ4[1];
16}
17
18void addLz4ToPlist(H5::DSetCreatPropList& plist) {
19
20 // Register the filter if it isn't already known to the library.
21 // Since LZ4PluginLib is linked into the binary, H5Z_LZ4 is already
22 // in memory -- no HDF5_PLUGIN_PATH or symlink directory needed.
23 // The registry is global, so registration happens once per process.
24 static std::once_flag registered;
25 std::call_once(registered, []() {
26 if (!H5Zfilter_avail(H5Z_FILTER_LZ4)) {
27 herr_t reg = H5Zregister(H5Z_LZ4);
28 if (reg < 0) throw std::runtime_error("can't register LZ4 filter");
29 }
30 });
31
32 // this specifies additional arguments. For LZ4 this can have one
33 // entry, the chunk size. Leaving it empty should use the default
34 // chunk size.
35 std::array<unsigned int, 0> cd_values;
36
37 herr_t status = H5Pset_filter(
38 plist.getId(),
40 H5Z_FLAG_MANDATORY,
41 cd_values.size(),
42 cd_values.data());
43
44 if (status < 0) throw std::runtime_error("can't set LZ4 filter");
45
46}
#define H5Z_FILTER_LZ4
Definition H5Zlz4.h:10
const H5Z_class2_t H5Z_LZ4[1]
void addLz4ToPlist(H5::DSetCreatPropList &plist)