![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
RAII cross-platform memory-mapped file segment. More...
#include <wal_mapped_segment.hpp>
Public Member Functions | |
| MappedSegment ()=default | |
| Default-construct an invalid (unmapped) segment. | |
| ~MappedSegment () noexcept | |
| MappedSegment (const MappedSegment &)=delete | |
| MappedSegment & | operator= (const MappedSegment &)=delete |
| MappedSegment (MappedSegment &&o) noexcept | |
| MappedSegment & | operator= (MappedSegment &&o) noexcept |
| uint8_t * | data () const noexcept |
| Pointer to the start of the mapped memory region. | |
| size_t | capacity () const noexcept |
| Size of the mapped region in bytes. | |
| bool | is_valid () const noexcept |
| Check whether the segment is currently mapped and valid. | |
| const std::string & | path () const noexcept |
| File path of this segment. | |
| expected< void > | flush_async () noexcept |
| Asynchronously flush dirty pages to storage (non-blocking). | |
| expected< void > | flush_sync () noexcept |
| Synchronously flush dirty pages to storage (blocks until complete). | |
| void | close () noexcept |
| Unmap and close all OS handles. Safe to call multiple times. | |
| void | prefault () noexcept |
| Pre-fault every 4 KB page in the mapping by reading one byte per page. | |
Static Public Member Functions | |
| static expected< MappedSegment > | create (const std::string &path, size_t size) noexcept |
| Create (overwrite) and memory-map a new segment file of the given byte size. | |
RAII cross-platform memory-mapped file segment.
Creates, maps, and manages a file backed by OS-level memory mapping (POSIX mmap / Windows MapViewOfFile). Supports async and sync flush, pre-faulting, and safe close semantics.
Definition at line 139 of file wal_mapped_segment.hpp.
|
default |
Default-construct an invalid (unmapped) segment.
|
inlinenoexcept |
Definition at line 143 of file wal_mapped_segment.hpp.
|
delete |
|
inlinenoexcept |
Definition at line 147 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
Size of the mapped region in bytes.
Definition at line 302 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
Unmap and close all OS handles. Safe to call multiple times.
Definition at line 353 of file wal_mapped_segment.hpp.
|
inlinestaticnoexcept |
Create (overwrite) and memory-map a new segment file of the given byte size.
On POSIX, uses ftruncate + mmap with MADV_SEQUENTIAL. On macOS, attempts contiguous pre-allocation via F_PREALLOCATE. On Windows, uses CreateFileMapping.
| path | File path for the new segment (created or overwritten). |
| size | Segment size in bytes; must be in [WAL_MMAP_MIN_SEGMENT, WAL_MMAP_MAX_SEGMENT] and a multiple of 65536. |
Definition at line 191 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
Pointer to the start of the mapped memory region.
Definition at line 300 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
Asynchronously flush dirty pages to storage (non-blocking).
Uses MS_ASYNC on POSIX, FlushViewOfFile (without FlushFileBuffers) on Windows.
Definition at line 311 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
Synchronously flush dirty pages to storage (blocks until complete).
Uses MS_SYNC on POSIX, FlushViewOfFile + FlushFileBuffers on Windows.
Definition at line 331 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
Check whether the segment is currently mapped and valid.
Definition at line 304 of file wal_mapped_segment.hpp.
|
delete |
|
inlinenoexcept |
Definition at line 166 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
File path of this segment.
Definition at line 306 of file wal_mapped_segment.hpp.
|
inlinenoexcept |
Pre-fault every 4 KB page in the mapping by reading one byte per page.
Uses read-only touch to avoid corrupting data on re-opened segments. Call from a background thread only – this can be expensive for large segments.
Definition at line 382 of file wal_mapped_segment.hpp.