IntermediateAbout 15 min

    Hash Indexes & Append-Only Logs

    Read the full article on Substack

    6 min read.

    Watch writes append to a log, a hash map point at the newest record, segments compact, and the map rebuild after a crash.

    Think of it this way: A hash index is a diary you only ever write at the end of, plus a sticky note on the fridge listing which page holds the latest entry for each topic. Looking something up is one glance at the note and one flip to a page. When the diary gets long, you copy only the latest entry for each topic into a fresh diary and throw the old one away.

    In memorybytes on disk: 0, disk seeks: 0
    Hash mapkey → newest record
    empty
    On disk

    No segments yet.

    A hash index keeps every key in a map in memory. The map says where the newest value sits in a log on disk.

    1/8

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Follow a write through a hash index

    Sequence

    Order what happens from a put to getting the value back and later cleaning up.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Quiz

    8 questions
    Question 1 of 8
    Score: 0

    Where does a new write go in a hash-indexed log store?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going