16-FEB-2011: A simple "append-only" database r0 (See the current copy)

A proposed API and implementation for an append-only database

  1. Journal (multiple concurrent writers) -- all writes go here, acts as a buffer
  2. Database (flat text file, looks like a log file) -- written to by single thread reading from Journal; order of inserts is not guaranteed to be the same as order of inserts into journal
  3. Index (binary tree of keys) -- values are kept in sorted order with a count of the number of values; values are pointers to offsets in the Database

Support disabling the journal or the index at compile time using #define AMDB_NO_JOURNAL and #define AMDB_NO_INDEX

Journal format:

  1. [Magic (32-bits)]
  2. [Header Size (HDR_SZ; 32-bits)]
  3. [Header (HDR_SZ * 8-bits)]:
    1. Tag-Length-Value
  4. [Tracks (NUM_TRACKS * TRACK_SIZE * 8-bits)]