Introduction
cdb, the constant database, is D. J. Bernstein’s file format for key and value data that is built once and then only read. A lookup needs very few disk reads.
Structure
0Header 256 pairs of hash table position and slot count2048 bytes2048Records the keys and values, one after anothervariableafterHash tables 256 tables of slots pointing at recordsvariable
The hash starts at 5381 and, for each byte of the key, computes
((h << 5) + h) ^ c.
Not described
This page is a first outline. The details of the layout are not yet described here.
Known, not yet covered
- Reference: the record and slot layouts, the lookup rules and cdb64, the variant with 64-bit quantities.
- Viewer: the site has no viewer for this format.
Links
Software
- cdb – Bernstein’s library and tools for creating and reading constant databases
Reference
- cdb format – Bernstein’s description
- A structure for constant databases – Bernstein’s text of 1996, with a note on cdb64
- cdb(5) – the TinyCDB manual page on the file format