appendix 0.1.0

Append-only, on-disk key-value index
Documentation

Appendix

An immutable, append-only, thread safe, on-disk index mapping Copy keys to Copy values.

Writes use mutexes, but reads are lock-free.

Overwriting values is not possible, and any insert with pre-existing key will simply be ignored.

Example from test

#[test]
fn multithreading() {
    let tempdir = TempDir::new("idx").unwrap();
    let idx = Arc::new(Index::new(tempdir.path()).unwrap());

    let n_threads = 16;
    let mut handles = vec![];

    for _ in 0..n_threads {
        let idx = idx.clone();
        handles.push(thread::spawn(move || {
            for i in 0..N {
                idx.insert(i, i).unwrap();
                }
            }))
    }

    for handle in handles {
        handle.join().unwrap();
    }

    for i in 0..N {
        assert_eq!(idx.get(&i).unwrap(), &i)
    }

    assert_eq!(idx.get(&N), None);
}