Expand description
Write-Ahead Log (WAL) for crash-safe ingestion.
Implements an append-only, CRC32-validated log with segment rotation and recovery protocol per the Storage Layout spec §3.
§Architecture
wal/
├── segment-000000000000.wal (64MB max, append-only)
├── segment-000000000001.wal
└── wal.meta (committed state)§Entry lifecycle
- Caller appends entry → WAL writes header + payload + CRC32
- After downstream store + index confirm, caller calls
commit() - On crash before commit, recovery replays uncommitted entries
§Recovery protocol
- Read
wal.metafor committed sequence number - Scan all segments for entries after committed sequence
- Validate CRC32 — truncate at first invalid entry
- Return uncommitted valid entries for replay
Structs§
- Wal
- Write-Ahead Log.
- WalConfig
- WAL configuration.
- WalEntry
- A WAL entry ready for serialization.
- WalMeta 🔒
- Persisted WAL metadata.
Enums§
- Entry
Type - WAL entry types.
Constants§
- DEFAULT_
MAX_ 🔒SEGMENT_ SIZE - Default maximum segment size: 64 MB.
- ENTRY_
HEADER_ 🔒SIZE - Entry header size in bytes (before payload).
- SEGMENT_
HEADER_ 🔒SIZE - Segment header size in bytes.
- WAL_
MAGIC 🔒 - Magic bytes identifying a CVX WAL segment.
- WAL_
VERSION 🔒 - Current WAL format version.
Functions§
- crc32_
hash 🔒 - Simple CRC32 hash (IEEE polynomial).
- decode_
delete_ payload - Decode a delete payload.
- decode_
insert_ payload - Decode an insert payload back into components.
- encode_
delete_ payload - Encode a delete payload: entity_id + timestamp.
- encode_
insert_ payload - Encode an insert payload: entity_id + timestamp + dimension + vector.