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 mmap handles are cached and incrementally invalidated on rotation and GC. Aggregation across segments is parallelised with rayon.
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.
One writer per engine. The write path holds a RwLock on rollups and a Mutex on the WAL. Reads acquire only read locks — concurrent with writes.
Events arrive in non-decreasing ts_ns order. Each segment's ts column is sorted; readers binary-search.
A closed .kseg is never modified. All updates are tombstones in a side index.
Retention is unlink(). There is no compaction because there is nothing to compact into.