rawdb-0.4.1 has been yanked.
rawdb
Non-transactional embedded storage engine with a filesystem-like API.
It features:
- Multiple named regions in one file
- Automatic space reclamation via hole punching
- Regions grow and move automatically as needed
- Zero-copy mmap access
- Thread-safe with concurrent reads and writes
- Page-aligned allocations (4KB)
- Crash-consistent with explicit flush
- Foundation for higher-level abstractions (e.g.,
vecdb)
It is not:
- A transactional database (no ACID, transactions, or rollback)
- A query engine (no SQL, indexes, or schemas)
Install
Usage
use ;
Durability
Operations become durable after calling flush(). Before flush, writes are visible in memory but not guaranteed to survive crashes.
Design:
- 4KB metadata entries: Atomic page-sized writes per region with embedded IDs
- Single metadata file: Rebuilt into HashMap on startup for O(1) lookups
- No WAL: Simple design with lazy flushing for consistency
- Lazy writes: Both data and metadata are written to mmaps immediately but not synced until flush
Write model:
- Data writes modify the data mmap immediately (visible but not durable)
- Metadata changes modify the metadata mmap immediately (visible but not durable)
- Holes from moves/removes are marked as pending (not reusable until flush)
flush()syncs both mmaps (data → metadata → file size), then promotes pending holes- Ensures metadata never points to unflushed data and old locations aren't reused prematurely
Region operations:
- Expand in-place when possible (last region or adjacent hole)
- Copy-on-write to new location when expansion needed
- All changes visible immediately in mmaps, durable after
flush()
Recovery: On open, reads all metadata entries and rebuilds in-memory structures. Deleted regions are identified by zeroed metadata.