| Crates.io | linhash |
| lib.rs | linhash |
| version | 0.4.0 |
| created_at | 2026-01-13 08:35:46.621894+00 |
| updated_at | 2026-01-20 04:04:56.972249+00 |
| description | Linear Hashing implementation. |
| homepage | |
| repository | https://github.com/akiradeveloper/LinHash |
| max_upload_size | |
| id | 2039585 |
| size | 78,682 |
Concurrent Linear Hashing implementation in Rust.
Best suit for metadata store for a database.
Each operation is designed to take a hierarchy of locks before doing its work. This is type-checked by Rust compiler.
| Read Lock | Selective Lock | Exclusive Lock | |
|---|---|---|---|
| Read Lock | ✅️ | ✅️ | ❌ |
| Selective Lock | ✅️ | ❌️ | ❌️ |
| Exclusive Lock | ❌️ | ❌️ | ❌️ |
| Operation | Root Lock | Bucket Lock |
|---|---|---|
| INSERT | Read Lock | Selective Lock |
| DELETE | Read Lock | Exclusive Lock |
| GET | Read Lock | Read Lock |
| LIST | Exclusive Lock | |
| SPLIT | Read Lock | Selective Lock |
The API is as same as HashMap.
use linhash::LinHash;
let dir = tempfile::tempdir().unwrap();
let ksize = 2;
let vsize = 4;
let db = LinHash::open(dir.path(), ksize, vsize).unwrap();
db.insert(vec![1, 2], vec![3, 4, 5, 6]).unwrap();
let old = db.insert(vec![1, 2], vec![7, 8, 9, 10]).unwrap();
assert_eq!(old, Some(vec![3, 4, 5, 6]));
assert_eq!(db.get(&vec![1, 2]).unwrap(), Some(vec![7, 8, 9, 10]));
let old = db.delete(&vec![1, 2]).unwrap();
assert_eq!(old, Some(vec![7, 8, 9, 10]));
assert_eq!(db.get(&vec![1, 2]).unwrap(), None);
| flag | default | description |
|---|---|---|
| hash | on | Enabled → Hash function is used to calculate hash from key. Disabled → 64 bit from the given key is taken as a hash, eliminating the cost of hashing. |
| atomic-write | off | Enabled → writes are atomic using RWF_ATOMIC. Disabled → crash tolerance is not guaranteed but high speed. |