1 unstable release

0.1.0 Apr 18, 2024

#2063 in Database interfaces

Apache-2.0

78KB
2K SLoC

mintkv

A simple KV database in rust is based on btree, written as a learning project.

File system layout

data
|----blocks
|      b_0000001
          data
          meta.json
          index.json
          tombstone
|      b_0000002
          data
          meta.json
          index.json
          tombstone
|-----memtables (mmap)
|         m_0001
             data 
             tombstone

TODO

  • B+tree as engine
  • Memtables
  • LE128 Code
  • Blocks(disk present)
  • Wal
  • tombstone
  • compaction

Example

use mintkv::db::MintKv;
const TEST_COUNT: i32 = 1000;

fn main() {
    let mut db = MintKv::new("./data");
    for i in 0..TEST_COUNT {
        let (key, value) = (format!("key-{}", i), format!("value-{}", i));
        db.insert(&key, &value).unwrap();
    }

    for i in 0..TEST_COUNT {
        let key = format!("key-{}", i);
        let result = db.get(&key);
        println!("Search For: {}, Reesult: {:?}", key, result);
    }
}

No runtime deps