KeplorDB is three moving parts — an in-memory columnar buffer, a write-ahead log, and a set of immutable column-oriented segment files. There are no background threads and no compactions. Segment reads are lock-free via ArcSwap. Rollups are deferred to rotation time. Aggregation across segments is parallelised with rayon. Status bitmap indexes and zone maps enable row- and chunk-level pruning before any column data is touched.
Dims resolved through a hashbrown arena. No String allocations.
Twenty column buffers receive unchecked vec pushes. Bounds verified at open.
Serialise to a reusable buffer, length-prefixed, then write().
Every 64th event durably syncs the WAL. Configurable per engine.
When buffer hits wal_max_events, flush columns to a new .kseg. Build status bitmap + zone maps.
One writer per engine. The write path holds only a Mutex on the WAL — rollups are deferred to rotation. Reads are lock-free via ArcSwap — concurrent with writes, zero contention.
Events arrive in non-decreasing ts_ns order. Each segment's ts column is sorted; readers binary-search. Delta-encoded + zstd compressed.
A closed .kseg is never modified. All updates are tombstones in a side index. Status bitmap + zone maps built at rotation time.
Retention is unlink(). GC uses in-memory manifest — zero disk reads. There is no compaction because there is nothing to compact into.