21 unstable releases (3 breaking)
Uses new Rust 2024
| new 0.3.16 | Nov 9, 2025 |
|---|---|
| 0.3.15 |
|
| 0.2.17 | Oct 10, 2025 |
| 0.2.16 | Sep 20, 2025 |
| 0.0.2 | Aug 9, 2025 |
#465 in Database interfaces
210 downloads per month
Used in 13 crates
(7 directly)
305KB
9K
SLoC
vecdb
High-performance mutable persistent vectors built on rawdb.
It features:
Vecbased API: push, update, truncate, delete by index- Multiple variants:
raw,compressed,computed - Rollback via stamped change deltas
- Sparse deletions with holes
- Thread-safe with concurrent reads
- Blazing fast (benchmark)
- Persistence only on
flush
It is not:
Install
cargo add vecdb
Usage
use vecdb::{AnyStoredVec, Database, GenericStoredVec, RawVec, Result, Version};
fn main() -> Result<()> {
// create
let temp_dir = tempfile::TempDir::new()?;
let db = Database::open(temp_dir.path())?;
let mut vec: RawVec<usize, u64> = RawVec::import(&db, "vec", Version::ONE)?;
// push
for i in 0..1_000_000 {
vec.push(i);
}
// flush
vec.flush()?;
db.flush()?;
// read (sequential)
let mut sum = 0u64;
for value in vec.iter()? {
sum = sum.wrapping_add(value);
}
// read (random)
let indices: Vec<usize> = vec![500, 1000, 10];
let reader = vec.create_reader();
for i in indices {
if let Ok(value) = vec.read_at(i, &reader) {
sum = sum.wrapping_add(value);
}
}
Ok(())
}
Constraints
Data must be fixed-size types: numbers, fixed arrays, structs with #[repr(C)].
Compression via Pcodec works for numeric types only.
When to use it
- Need to store
Vecs on disk - Append-only or append-mostly workloads
- Need very high read speeds
- Space-efficient storage for numeric data
- Sparse deletions without reindexing
- Rollback without full snapshots
Dependencies
~7–10MB
~189K SLoC