Designing a single-file mmap-backed read-only hashed multi-table database

by Ciprian Dorin Craciun (https://volution.ro/ciprian) on 

For some time I wanted to design a CDB (Constant DataBase) alternative that fits better my use-case for Kawipiko (high performance read-only static HTTP server).

// permanent-link // Lobsters // HackerNews // index // RSS





Warning!

This is a work-in-progress, brainstorming document, which is not yet implemented.

Feedback is extremely welcome, see the comments section.

It is written with a bullet-style because it's easier to follow as a specification or for future reference.

Purpose

The goal is to have a persistent multi-namespace key-value database that is written once and read multiple times afterward.

Think something similar to CDB or Sparkey.

Where would I like to use this? Kawipiko!

What sets this apart from CDB (or other key-value stores)?

Requirements, constraints, assumptions

The database has the following characteristics:

Main considerations and constraints during access:

Main considerations and constraints during the creation:

Main assumptions:

High level overall design

Single-file byte-level format

Database header and trailer

All tables descriptor

Individual table descriptor

Individual value descriptor

Overhead analysis

The total overhead of storing an empty database:

The total overhead of storing a database with one table with one value of 1 byte:

The total overhead of storing a key-value pair:

High-level algorithms

Hash-map algorithm

Checksumming

Signing

Observations