← All projects
Project record1 mention
Originally shared on Hacker News

VennDB

VennDB is an append-only, in-memory Rust database library for rows queried using bit flags. A derive macro on a struct generates a database type and query builder; bools become bitmasks, filter values become sets of rows, and a query is the intersection of those sets, with the ability to pick a random match without finding all matches first. It is essentially an auto-generated bitmap index, narrow on purpose: append-only and in-memory, with no updates or deletes.

Last shared
01 / The problem

What it addresses

Picking a random row matching a handful of flags from data that barely changes but is queried constantly; scanning a Vec got slow and SQLite felt like too much database for "give me a random row with these flags".

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. VennDB

    VennDB is an append-only, in-memory Rust database library for rows queried using bit flags. A derive macro on a struct generates a database type and query builder; bools become bitmasks, filter values become sets of rows, and a query is the intersection of those sets, with the ability to pick a random match without finding all matches first. It is essentially an auto-generated bitmap index, narrow on purpose: append-only and in-memory, with no updates or deletes.

    Problem: Picking a random row matching a handful of flags from data that barely changes but is queried constantly; scanning a Vec got slow and SQLite felt like too much database for "give me a random row with these flags".

    Posted by @gdcbe · Original source ↗

    Story title · @gdcbe · · Source ↗

    Show HN: VennDB: append-only in-memory Rust DB for rows queried using bit flags

    Submitted URL · @gdcbe · · Source ↗

    https://github.com/plabayo/venndb

    Source text · @gdcbe · · Source ↗

    VennDB is a Rust library: you add a derive macro to a struct, and it generates a database type and a query builder for it. Bools become bitmasks, filter values become sets of rows, and a query is the intersection of those sets. It can pick a random match without finding all of them first.

    Source text · @gdcbe · · Source ↗

    This project started about three years ago as a small piece of a proxy project (ramaproxy.org): on every request we pick a random upstream proxy that matches a handful of flags and a country or city. The data barely changes, the queries happen constantly. Scanning a Vec got slow, and SQLite felt like a lot of database for "give me a random row with these flags".

    Source text · @gdcbe · · Source ↗

    It is mostly a bitmap index, generated from your struct so you don't have to write and maintain it yourself. It is also narrow on purpose: append-only and in-memory, with no updates or deletes.