bijective-gamut 2.3.1__tar.gz → 2.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/CHANGELOG.md +28 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/CITATION.cff +1 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/CMakeLists.txt +1 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/PKG-INFO +3 -3
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/README.md +2 -2
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/include/gamut/gamut.h +7 -2
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/pyproject.toml +1 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/Cargo.toml +1 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut/Cargo.toml +1 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut/src/lib.rs +1 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/capi.cpp +1 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/h5.cpp +95 -18
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/h5.hpp +28 -4
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/writer.cpp +61 -7
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/writer.hpp +15 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/tests/writer_reader_tests.cpp +250 -1
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/.gitignore +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/CONTRIBUTING.md +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/LICENSE +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/SPEC.md +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/00_readme.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/01_run_table.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/02_one_mesh.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/03_geometry_family.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/04_changing_mesh.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/05_time_series.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/06_uncertainty_gradients.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/07_models.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/08_selecting_parts.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/09_combining_files.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/10_vtk.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/README.md +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/_cylinder.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/c/one_mesh.c +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cli/second_entry.json +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cli/second_entry_runs.csv +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cli/sweep.json +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cli/sweep_runs.csv +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/combining.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/cylinder.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/family.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/nearest.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/one_mesh.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/parts.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/refinement.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/run_table.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/sweep.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/transient.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/cpp/uncertain.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/combining.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/cylinder.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/family.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/nearest.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/one_mesh.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/parts.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/refinement.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/run_table.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/sweep.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/transient.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/examples/rust/uncertain.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/exports.map +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/exports.txt +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/include/gamut/gamut.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/licenses/hdf5.txt +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/licenses/zlib.txt +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/llms.txt +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/mkdocs.yml +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/overrides/partials/logo.html +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/__init__.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/__main__.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/_files.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/_lib.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/_models.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/_notice.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/_study.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/_units.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/_validate.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/cli.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/gamut/vtk.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/_pages.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_append_many.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_append_sessions.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_arrays.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_binding.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_cli.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_docs.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_edges.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_examples.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_existing_destinations.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_files.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_guide_cli.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_guide_languages.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_layouts.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_models.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_readme.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_validate.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/python/tests/test_vtk.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/.gitignore +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut/build.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut/tests/corpus.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut/tests/study.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut-sys/Cargo.toml +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut-sys/build.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut-sys/generate.py +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/rust/gamut-sys/src/lib.rs +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/chunk.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/chunk.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/chunks.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/codec.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/codec.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/copy.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/copy.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/evaluate.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/evaluate.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/names.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/names.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/nearest.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/nearest.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/notice.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/notice.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/reader.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/reader.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/schema.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/schema.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/select.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/select.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/session.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/session.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/sha256.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/sha256.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/types.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/types.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/units.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/units.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/validate.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/validate.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/value.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/src/value.hpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/tests/header_tests.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/tests/unit_tests.cpp +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/tools/build_core.sh +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/tools/build_deps.sh +0 -0
- {bijective_gamut-2.3.1 → bijective_gamut-2.3.2}/tools/damaged_files.py +0 -0
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.2 (2026-11-26)
|
|
4
|
+
|
|
5
|
+
The file format (`gamut/1`) and the C interface are unchanged.
|
|
6
|
+
|
|
7
|
+
- A write that the disk has no room for no longer crashes the process
|
|
8
|
+
(#175). `close()` raised its error and the process then died with SIGSEGV
|
|
9
|
+
while the file's HDF5 ids were released. Each id is now closed with the
|
|
10
|
+
close call of its type. When HDF5 cannot close a dataset or flush or
|
|
11
|
+
close the file, adding runs, flushing and closing stop with "cannot write
|
|
12
|
+
the file (no space left on the device?)" and say what became of it: a new
|
|
13
|
+
file is removed, and a file being appended to is unchanged, with the copy
|
|
14
|
+
the runs were written to removed. The writer lets go of the file at
|
|
15
|
+
that point, and every later call on it repeats the error. HDF5 does not
|
|
16
|
+
free a file whose last close failed: the metadata its cache held then
|
|
17
|
+
stays allocated until the process ends, once for each file that fails
|
|
18
|
+
this way. That is about 0.7 MB for a small file and more for a file
|
|
19
|
+
with many objects; HDF5's cache holds up to 32 MB by default.
|
|
20
|
+
- A new file that cannot be written at all (a disk with nothing free) is
|
|
21
|
+
reported as that, with the system's reason or "no space left on the
|
|
22
|
+
device?", and no empty file is left at its path. It was reported as "an
|
|
23
|
+
existing file is never replaced", and the empty file left behind made the
|
|
24
|
+
same create fail again once there was room.
|
|
25
|
+
- A new file that is given up, by `abandon` or because it could not be
|
|
26
|
+
written, is removed at the path it was created at. A file created by a
|
|
27
|
+
relative name was removed relative to the program's current folder at
|
|
28
|
+
that later moment, which could remove another file of the same name. The
|
|
29
|
+
error says so when the file could not be removed.
|
|
30
|
+
|
|
3
31
|
## 2.3.1 (2026-11-26)
|
|
4
32
|
|
|
5
33
|
The file format (`gamut/1`) and the C interface are unchanged.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
cmake_minimum_required(VERSION 3.16)
|
|
2
|
-
project(gamut VERSION 2.3.
|
|
2
|
+
project(gamut VERSION 2.3.2 LANGUAGES C CXX)
|
|
3
3
|
|
|
4
4
|
# The shared core of spec version 1: one C++ library behind a plain C
|
|
5
5
|
# interface (include/gamut/gamut.h). Python, MATLAB and Julia bind to
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bijective-gamut
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.2
|
|
4
4
|
Summary: Gamut by Bijective Systems: an open file format for parametric simulation studies and fitted models
|
|
5
5
|
Keywords: simulation,parametric study,design of experiments,CFD,FEA,HDF5,netCDF,xarray,surrogate model,reduced-order model,machine learning,dataset,MATLAB,Julia
|
|
6
6
|
Author: Bijective Systems
|
|
@@ -146,9 +146,9 @@ another approach is faster.
|
|
|
146
146
|
|---|---|
|
|
147
147
|
| Python 3.11 or later | `pip install bijective-gamut` |
|
|
148
148
|
| MATLAB R2023b or later | open `Gamut.mltbx` from the [latest release](https://github.com/bijective-systems-org/gamut/releases/latest) |
|
|
149
|
-
| Julia 1.10 or later | `Pkg.add(url="https://github.com/bijective-systems-org/gamut", subdir="julia", rev="v2.3.
|
|
149
|
+
| Julia 1.10 or later | `Pkg.add(url="https://github.com/bijective-systems-org/gamut", subdir="julia", rev="v2.3.2")` |
|
|
150
150
|
| C++ and C | CMake build and install, then `find_package(gamut)`; include `gamut/gamut.hpp` (C++17) or `gamut/gamut.h` (C) |
|
|
151
|
-
| Rust 1.70 or later | `bijective-gamut = { git = "https://github.com/bijective-systems-org/gamut", tag = "v2.3.
|
|
151
|
+
| Rust 1.70 or later | `bijective-gamut = { git = "https://github.com/bijective-systems-org/gamut", tag = "v2.3.2" }`, with `GAMUT_LIB_DIR` at a release's core |
|
|
152
152
|
|
|
153
153
|
In Python, install `bijective-gamut`, then `import gamut`; the PyPI project
|
|
154
154
|
named `gamut` is a different package. [Installing](https://bijective-systems-org.github.io/gamut/install.html) has
|
|
@@ -102,9 +102,9 @@ another approach is faster.
|
|
|
102
102
|
|---|---|
|
|
103
103
|
| Python 3.11 or later | `pip install bijective-gamut` |
|
|
104
104
|
| MATLAB R2023b or later | open `Gamut.mltbx` from the [latest release](https://github.com/bijective-systems-org/gamut/releases/latest) |
|
|
105
|
-
| Julia 1.10 or later | `Pkg.add(url="https://github.com/bijective-systems-org/gamut", subdir="julia", rev="v2.3.
|
|
105
|
+
| Julia 1.10 or later | `Pkg.add(url="https://github.com/bijective-systems-org/gamut", subdir="julia", rev="v2.3.2")` |
|
|
106
106
|
| C++ and C | CMake build and install, then `find_package(gamut)`; include `gamut/gamut.hpp` (C++17) or `gamut/gamut.h` (C) |
|
|
107
|
-
| Rust 1.70 or later | `bijective-gamut = { git = "https://github.com/bijective-systems-org/gamut", tag = "v2.3.
|
|
107
|
+
| Rust 1.70 or later | `bijective-gamut = { git = "https://github.com/bijective-systems-org/gamut", tag = "v2.3.2" }`, with `GAMUT_LIB_DIR` at a release's core |
|
|
108
108
|
|
|
109
109
|
In Python, install `bijective-gamut`, then `import gamut`; the PyPI project
|
|
110
110
|
named `gamut` is a different package. [Installing](https://bijective-systems-org.github.io/gamut/install.html) has
|
|
@@ -63,7 +63,7 @@ typedef struct {
|
|
|
63
63
|
int64_t count;
|
|
64
64
|
} gamut_sel;
|
|
65
65
|
|
|
66
|
-
/* The library's version ("2.3.
|
|
66
|
+
/* The library's version ("2.3.2") and the format string it writes
|
|
67
67
|
* ("gamut/1"). Static strings; never freed. */
|
|
68
68
|
GAMUT_API const char* gamut_version(void);
|
|
69
69
|
GAMUT_API const char* gamut_format(void);
|
|
@@ -182,7 +182,12 @@ GAMUT_API int gamut_set_private(gamut_file* f, const char* name, const void* byt
|
|
|
182
182
|
/* Closes a file opened by any call and frees the handle; writes what a
|
|
183
183
|
* writer holds. f may be NULL. When a writer's close is refused (a model
|
|
184
184
|
* file without a model, a shared mesh never set) the handle stays open:
|
|
185
|
-
* fix what the error names and close again, or gamut_abandon.
|
|
185
|
+
* fix what the error names and close again, or gamut_abandon. When the
|
|
186
|
+
* file cannot be written out (no space left on the device), adding rows,
|
|
187
|
+
* flushing and closing fail and the file is given up: a new file is
|
|
188
|
+
* removed at the path it was created at (the error says so if it could
|
|
189
|
+
* not be), a file being appended to is unchanged. The handle is then
|
|
190
|
+
* good only for gamut_abandon. */
|
|
186
191
|
GAMUT_API int gamut_close(gamut_file* f, gamut_error* err);
|
|
187
192
|
/* Gives up on a file and frees the handle without finishing it: nothing
|
|
188
193
|
* more is written. remove_file (non-zero) deletes a file this handle
|
|
@@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bijective-gamut"
|
|
7
|
-
version = "2.3.
|
|
7
|
+
version = "2.3.2"
|
|
8
8
|
description = "Gamut by Bijective Systems: an open file format for parametric simulation studies and fitted models"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -12,7 +12,7 @@ build = "build.rs"
|
|
|
12
12
|
name = "gamut"
|
|
13
13
|
|
|
14
14
|
[dependencies]
|
|
15
|
-
gamut-sys = { package = "bijective-gamut-sys", path = "../gamut-sys", version = "=2.3.
|
|
15
|
+
gamut-sys = { package = "bijective-gamut-sys", path = "../gamut-sys", version = "=2.3.2" }
|
|
16
16
|
|
|
17
17
|
# The examples of the documentation, one program per page.
|
|
18
18
|
[[example]]
|
|
@@ -1329,7 +1329,7 @@ pub fn evaluate(model_path: &str, inputs: &[(&str, Column)], path: &str) -> Resu
|
|
|
1329
1329
|
Ok((open(path)?, warnings.take()))
|
|
1330
1330
|
}
|
|
1331
1331
|
|
|
1332
|
-
/// The library's version ("2.3.
|
|
1332
|
+
/// The library's version ("2.3.2").
|
|
1333
1333
|
pub fn version() -> String {
|
|
1334
1334
|
unsafe { CStr::from_ptr(sys::gamut_version()) }.to_string_lossy().into_owned()
|
|
1335
1335
|
}
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
#include <hdf5_hl.h>
|
|
4
4
|
|
|
5
|
+
#include <fcntl.h>
|
|
6
|
+
#include <sys/stat.h>
|
|
7
|
+
#if defined(_WIN32)
|
|
8
|
+
#include <io.h>
|
|
9
|
+
#else
|
|
10
|
+
#include <unistd.h>
|
|
11
|
+
#endif
|
|
12
|
+
|
|
5
13
|
#include <algorithm>
|
|
14
|
+
#include <cerrno>
|
|
6
15
|
#include <cstdio>
|
|
7
16
|
#include <cstring>
|
|
8
17
|
#include <filesystem>
|
|
@@ -51,8 +60,8 @@ std::string parent_of(const std::string& path) {
|
|
|
51
60
|
return path.substr(0, at);
|
|
52
61
|
}
|
|
53
62
|
|
|
54
|
-
Id open_object(hid_t file, const std::string& path) {
|
|
55
|
-
Id id(H5Oopen(file, path.c_str(), H5P_DEFAULT));
|
|
63
|
+
Id open_object(hid_t file, const std::string& path, bool* failed) {
|
|
64
|
+
Id id(H5Oopen(file, path.c_str(), H5P_DEFAULT), failed);
|
|
56
65
|
need(id.valid(), "cannot open \"" + path + "\"");
|
|
57
66
|
return id;
|
|
58
67
|
}
|
|
@@ -252,11 +261,36 @@ std::size_t checked_product(const std::string& path,
|
|
|
252
261
|
return n;
|
|
253
262
|
}
|
|
254
263
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
264
|
+
// Each type's own close call, because H5Idec_ref keeps an id whose close
|
|
265
|
+
// failed in HDF5's table although the object behind it is freed, and HDF5
|
|
266
|
+
// reads that object the next time it walks its open ids. H5Dclose removes
|
|
267
|
+
// the id whether or not the close succeeds.
|
|
268
|
+
bool Id::close() {
|
|
269
|
+
if (id_ < 0) return true;
|
|
270
|
+
herr_t status;
|
|
271
|
+
switch (H5Iget_type(id_)) {
|
|
272
|
+
case H5I_FILE: status = H5Fclose(id_); break;
|
|
273
|
+
case H5I_GROUP: status = H5Gclose(id_); break;
|
|
274
|
+
case H5I_DATATYPE: status = H5Tclose(id_); break;
|
|
275
|
+
case H5I_DATASPACE: status = H5Sclose(id_); break;
|
|
276
|
+
case H5I_DATASET: status = H5Dclose(id_); break;
|
|
277
|
+
case H5I_ATTR: status = H5Aclose(id_); break;
|
|
278
|
+
case H5I_GENPROP_LST: status = H5Pclose(id_); break;
|
|
279
|
+
default: status = H5Idec_ref(id_) < 0 ? -1 : 0; break;
|
|
280
|
+
}
|
|
281
|
+
id_ = H5I_INVALID_HID;
|
|
282
|
+
if (status < 0 && failed_ != nullptr) *failed_ = true;
|
|
283
|
+
return status >= 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
std::string removed(const std::string& path) {
|
|
287
|
+
std::error_code ec;
|
|
288
|
+
const std::filesystem::path file = std::filesystem::u8path(path);
|
|
289
|
+
std::filesystem::remove(file, ec);
|
|
290
|
+
if (!ec && !std::filesystem::exists(file, ec) && !ec) {
|
|
291
|
+
return "the incomplete \"" + path + "\" was removed";
|
|
259
292
|
}
|
|
293
|
+
return "the incomplete \"" + path + "\" could not be removed and is still there";
|
|
260
294
|
}
|
|
261
295
|
|
|
262
296
|
const char* link_kind_name(LinkKind kind) {
|
|
@@ -384,6 +418,31 @@ std::string cannot_open(const std::string& path, const std::string& as) {
|
|
|
384
418
|
return "cannot open \"" + path + "\" " + as;
|
|
385
419
|
}
|
|
386
420
|
|
|
421
|
+
// Creates an empty file at `path`, which must not exist: the one step that
|
|
422
|
+
// tells an existing file from a file that cannot be made. HDF5 reports both
|
|
423
|
+
// as a failed create, and leaves an empty file behind when it could make
|
|
424
|
+
// the file and not write to it.
|
|
425
|
+
void create_exclusively(const std::string& path) {
|
|
426
|
+
#if defined(_WIN32)
|
|
427
|
+
const int fd = ::_wopen(std::filesystem::u8path(path).wstring().c_str(),
|
|
428
|
+
_O_WRONLY | _O_CREAT | _O_EXCL | _O_BINARY, _S_IREAD | _S_IWRITE);
|
|
429
|
+
#else
|
|
430
|
+
const int fd = ::open(path.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0666);
|
|
431
|
+
#endif
|
|
432
|
+
if (fd < 0) {
|
|
433
|
+
if (errno == EEXIST) {
|
|
434
|
+
throw Error("", "cannot create new file \"" + path +
|
|
435
|
+
"\"; an existing file is never replaced");
|
|
436
|
+
}
|
|
437
|
+
throw Error("", "cannot create new file \"" + path + "\": " + std::strerror(errno));
|
|
438
|
+
}
|
|
439
|
+
#if defined(_WIN32)
|
|
440
|
+
::_close(fd);
|
|
441
|
+
#else
|
|
442
|
+
::close(fd);
|
|
443
|
+
#endif
|
|
444
|
+
}
|
|
445
|
+
|
|
387
446
|
} // namespace
|
|
388
447
|
|
|
389
448
|
File File::open_read(const std::string& path) {
|
|
@@ -422,13 +481,30 @@ File File::create(const std::string& path) {
|
|
|
422
481
|
Id fapl(H5Pcreate(H5P_FILE_ACCESS));
|
|
423
482
|
need(H5Pset_libver_bounds(fapl.get(), H5F_LIBVER_EARLIEST, H5F_LIBVER_V110) >= 0,
|
|
424
483
|
"cannot set the library version bounds");
|
|
425
|
-
|
|
426
|
-
|
|
484
|
+
create_exclusively(path);
|
|
485
|
+
// HDF5 then writes into the file made here.
|
|
486
|
+
f.id_ = Id(H5Fcreate(path.c_str(), H5F_ACC_TRUNC, fcpl.get(), fapl.get()));
|
|
487
|
+
if (!f.id_.valid()) {
|
|
488
|
+
throw Error("", "cannot write the new file \"" + path +
|
|
489
|
+
"\" (no space left on the device?); " + removed(path));
|
|
490
|
+
}
|
|
427
491
|
return f;
|
|
428
492
|
}
|
|
429
493
|
|
|
494
|
+
void File::need_not_failed() const {
|
|
495
|
+
need(!failed_, "an earlier write to the file failed");
|
|
496
|
+
}
|
|
497
|
+
|
|
430
498
|
void File::flush() {
|
|
431
|
-
|
|
499
|
+
need_not_failed();
|
|
500
|
+
failed_ = H5Fflush(id_.get(), H5F_SCOPE_GLOBAL) < 0;
|
|
501
|
+
need(!failed_, "cannot flush the file");
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
void File::close() {
|
|
505
|
+
need_not_failed();
|
|
506
|
+
failed_ = !id_.close();
|
|
507
|
+
need(!failed_, "cannot close the file");
|
|
432
508
|
}
|
|
433
509
|
|
|
434
510
|
LinkKind File::link_kind(const std::string& path) const {
|
|
@@ -562,7 +638,7 @@ std::vector<RawAttr> attributes_of(hid_t object_id) {
|
|
|
562
638
|
|
|
563
639
|
std::vector<RawAttr> File::attributes(const std::string& path) const {
|
|
564
640
|
if (link_kind(path) != LinkKind::Hard) return {};
|
|
565
|
-
return attributes_of(open_object(id_.get(), path).get());
|
|
641
|
+
return attributes_of(open_object(id_.get(), path, &failed_).get());
|
|
566
642
|
}
|
|
567
643
|
|
|
568
644
|
|
|
@@ -585,7 +661,7 @@ DsetInfo& with_shape(hid_t dset, DsetInfo& info) {
|
|
|
585
661
|
} // namespace
|
|
586
662
|
|
|
587
663
|
Id File::open_dataset(const std::string& path) const {
|
|
588
|
-
Id dset(H5Dopen2(id_.get(), path.c_str(), H5P_DEFAULT));
|
|
664
|
+
Id dset(H5Dopen2(id_.get(), path.c_str(), H5P_DEFAULT), &failed_);
|
|
589
665
|
need(dset.valid(), "cannot open \"" + path + "\"");
|
|
590
666
|
// How a dataset stores its values is fixed when it is created, so each
|
|
591
667
|
// is checked once per open file.
|
|
@@ -598,7 +674,7 @@ Id File::open_dataset(const std::string& path) const {
|
|
|
598
674
|
}
|
|
599
675
|
|
|
600
676
|
std::string File::stored_outside(const std::string& path) const {
|
|
601
|
-
Id dset(H5Dopen2(id_.get(), path.c_str(), H5P_DEFAULT));
|
|
677
|
+
Id dset(H5Dopen2(id_.get(), path.c_str(), H5P_DEFAULT), &failed_);
|
|
602
678
|
need(dset.valid(), "cannot open \"" + path + "\"");
|
|
603
679
|
return outside_storage(dset.get(), path);
|
|
604
680
|
}
|
|
@@ -613,7 +689,7 @@ DsetInfo File::dataset_shape(const std::string& path) const {
|
|
|
613
689
|
|
|
614
690
|
std::pair<std::vector<RawAttr>, DsetInfo> File::inspect(const std::string& path) const {
|
|
615
691
|
if (link_kind(path) != LinkKind::Hard) return {};
|
|
616
|
-
Id object = open_object(id_.get(), path);
|
|
692
|
+
Id object = open_object(id_.get(), path, &failed_);
|
|
617
693
|
DsetInfo info;
|
|
618
694
|
if (H5Iget_type(object.get()) == H5I_DATASET) {
|
|
619
695
|
const std::string outside = outside_storage(object.get(), path);
|
|
@@ -1025,7 +1101,7 @@ void File::make_group(const std::string& path) {
|
|
|
1025
1101
|
void File::write_raw_string_attr(const std::string& path,
|
|
1026
1102
|
const std::string& name,
|
|
1027
1103
|
const std::string& bytes) {
|
|
1028
|
-
Id object = open_object(id_.get(), path);
|
|
1104
|
+
Id object = open_object(id_.get(), path, &failed_);
|
|
1029
1105
|
const std::size_t size = bytes.empty() ? 1 : bytes.size();
|
|
1030
1106
|
Id type = string_type(size);
|
|
1031
1107
|
Id space(H5Screate(H5S_SCALAR));
|
|
@@ -1044,7 +1120,7 @@ void File::write_attr(const std::string& path, const std::string& name,
|
|
|
1044
1120
|
write_raw_string_attr(path, name, value.as_text());
|
|
1045
1121
|
return;
|
|
1046
1122
|
}
|
|
1047
|
-
Id object = open_object(id_.get(), path);
|
|
1123
|
+
Id object = open_object(id_.get(), path, &failed_);
|
|
1048
1124
|
Id space(H5Screate(H5S_SCALAR));
|
|
1049
1125
|
hid_t ftype = H5T_STD_I64LE;
|
|
1050
1126
|
hid_t mtype = H5T_NATIVE_INT64;
|
|
@@ -1079,7 +1155,7 @@ void File::write_attr(const std::string& path, const std::string& name,
|
|
|
1079
1155
|
|
|
1080
1156
|
void File::replace_attr(const std::string& path, const std::string& name,
|
|
1081
1157
|
const AttrValue& value) {
|
|
1082
|
-
Id object = open_object(id_.get(), path);
|
|
1158
|
+
Id object = open_object(id_.get(), path, &failed_);
|
|
1083
1159
|
const htri_t exists = H5Aexists(object.get(), name.c_str());
|
|
1084
1160
|
need(exists >= 0, "cannot inspect the attribute \"" + name + "\"");
|
|
1085
1161
|
if (exists == 0) {
|
|
@@ -1230,7 +1306,7 @@ void File::create_dataset(const std::string& path, DType dtype,
|
|
|
1230
1306
|
ftype = file_type(dtype);
|
|
1231
1307
|
}
|
|
1232
1308
|
Id dset(H5Dcreate2(id_.get(), path.c_str(), ftype, space.get(), H5P_DEFAULT,
|
|
1233
|
-
dcpl.get(), H5P_DEFAULT));
|
|
1309
|
+
dcpl.get(), H5P_DEFAULT), &failed_);
|
|
1234
1310
|
need(dset.valid(), "cannot create the dataset \"" + path + "\"");
|
|
1235
1311
|
forget(path);
|
|
1236
1312
|
}
|
|
@@ -1320,7 +1396,7 @@ void File::make_scale(const std::string& path, hsize_t length, bool unlimited) {
|
|
|
1320
1396
|
H5Pset_chunk(dcpl.get(), 1, &chunk);
|
|
1321
1397
|
H5Pset_fill_time(dcpl.get(), H5D_FILL_TIME_ALLOC);
|
|
1322
1398
|
Id dset(H5Dcreate2(id_.get(), path.c_str(), H5T_IEEE_F32BE, space.get(),
|
|
1323
|
-
H5P_DEFAULT, dcpl.get(), H5P_DEFAULT));
|
|
1399
|
+
H5P_DEFAULT, dcpl.get(), H5P_DEFAULT), &failed_);
|
|
1324
1400
|
need(dset.valid(), "cannot create the dimension scale \"" + path + "\"");
|
|
1325
1401
|
forget(path);
|
|
1326
1402
|
const std::string name = scale_name_attribute(length);
|
|
@@ -1457,6 +1533,7 @@ void File::forget(const std::string& path) {
|
|
|
1457
1533
|
}
|
|
1458
1534
|
|
|
1459
1535
|
void File::remove_link(const std::string& path) {
|
|
1536
|
+
need_not_failed();
|
|
1460
1537
|
need(H5Ldelete(id_.get(), path.c_str(), H5P_DEFAULT) >= 0,
|
|
1461
1538
|
"cannot remove \"" + path + "\"");
|
|
1462
1539
|
object_index_built_ = false;
|
|
@@ -27,18 +27,22 @@ namespace internal {
|
|
|
27
27
|
// Turns off HDF5's printing of its error stack on the calling thread.
|
|
28
28
|
void quiet_hdf5();
|
|
29
29
|
|
|
30
|
-
// An HDF5 identifier that closes itself.
|
|
30
|
+
// An HDF5 identifier that closes itself. A close can fail: closing a
|
|
31
|
+
// dataset writes the chunks HDF5 still holds for it, which a full disk
|
|
32
|
+
// refuses. `failed`, when given, is set to true if this id's close fails;
|
|
33
|
+
// it must outlive the id.
|
|
31
34
|
class Id {
|
|
32
35
|
public:
|
|
33
36
|
Id() : id_(H5I_INVALID_HID) {}
|
|
34
|
-
explicit Id(hid_t id) : id_(id) {}
|
|
37
|
+
explicit Id(hid_t id, bool* failed = nullptr) : id_(id), failed_(failed) {}
|
|
35
38
|
Id(const Id&) = delete;
|
|
36
39
|
Id& operator=(const Id&) = delete;
|
|
37
|
-
Id(Id&& o) noexcept : id_(o.id_) { o.id_ = H5I_INVALID_HID; }
|
|
40
|
+
Id(Id&& o) noexcept : id_(o.id_), failed_(o.failed_) { o.id_ = H5I_INVALID_HID; }
|
|
38
41
|
Id& operator=(Id&& o) noexcept {
|
|
39
42
|
if (this != &o) {
|
|
40
43
|
close();
|
|
41
44
|
id_ = o.id_;
|
|
45
|
+
failed_ = o.failed_;
|
|
42
46
|
o.id_ = H5I_INVALID_HID;
|
|
43
47
|
}
|
|
44
48
|
return *this;
|
|
@@ -47,10 +51,13 @@ class Id {
|
|
|
47
51
|
|
|
48
52
|
hid_t get() const { return id_; }
|
|
49
53
|
bool valid() const { return id_ >= 0; }
|
|
50
|
-
|
|
54
|
+
// Releases the id with the close call of its type; false when that call
|
|
55
|
+
// failed. The id is gone either way.
|
|
56
|
+
bool close();
|
|
51
57
|
|
|
52
58
|
private:
|
|
53
59
|
hid_t id_;
|
|
60
|
+
bool* failed_ = nullptr;
|
|
54
61
|
};
|
|
55
62
|
|
|
56
63
|
// Every count and length below comes out of the file, so each one is
|
|
@@ -217,7 +224,18 @@ class File {
|
|
|
217
224
|
static File create(const std::string& path);
|
|
218
225
|
|
|
219
226
|
hid_t get() const { return id_.get(); }
|
|
227
|
+
// Both refuse a file that has failed, and a failure of either makes it one.
|
|
220
228
|
void flush();
|
|
229
|
+
void close();
|
|
230
|
+
// True once HDF5 could not close a dataset or flush or close the file:
|
|
231
|
+
// what the file holds is then unknown and it cannot be finished. It is
|
|
232
|
+
// not flushed and no link is removed from it afterwards (HDF5 walks the
|
|
233
|
+
// open ids in both); all that is left is to release it. HDF5 frees
|
|
234
|
+
// such a file's handle and not its metadata cache, which stays
|
|
235
|
+
// allocated until the process ends: about 0.7 MB for a small file, more
|
|
236
|
+
// for a file with many objects (the cache holds up to 32 MB by default).
|
|
237
|
+
// HDF5 offers no call that frees a cache it could not write out.
|
|
238
|
+
bool failed() const { return failed_; }
|
|
221
239
|
|
|
222
240
|
// The kind of the last link of `path`, stopping at the first link that
|
|
223
241
|
// is not hard, so nothing below a soft or external link is touched.
|
|
@@ -323,13 +341,19 @@ class File {
|
|
|
323
341
|
const std::vector<Selection>& sel, void* out, std::size_t out_bytes) const;
|
|
324
342
|
std::string dataset_path(hid_t object) const;
|
|
325
343
|
|
|
344
|
+
void need_not_failed() const;
|
|
345
|
+
|
|
326
346
|
Id id_;
|
|
347
|
+
mutable bool failed_ = false;
|
|
327
348
|
mutable ChunkStore chunks_;
|
|
328
349
|
mutable std::set<std::string> inside_; // datasets checked to hold their own values
|
|
329
350
|
mutable std::map<std::string, std::string> object_paths_;
|
|
330
351
|
mutable bool object_index_built_ = false;
|
|
331
352
|
};
|
|
332
353
|
|
|
354
|
+
// Removes the file at `path`, one this process created and could not
|
|
355
|
+
// finish, and says what became of it, for the error that reports the write.
|
|
356
|
+
std::string removed(const std::string& path);
|
|
333
357
|
std::string scale_name_attribute(hsize_t length);
|
|
334
358
|
FilterPipeline pipeline_of(const DsetInfo& info);
|
|
335
359
|
Id string_type(std::size_t size);
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include <cstdio>
|
|
8
8
|
#include <cstring>
|
|
9
9
|
#include <ctime>
|
|
10
|
+
#include <filesystem>
|
|
10
11
|
#include <random>
|
|
11
12
|
#include <set>
|
|
12
13
|
|
|
@@ -370,8 +371,10 @@ std::unique_ptr<Writer> Writer::create(const std::string& path,
|
|
|
370
371
|
"a changing mesh changes per run or per group, never fixed");
|
|
371
372
|
}
|
|
372
373
|
std::unique_ptr<Writer> w(new Writer());
|
|
373
|
-
|
|
374
|
-
|
|
374
|
+
// The whole path now: the file made here is the one removed if it cannot
|
|
375
|
+
// be finished, wherever the program's current folder is by then.
|
|
376
|
+
w->path_ = std::filesystem::absolute(std::filesystem::u8path(path)).u8string();
|
|
377
|
+
w->file_.reset(new File(File::create(w->path_)));
|
|
375
378
|
w->created_ = true;
|
|
376
379
|
Schema& s = w->schema_;
|
|
377
380
|
s.kind = "data";
|
|
@@ -492,7 +495,14 @@ std::unique_ptr<Writer> Writer::open_append(const std::string& path) {
|
|
|
492
495
|
const std::vector<std::int64_t> ids = f.read_i64("/row");
|
|
493
496
|
for (const std::int64_t id : ids) w->next_id_ = std::max(w->next_id_, id + 1);
|
|
494
497
|
}
|
|
495
|
-
|
|
498
|
+
const std::string& copy = w->session_->copy();
|
|
499
|
+
try {
|
|
500
|
+
w->file_.reset(new File(File::open_write(copy)));
|
|
501
|
+
} catch (const Error&) {
|
|
502
|
+
// HDF5 writes to a file as it opens it to write.
|
|
503
|
+
throw Error("", "cannot write the copy of \"" + path + "\" that the runs are added to (no "
|
|
504
|
+
"space left on the device?); \"" + path + "\" is unchanged");
|
|
505
|
+
}
|
|
496
506
|
return w;
|
|
497
507
|
}
|
|
498
508
|
|
|
@@ -522,6 +532,7 @@ Writer::~Writer() {
|
|
|
522
532
|
}
|
|
523
533
|
|
|
524
534
|
void Writer::need_open() const {
|
|
535
|
+
need(failure_.empty(), "", failure_);
|
|
525
536
|
need(!closed_, "", "the file is closed");
|
|
526
537
|
need(!finished_, "", "the file is finished and waits to replace the original; close it again");
|
|
527
538
|
}
|
|
@@ -1334,7 +1345,50 @@ void Writer::check_relations() const {
|
|
|
1334
1345
|
}
|
|
1335
1346
|
}
|
|
1336
1347
|
|
|
1348
|
+
void Writer::give_up() {
|
|
1349
|
+
closed_ = true;
|
|
1350
|
+
pending_.clear();
|
|
1351
|
+
file_.reset();
|
|
1352
|
+
session_.reset(); // an append's copy goes and the file stays as it was
|
|
1353
|
+
failure_ = "cannot write the file (no space left on the device?); ";
|
|
1354
|
+
if (created_) {
|
|
1355
|
+
failure_ += removed(path_);
|
|
1356
|
+
} else {
|
|
1357
|
+
failure_ += "\"" + path_ + "\" is unchanged";
|
|
1358
|
+
}
|
|
1359
|
+
throw Error("", failure_);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
template <class Step>
|
|
1363
|
+
std::int64_t Writer::writing(Step step) {
|
|
1364
|
+
need(failure_.empty(), "", failure_);
|
|
1365
|
+
std::int64_t result = 0;
|
|
1366
|
+
try {
|
|
1367
|
+
result = step();
|
|
1368
|
+
} catch (...) {
|
|
1369
|
+
// A failed file's own error names one HDF5 call, and says nothing of
|
|
1370
|
+
// what became of the file.
|
|
1371
|
+
if (file_ && file_->failed()) give_up();
|
|
1372
|
+
throw;
|
|
1373
|
+
}
|
|
1374
|
+
if (file_ && file_->failed()) give_up();
|
|
1375
|
+
return result;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1337
1378
|
std::int64_t Writer::add_runs(const Batch& batch, bool check_only) {
|
|
1379
|
+
return writing([&] { return commit(batch, check_only); });
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
void Writer::flush() {
|
|
1383
|
+
writing([&] { write_pending(); return 0; });
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
void Writer::close() {
|
|
1387
|
+
if (closed_ && failure_.empty()) return;
|
|
1388
|
+
writing([&] { finish(); return 0; });
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
std::int64_t Writer::commit(const Batch& batch, bool check_only) {
|
|
1338
1392
|
need_open();
|
|
1339
1393
|
need(!model_, "E16", "a model file has no runs; evaluate it to get a data file");
|
|
1340
1394
|
// Before the first rows, the declarations are resolved against this batch
|
|
@@ -1897,7 +1951,7 @@ void Writer::add_model(const std::string& id, const std::string& type,
|
|
|
1897
1951
|
schema_.models.push_back(m);
|
|
1898
1952
|
}
|
|
1899
1953
|
|
|
1900
|
-
void Writer::
|
|
1954
|
+
void Writer::write_pending() {
|
|
1901
1955
|
if (closed_ || !file_) return;
|
|
1902
1956
|
File& f = *file_;
|
|
1903
1957
|
for (auto& kv : pending_) {
|
|
@@ -1959,11 +2013,10 @@ void Writer::abandon(bool remove) {
|
|
|
1959
2013
|
pending_.clear();
|
|
1960
2014
|
file_.reset();
|
|
1961
2015
|
session_.reset(); // the copy goes and the file stays as it was
|
|
1962
|
-
if (remove && created_)
|
|
2016
|
+
if (remove && created_) removed(path_);
|
|
1963
2017
|
}
|
|
1964
2018
|
|
|
1965
|
-
void Writer::
|
|
1966
|
-
if (closed_) return;
|
|
2019
|
+
void Writer::finish() {
|
|
1967
2020
|
if (finished_) { // a rename that failed before: tried again
|
|
1968
2021
|
const std::string note = session_->publish();
|
|
1969
2022
|
session_.reset();
|
|
@@ -1999,6 +2052,7 @@ void Writer::close() {
|
|
|
1999
2052
|
flush();
|
|
2000
2053
|
write_cf_coordinates();
|
|
2001
2054
|
file_->flush();
|
|
2055
|
+
file_->close();
|
|
2002
2056
|
file_.reset();
|
|
2003
2057
|
std::string note;
|
|
2004
2058
|
if (session_) {
|
|
@@ -143,6 +143,12 @@ class Writer {
|
|
|
143
143
|
|
|
144
144
|
// Writes every staged partial chunk. Reading through the same handle
|
|
145
145
|
// flushes first. When appending, the runs reach the file on close.
|
|
146
|
+
//
|
|
147
|
+
// add_runs, flush and close write to the disk. When one of them finds
|
|
148
|
+
// that HDF5 could not write the file out (a full disk is the usual
|
|
149
|
+
// reason), the file cannot be finished: the writer releases it, removes
|
|
150
|
+
// the new file or the copy an append was writing, and the error says
|
|
151
|
+
// which. Every later call but abandon repeats that error.
|
|
146
152
|
void flush();
|
|
147
153
|
void close();
|
|
148
154
|
// A fingerprint of a geometry as it would be stored: points at the
|
|
@@ -162,6 +168,14 @@ class Writer {
|
|
|
162
168
|
std::int64_t on_disk);
|
|
163
169
|
|
|
164
170
|
void need_open() const;
|
|
171
|
+
std::int64_t commit(const Batch& batch, bool check_only);
|
|
172
|
+
void write_pending();
|
|
173
|
+
void finish();
|
|
174
|
+
// Runs a step that writes to the disk, and gives the file up if HDF5
|
|
175
|
+
// could not write it out meanwhile.
|
|
176
|
+
template <class Step>
|
|
177
|
+
std::int64_t writing(Step step);
|
|
178
|
+
[[noreturn]] void give_up();
|
|
165
179
|
void need_no_runs(const std::string& what) const;
|
|
166
180
|
void check_new_root_name(const std::string& name) const;
|
|
167
181
|
void ensure_datasets(const Batch* first);
|
|
@@ -191,6 +205,7 @@ class Writer {
|
|
|
191
205
|
Schema schema_;
|
|
192
206
|
FilterPipeline filters_ = default_pipeline();
|
|
193
207
|
bool closed_ = false;
|
|
208
|
+
std::string failure_; // set once the file was given up
|
|
194
209
|
bool model_ = false;
|
|
195
210
|
bool created_ = false;
|
|
196
211
|
bool datasets_ready_ = false;
|