Crates.io | meshanina |
lib.rs | meshanina |
version | 0.4.2 |
source | src |
created_at | 2022-01-07 01:53:02.666656 |
updated_at | 2022-11-16 16:57:48.717799 |
description | Content-addressed, log-structured memory-mapped database |
homepage | |
repository | https://github.com/themeliolabs/meshanina |
max_upload_size | |
id | 509236 |
size | 79,464 |
Meshanina is a rather strange key-value database, with three assumptions:
H
maps every value to every key: H(v) = k
. That is, the same key will never be rebound to a different value.Meshanina is designed for use as a content-addressed datastore, where keys are typically hashes of values and deletion is ill-defined. It is a purely log-structured, content-addressed database file where we interleave data blocks with 64-ary HAMT nodes. When we insert keys, we just insert gobs of data, then when we flush we make sure metadata is pushed out too.
In-memory, we keep track of an Arc-linked bunch of new nodes before they get flushed out. Everything is managed in a "purely functional" way.
meshanina2
On DB open, there is a recovery mechanism. We search backwards, from the end of the file, for instances of the magic divider, then try to decode a record at each instance. When we find the first validly encoded HAMT root, we stop. We then scan forwards, reinserting every valid data block after this root into the database.
Assuming that there are no "gaps" in correctly written blocks --- that is, if there's a record that's correctly written, every record before it must be so too --- this defends against arbitrary crashes and power interruptions. Essentially all Unix filesystems do guarantee that interrupted file appends cannot disturb existing data in the file.
Starting from the latest HAMT root node, do the usual HAMT lookup/insertion, using the 256-bit key value 6 bits at a time.