![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
Manages multiple rolling WAL segment files in a directory. More...
#include <wal.hpp>
Public Types | |
| using | Options = WalManagerOptions |
| Alias for the options struct. | |
Public Member Functions | |
| WalManager (const WalManager &)=delete | |
| WalManager & | operator= (const WalManager &)=delete |
| WalManager (WalManager &&o) noexcept | |
| WalManager & | operator= (WalManager &&)=delete |
| ~WalManager () | |
| expected< int64_t > | append (const uint8_t *data, size_t size) |
| Append a record to the current segment, rolling to a new segment if needed. | |
| expected< int64_t > | append (const char *data, size_t size) |
| Append a record from a char pointer. | |
| expected< int64_t > | append (std::string_view sv) |
| Append a record from a string_view. | |
| std::vector< std::string > | segment_paths () const |
| List all WAL segment paths in sequence order (oldest first). | |
| expected< void > | commit_compaction_checkpoint (const std::string ¬e="") |
| Record that an external compaction checkpoint has been made durable, allowing old fully-compacted WAL segments to be pruned safely. | |
| void | clear_compaction_checkpoint () |
| Reset the checkpoint-ready flag so subsequent prune calls are blocked again until the next commit_compaction_checkpoint(). | |
| expected< void > | remove_segment (const std::string &path) |
| Remove a fully-compacted segment from disk and from the tracking list. | |
| int64_t | total_records () const noexcept |
| Total number of records written across all segments (including rolled ones). | |
| expected< void > | close () |
| Close the manager and the active segment writer. | |
| expected< std::vector< WalEntry > > | read_all () |
| Read all WAL entries across all segments (sealed and active). | |
Static Public Member Functions | |
| static expected< WalManager > | open (const std::string &dir, Options opts={}) |
| Open a WAL directory, discovering existing segments and creating a new active segment ready for writing. | |
Manages multiple rolling WAL segment files in a directory.
Automatically rolls to a new segment when the current segment exceeds max_segment_bytes or max_records. Provides crash-recovery read_all() across all segments, compaction checkpoint support, and safe segment pruning.
Thread-safe: all public methods acquire an internal mutex. Non-copyable, move-constructible. Use WalManager::open() to create.
|
delete |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
Reset the checkpoint-ready flag so subsequent prune calls are blocked again until the next commit_compaction_checkpoint().
|
inline |
|
inline |
Record that an external compaction checkpoint has been made durable, allowing old fully-compacted WAL segments to be pruned safely.
If checkpoint_manifest_path is configured, writes an atomic marker file. Must be called before remove_segment() when require_checkpoint_before_prune is enabled.
| note | Optional human-readable note written to the manifest. |
|
inlinestatic |
Open a WAL directory, discovering existing segments and creating a new active segment ready for writing.
If reset_on_open is true (and lifecycle_mode is not Production), all existing segment files are deleted before starting fresh.
| dir | Directory path (created if it does not exist). |
| opts | Manager options (segment limits, sync policy, lifecycle mode). |
|
delete |
|
delete |
|
inline |
Remove a fully-compacted segment from disk and from the tracking list.
The currently active (most recent) segment cannot be removed. If require_checkpoint_before_prune is enabled, commit_compaction_checkpoint() must be called first.
| path | Filesystem path of the segment to remove. |
|
inline |
|
inlinenoexcept |