You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;fnmain(){let db = {letmut 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