|
1 | | -*Note:* In preparation of `v3` of HighFive, we've started merging breaking |
2 | | -changes into the main branch. More information and opportunity to comment can |
3 | | -be found at: |
4 | | -https://github.com/BlueBrain/HighFive/issues/864 |
| 1 | +> [!WARNING] |
| 2 | +> The Blue Brain Project concluded in December 2024, so the HighFive development is ceased under the BlueBrain GitHub organization. |
| 3 | +> |
| 4 | +> The development of HighFive will continue at: |
| 5 | +> https://github.com/highfive-devs/highfive |
5 | 6 |
|
6 | 7 | # HighFive - HDF5 header-only C++ Library |
7 | 8 |
|
8 | | -[](https://BlueBrain.github.io/HighFive/actions/workflows/gh-pages.yml?query=branch%3Amaster) |
9 | | -[](https://codecov.io/gh/BlueBrain/HighFive) |
10 | | -[](https://github.com/BlueBrain/HighFive-testing/actions/workflows/integration.yml) |
11 | | -[](https://zenodo.org/doi/10.5281/zenodo.10679422) |
12 | | - |
13 | 9 | Documentation: https://bluebrain.github.io/HighFive/ |
14 | 10 |
|
15 | 11 | ## Brief |
@@ -47,237 +43,49 @@ It integrates nicely with other CMake projects by defining (and exporting) a Hig |
47 | 43 | - xtensor (optional) |
48 | 44 | - half (optional) |
49 | 45 |
|
50 | | -### Versioning & Code Stability |
51 | | -We use semantic versioning. Currently, we're preparing `v3` which contains a |
52 | | -limited set of breaking changes required to eliminate undesireable behaviour or |
53 | | -modernize outdated patterns. We provide a |
54 | | -[Migration Guide](https://bluebrain.github.io/HighFive/md__2home_2runner_2work_2_high_five_2_high_five_2doc_2migration__guide.html), |
55 | | -please report any missing or incorrect information to help others make the |
56 | | -switch more easily. |
57 | | - |
58 | | -- `v2.x.y` are stable and any API breaking changes are considered bugs. There's |
59 | | - like not going to be very many releases of the `v2` line once `v3` is stable. |
60 | | - |
61 | | -- `v3.0.0-beta?` are pre-releases of `v3.0.0`. We predict that one more |
62 | | - breaking changes might happen: the string handling is confusing to some of the |
63 | | - maintainers and the default encoding is inconsistent (and will likely be made |
64 | | - consistent). |
65 | | - |
66 | | - For codes that either use `std::string` when dealing with strings, or that |
67 | | - don't use strings with HDF5 at all, we don't currently have any additional |
68 | | - breaking changes planned for 3.0.0. |
69 | | - |
| 46 | +The releases for versions 2.x.y and two prereleases of v3 can be found at: |
| 47 | +* https://github.com/BlueBrain/HighFive/releases |
| 48 | +* https://zenodo.org/doi/10.5281/zenodo.10679422 |
70 | 49 |
|
71 | | -### Known flaws |
72 | | -- HighFive is not thread-safe. At best it has the same limitations as the HDF5 library. However, HighFive objects modify their members without protecting these writes. Users have reported that HighFive is not thread-safe even when using the threadsafe HDF5 library, e.g., https://github.com/BlueBrain/HighFive/discussions/675. |
73 | | -- Eigen support in core HighFive was broken until v3.0. See https://github.com/BlueBrain/HighFive/issues/532. H5Easy was not |
74 | | - affected. |
75 | | -- The support of fixed length strings isn't ideal. |
| 50 | +The state of HighFive immediately before preparing it for archival is: |
| 51 | +* https://github.com/BlueBrain/HighFive/tree/v3.0.0-beta2 |
76 | 52 |
|
| 53 | +All future development and new releases can be found at: |
| 54 | +* https://github.com/highfive-devs/highfive |
77 | 55 |
|
78 | | -## Examples |
79 | | - |
80 | | -#### Write a std::vector<int> to 1D HDF5 dataset and read it back |
| 56 | +## Example |
81 | 57 |
|
82 | 58 | ```c++ |
83 | | -#include <highfive/highfive.hpp> |
84 | | - |
85 | 59 | using namespace HighFive; |
86 | 60 |
|
87 | | -std::string filename = "/tmp/new_file.h5"; |
| 61 | +File file("foo.h5", File::Truncate); |
88 | 62 |
|
89 | 63 | { |
90 | | - // We create an empty HDF55 file, by truncating an existing |
91 | | - // file if required: |
92 | | - File file(filename, File::Truncate); |
93 | | - |
94 | 64 | std::vector<int> data(50, 1); |
95 | 65 | file.createDataSet("grp/data", data); |
96 | 66 | } |
97 | 67 |
|
98 | 68 | { |
99 | | - // We open the file as read-only: |
100 | | - File file(filename, File::ReadOnly); |
101 | 69 | auto dataset = file.getDataSet("grp/data"); |
102 | 70 |
|
103 | | - // Read back, with allocating: |
| 71 | + // Read back, automatically allocating: |
104 | 72 | auto data = dataset.read<std::vector<int>>(); |
105 | 73 |
|
106 | | - // Because `data` has the correct size, this will |
107 | | - // not cause `data` to be reallocated: |
| 74 | + // Alternatively, if `data` has the correct |
| 75 | + // size, without reallocation: |
108 | 76 | dataset.read(data); |
109 | 77 | } |
110 | 78 | ``` |
111 | 79 |
|
112 | | -**Note:** As of 2.8.0, one can use `highfive/highfive.hpp` to include |
113 | | -everything HighFive. Prior to 2.8.0 one would include `highfive/H5File.hpp`. |
114 | | - |
115 | | -**Note:** For advanced usecases the dataset can be created without immediately |
116 | | -writing to it. This is common in MPI-IO related patterns, or when growing a |
117 | | -dataset over the course of a simulation. |
118 | | - |
119 | | -#### Write a 2 dimensional C double float array to a 2D HDF5 dataset |
120 | | - |
121 | | -See [create_dataset_double.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/create_dataset_double.cpp) |
122 | | - |
123 | | -#### Write and read a matrix of double float (boost::ublas) to a 2D HDF5 dataset |
124 | | - |
125 | | -See [boost_ublas_double.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/boost_ublas_double.cpp) |
126 | | - |
127 | | -#### Write and read a subset of a 2D double dataset |
128 | | - |
129 | | -See [select_partial_dataset_cpp11.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/select_partial_dataset_cpp11.cpp) |
130 | | - |
131 | | -#### Create, write and list HDF5 attributes |
132 | | - |
133 | | -See [create_attribute_string_integer.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/create_attribute_string_integer.cpp) |
134 | | - |
135 | | -#### And others |
136 | | - |
137 | | -See [src/examples/](https://github.com/BlueBrain/HighFive/blob/master/src/examples/) subdirectory for more info. |
138 | | - |
139 | | - |
140 | | -### H5Easy |
141 | | - |
142 | | -For several 'standard' use cases the [highfive/H5Easy.hpp](include/highfive/H5Easy.hpp) interface is available. It allows: |
143 | | - |
144 | | -* Reading/writing in a single line of: |
145 | | - |
146 | | - - scalars (to/from an extendible DataSet), |
147 | | - - strings, |
148 | | - - vectors (of standard types), |
149 | | - - [Eigen::Matrix](http://eigen.tuxfamily.org) (optional), |
150 | | - - [xt::xarray](https://github.com/QuantStack/xtensor) and [xt::xtensor](https://github.com/QuantStack/xtensor) |
151 | | - (optional). |
152 | | - - [cv::Mat_](https://docs.opencv.org/master/df/dfc/classcv_1_1Mat__.html) |
153 | | - (optional). |
154 | | - |
155 | | -* Getting in a single line: |
156 | | - |
157 | | - - the size of a DataSet, |
158 | | - - the shape of a DataSet. |
159 | | - |
160 | | -#### Example |
161 | | - |
162 | | -```cpp |
163 | | -#include <highfive/H5Easy.hpp> |
164 | | - |
165 | | -int main() { |
166 | | - H5Easy::File file("example.h5", H5Easy::File::Overwrite); |
167 | | - |
168 | | - int A = ...; |
169 | | - H5Easy::dump(file, "/path/to/A", A); |
170 | | - |
171 | | - A = H5Easy::load<int>(file, "/path/to/A"); |
172 | | -} |
173 | | -``` |
174 | | - |
175 | | -whereby the `int` type of this example can be replaced by any of the above |
176 | | -types. See [easy_load_dump.cpp](src/examples/easy_load_dump.cpp) for more |
177 | | -details. |
178 | | - |
179 | | -**Note:** Classes such as `H5Easy::File` are just short for the regular |
180 | | -`HighFive` classes (in this case `HighFive::File`). They can thus be used |
181 | | -interchangeably. |
182 | | - |
183 | | - |
184 | | -## CMake integration |
185 | | -There's two common paths of integrating HighFive into a CMake based project. |
186 | | -The first is to "vendor" HighFive, the second is to install HighFive as a |
187 | | -normal C++ library. Since HighFive makes choices about how to integrate HDF5, |
188 | | -sometimes following the third Bailout Approach is needed. |
189 | | - |
190 | | -Regular HDF5 CMake variables can be used. Interesting variables include: |
191 | | - |
192 | | -* `HDF5_USE_STATIC_LIBRARIES` to link statically against the HDF5 library. |
193 | | -* `HDF5_PREFER_PARALLEL` to prefer pHDF5. |
194 | | -* `HDF5_IS_PARALLEL` to check if HDF5 is parallel. |
195 | | - |
196 | | -Please consult `tests/cmake_integration` for examples of how to write libraries |
197 | | -or applications using HighFive. |
198 | | - |
199 | | -### Vendoring HighFive |
200 | | - |
201 | | -In this approach the HighFive sources are included in a subdirectory of the |
202 | | -project (typically as a git submodule), for example in `third_party/HighFive`. |
203 | | - |
204 | | -The projects `CMakeLists.txt` add the following lines |
205 | | -```cmake |
206 | | -add_subdirectory(third_party/HighFive) |
207 | | -target_link_libraries(foo HighFive) |
208 | | -``` |
209 | | - |
210 | | -**Note:** `add_subdirectory(third_party/HighFive)` will search and "link" HDF5 |
211 | | -but wont search or link any optional dependencies such as Boost. |
212 | | - |
213 | | -### Regular Installation of HighFive |
214 | | - |
215 | | -Alternatively, HighFive can be install and "found" like regular software. |
216 | | - |
217 | | -The project's `CMakeLists.txt` should add the following: |
218 | | -```cmake |
219 | | -find_package(HighFive REQUIRED) |
220 | | -target_link_libraries(foo HighFive) |
221 | | -``` |
222 | | - |
223 | | -**Note:** `find_package(HighFive)` will search for HDF5. "Linking" to |
224 | | -`HighFive` includes linking with HDF5. The two commands will not search for or |
225 | | -"link" to optional dependencies such as Boost. |
226 | | - |
227 | | -### Bailout Approach |
228 | | - |
229 | | -To prevent HighFive from searching or "linking" to HDF5 the project's |
230 | | -`CMakeLists.txt` should contain the following: |
231 | | - |
232 | | -```cmake |
233 | | -# Prevent HighFive CMake code from searching for HDF5: |
234 | | -set(HIGHFIVE_FIND_HDF5 Off) |
235 | | -
|
236 | | -# Then "find" HighFive as usual: |
237 | | -find_package(HighFive REQUIRED) |
238 | | -# alternatively, when vendoring: |
239 | | -# add_subdirectory(third_party/HighFive) |
240 | | -
|
241 | | -# Finally, use the target `HighFive::Include` which |
242 | | -# doesn't add a dependency on HDF5. |
243 | | -target_link_libraries(foo HighFive::Include) |
244 | | -
|
245 | | -# Proceed to find and link HDF5 as required. |
246 | | -``` |
247 | | - |
248 | | -### Optional Dependencies |
249 | | - |
250 | | -HighFive does not attempt to find or "link" to any optional dependencies, such |
251 | | -as Boost, Eigen, etc. Any project using HighFive with any of the optional |
252 | | -dependencies must include the respective header: |
253 | | -``` |
254 | | -#include <highfive/boost.hpp> |
255 | | -#include <highfive/eigen.hpp> |
256 | | -``` |
257 | | -and add the required CMake code to find and link against the dependencies. For |
258 | | -Boost the required lines might be |
259 | | -``` |
260 | | -find_package(Boost REQUIRED) |
261 | | -target_link_libraries(foo PUBLIC Boost::headers) |
262 | | -``` |
263 | | - |
264 | | -# Questions? |
265 | | - |
266 | | -Do you have questions on how to use HighFive? Would you like to share an interesting example or |
267 | | -discuss HighFive features? Head over to the [Discussions](https://github.com/BlueBrain/HighFive/discussions) |
268 | | -forum and join the community. |
269 | | - |
270 | | -For bugs and issues please use [Issues](https://github.com/BlueBrain/HighFive/issues). |
271 | | - |
272 | 80 | # Funding & Acknowledgment |
273 | | - |
| 81 | +
|
274 | 82 | The development of this software was supported by funding to the Blue Brain Project, a research center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss government's ETH Board of the Swiss Federal Institutes of Technology. |
275 | 83 |
|
276 | 84 | HighFive releases are uploaded to Zenodo. If you wish to cite HighFive in a |
277 | 85 | scientific publication you can use the DOIs for the |
278 | 86 | [Zenodo records](https://zenodo.org/doi/10.5281/zenodo.10679422). |
279 | | - |
280 | | -Copyright © 2015-2022 Blue Brain Project/EPFL |
| 87 | +
|
| 88 | +Copyright © 2015-2024 Blue Brain Project/EPFL |
281 | 89 |
|
282 | 90 |
|
283 | 91 | ### License |
|
0 commit comments