A reverse trie key value db with exceptional lookup speed. Written in Rust.
523
StreamDB is a lightweight, thread-safe embedded key-value database implemented in Rust. It utilizes a reverse trie data structure for suffix-based search performance, making it ideal for domain analysis, log parsing, and bioinformatics.
RwLock and Mutex) for safe concurrent access from multiple threads.im::OrdMap for memory-efficient persistent trie updates.StreamDB consists of a core Rust library that manages a persistent Trie and multiple storage backends (In-Memory or File-based).
use streamdb::{StreamDb, Result};
fn main() -> Result<()> {
let db = StreamDb.open_memory()?; // Open in-memory instance
// Insert binary data
db.insert(b"user:alice", b"Alice Smith")?;
// Perform suffix search
let results = db.suffix_search(b"alice")?;
for result in results {
println!("Found key: {:?}", result.key);
}
Ok(())
}
The StreamDB AI-Ready Container provides a pre-configured Python environment with the database library pre-loaded at /lib/libstreamdb.so.
ctypes wrapper)import ctypes
# Load the deterministic binary
lib = ctypes.CDLL("/lib/libstreamdb.so")
# Initialize In-Memory DB
db_handle = ctypes.c_void_p()
lib.streamdb_open_memory(ctypes.byref(db_handle))
# Insert a key
key = b"agent:task_01"
val = b"completed"
lib.streamdb_insert(db_handle, key, len(key), val, len(val), None)
lib.streamdb_close(db_handle)
StreamDB uses Nix Flakes to guarantee that the container image is identical regardless of the build machine.
nix build .#docker
docker load < result
docker run --rm streamdb-ai-ready:latest ls -l /include/streamdb.h /lib/libstreamdb.so
The file timestamps will appear as Jan 1, 1970, confirming a deterministic Nix build.
StreamDB can be tuned via the Config struct:
| Option | Default | Description |
|---|---|---|
page_size | 4096 | Size of pages for file storage. |
cache_size | 10000 | Max entries in the LRU path cache. |
flush_interval_ms | 5000 | Auto-flush interval for persistence. |
use_mmap | true | Enable memory-mapped I/O. |
Theoretical results from AMD Ryzen 7 5800X equivalent:
This project is licensed under the GNU Lesser General Public License v2.1 (LGPL-2.1-or-later).
Copyright (C) 2025 DeMoD LLC.
Content type
Image
Digest
sha256:63661da75…
Size
80.4 MB
Last updated
9 months ago
docker pull alh477/streamdb-rs