Skip to content

dakv/dakv

Repository files navigation

test clippy Build Status codecov Codacy Badge

Diagram

sequenceDiagram
autonumber
participant dakv
    participant W as writer worker
    participant C as compaction worker
    Note over dakv: main thread
    Note over W: writer thread
    Note over C: compaction thread
    dakv->>W: start writer worker
    dakv->>C: start compaction worker
    loop
        W-->>W: wait for writer signal
    end
    loop
        C-->>C: Wait for compaction signal
    end
    participant Log as write ahead log
    participant Mem as memtable
    dakv->>W: write kv record
    W-->>C: maybe trigger compaction
    W->>Log: write record
    W->>Mem: insert into memtable
    W->>dakv: send OK message

Example

use dakv::{Database, Options, ReadOptions, TestEnv, WriteOptions, DB};
use std::sync::Arc;

fn main() {
    let db = {
        let mut opt = Options::default();
        opt.env = Arc::new(TestEnv::default());
        DB::open("example_db".to_string(), opt).unwrap()
    };

    let write_opt = WriteOptions::default();
    db.put(
        b"Red",
        b"Let me tell you something my friend. Hope is a dangerous thing. Hope can drive a man insane.",
        write_opt.clone(),
    ).unwrap();
    {
        let opt = ReadOptions::new();
        assert!(db.get(b"Red", opt.clone()).is_ok());
        db.delete(b"Red", write_opt.clone()).unwrap();
        assert_eq!(db.get(b"Red", opt).unwrap_err().to_string(), "NotFound");
    }
    db.put(
        b"Andy Dufresne",
        b"Remember Red, hope is a good thing, maybe the best of things, and no good thing ever dies.",
        write_opt.clone(),
    ).unwrap();
}

Build

cd dakv
git submodule update --init --recursive
cargo build

Features

  • Fast CRC (support see and PCLMULQDQ instructions)

Future

  • Support io_uring
  • Implement WiscKey to improve performance.
  • Use DB session ID as the cache key prefix to ensure uniqueness and repeatability
  • Fuzz testing with rust-fuzz/afl
  • Support multi get.
  • YCSB Benchmark

FOSSA Status

About

A Rust storage-engine library that provides an embeddable, persistent key-value store for fast storage.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published