Expand description
§shodh-redb
Multi-modal embedded database for Rust - vectors, blobs, TTL, merge operators, and causal tracking built on ACID B-trees.
shodh-redb extends redb with capabilities for AI/ML workloads, edge computing, and multi-modal data. Data is stored in a collection of copy-on-write B-trees with full ACID guarantees.
§Core Features
- Zero-copy, thread-safe,
BTreeMapbased API - Fully ACID-compliant transactions with MVCC
- Crash-safe by default with savepoints and rollbacks
no_stdcompatible (withstdfeature flag, enabled by default)
§Extended Features
- Vector types –
FixedVec,DynVec,BinaryQuantized,ScalarQuantizedwith distance metrics (cosine_distance,euclidean_distance_sq,hamming_distance) and top-k search (nearest_k) - Blob store – Streaming writes, content-addressable dedup, seekable reads, causal lineage tracking, and crash-safe compaction
- TTL tables – Per-key expiration with lazy filtering and bulk purge
(requires
stdfeature) - Merge operators – Atomic read-modify-write via
MergeOperatortrait with built-inNumericAdd,NumericMax,BitwiseOr, and more - Group commit – Batch concurrent writes into a single fsync
(requires
stdfeature) - Hybrid Logical Clock –
HybridLogicalClockfor causal ordering in distributed systems - Memory budget – Hard RAM cap with adaptive cache sizing
§Example
use shodh_redb::{Database, Error, ReadableDatabase, ReadableTable, TableDefinition};
const TABLE: TableDefinition<&str, u64> = TableDefinition::new("my_data");
fn main() -> Result<(), Error> {
let file = tempfile::NamedTempFile::new().unwrap();
let db = Database::create(file.path())?;
let write_txn = db.begin_write()?;
{
let mut table = write_txn.open_table(TABLE)?;
table.insert("my_key", &123)?;
}
write_txn.commit()?;
let read_txn = db.begin_read()?;
let table = read_txn.open_table(TABLE)?;
assert_eq!(table.get("my_key")?.unwrap().value(), 123);
Ok(())
}Re-exports§
pub use error::BackendError;pub use error::CommitError;pub use error::CompactionError;pub use error::DatabaseError;pub use error::Error;pub use error::SavepointError;pub use error::SetDurabilityError;pub use error::StorageError;pub use error::TableError;pub use error::TransactionError;pub use group_commit::GroupCommitError;pub use group_commit::WriteBatch;pub use incremental::IncrementalBackupReport;pub use incremental::IncrementalImportReport;pub use incremental::IncrementalSnapshot;pub use integrity_scanner::IntegrityScannerConfig;pub use integrity_scanner::IntegrityScannerHandle;pub use integrity_scanner::ScanCycleResult;pub use blob_store::BlobCompactionPolicy;pub use blob_store::BlobCompactionReport;pub use blob_store::BlobId;pub use blob_store::BlobInput;pub use blob_store::BlobMeta;pub use blob_store::BlobReader;pub use blob_store::BlobRef;pub use blob_store::BlobStats;pub use blob_store::BlobWriter;pub use blob_store::CausalEdge;pub use blob_store::CausalLink;pub use blob_store::CausalPath;pub use blob_store::ContentType;pub use blob_store::DedupStats;pub use blob_store::MAX_TAGS_PER_BLOB;pub use blob_store::RelationType;pub use blob_store::StoreOptions;pub use cdc::CdcConfig;pub use cdc::CdcKey;pub use cdc::CdcRecord;pub use cdc::ChangeOp;pub use cdc::ChangeStream;pub use composite::BlobQueryProvider;pub use composite::CompositeQuery;pub use composite::ScoredBlob;pub use composite::SignalScores;pub use composite::SignalWeights;pub use ivfpq::Codebooks;pub use ivfpq::IndexConfig;pub use ivfpq::IvfPqIndex;pub use ivfpq::IvfPqIndexDefinition;pub use ivfpq::MetadataFilter;pub use ivfpq::MetadataMap;pub use ivfpq::MetadataValue;pub use ivfpq::ReadOnlyIvfPqIndex;pub use ivfpq::SearchParams;pub use merge::BitwiseOr;pub use merge::BytesAppend;pub use merge::FloatAdd;pub use merge::FnMergeOperator;pub use merge::MergeOperator;pub use merge::NumericAdd;pub use merge::NumericMax;pub use merge::NumericMin;pub use merge::SaturatingAdd;pub use merge::merge_fn;pub use observer::CommitInfo;pub use observer::DatabaseObserver;pub use probe_select::DiversityConfig;pub use temporal::HybridLogicalClock;pub use ttl_table::ReadOnlyTtlTable;pub use ttl_table::TtlAccessGuard;pub use ttl_table::TtlRange;pub use ttl_table::TtlTable;pub use ttl_table::TtlTableDefinition;pub use vector::BinaryQuantized;pub use vector::DynVec;pub use vector::FixedVec;pub use vector::SQVec;pub use vector::ScalarQuantized;pub use vector_ops::DistanceMetric;pub use vector_ops::Neighbor;pub use vector_ops::cosine_distance;pub use vector_ops::cosine_similarity;pub use vector_ops::dequantize_scalar;pub use vector_ops::dot_product;pub use vector_ops::euclidean_distance_sq;pub use vector_ops::hamming_distance;pub use vector_ops::l2_norm;pub use vector_ops::l2_normalize;pub use vector_ops::l2_normalized;pub use vector_ops::manhattan_distance;pub use vector_ops::nearest_k;pub use vector_ops::nearest_k_fixed;pub use vector_ops::quantize_binary;pub use vector_ops::quantize_scalar;pub use vector_ops::read_f32_le;pub use vector_ops::sq_dot_product;pub use vector_ops::sq_euclidean_distance_sq;pub use vector_ops::write_f32_le;
Modules§
- backends
- blob_
store - cdc
- composite
- error
- group_
commit - incremental
- Incremental backup and portable snapshot export/import.
- integrity_
scanner - Background integrity scanner for continuous corruption detection.
- ivfpq
- IVF-PQ vector index – disk-first approximate nearest neighbor search.
- merge
- observer
- Database observability infrastructure.
- probe_
select - Diversity-aware probe selection for multi-probe vector search.
- storage_
traits - Backend-agnostic storage traits for shodh-redb.
- temporal
- ttl_
table - vector
- vector_
ops
Structs§
- Access
Guard - Scoped accessor to data in the database
- Access
Guard Mut - Access
Guard MutIn Place - Blob
Compaction Handle - Handle for online blob compaction that allows concurrent readers between phases.
- Blob
Compaction Progress - Progress report from a blob compaction step.
- Builder
- Configuration builder of a redb Database.
- Cache
Stats - Information regarding the usage of the in-memory cache
- Compaction
Handle - Handle for an incremental online compaction.
- Compaction
Progress - Progress report from a single compaction step.
- Corrupt
Page Info - Details about a single corrupt page found during verification.
- Database
- Database
Stats - Informational storage stats about the database
- Extract
If - Flash
Backend - Storage backend for bare-metal flash devices.
- Flash
Geometry - Describes the physical geometry of a flash device.
- Flash
Wear Stats - Aggregate wear statistics for the flash device.
- Legacy
- Legacy wrapper for tuple types created with redb version 2.x
- Multimap
Range - Multimap
Table - A multimap table
- Multimap
Table Definition - Defines the name and types of a multimap table
- Multimap
Value - Range
- RawEntry
Guard - Entry from raw (untyped) table iteration, holding references to key and value bytes.
- RawEntry
Iter - Iterator over all entries in a table as raw key/value byte slices. Does not require knowing the key or value types at compile time.
- Read
Only Database - A redb database opened in read-only mode
- Read
Only Multimap Table - A read-only multimap table
- Read
Only Table - A read-only table
- Read
Only Untyped Multimap Table - A read-only untyped multimap table
- Read
Only Untyped Table - A read-only untyped table
- Read
Transaction - A read-only transaction
- Repair
Session - Salvage
Report - Results of a best-effort database recovery (salvage) operation.
- Savepoint
- A database savepoint
- Table
- A table containing key-value mappings
- Table
Definition - Defines the name and types of a table
- Table
Stats - Informational storage stats about a table
- Transaction
Info - Opened redb database file
- Type
Name - Untyped
Multimap Table Handle - Untyped
Table Handle - Verify
Report - Results of a database integrity verification.
- Write
Transaction - A read/write transaction
Enums§
- Compression
Config - User-facing compression configuration.
- Durability
- Read
Verification - Controls inline checksum verification during B-tree reads.
- Read
Verification Action - Action to take when a read verification failure is detected.
- Verify
Level - Controls the depth of integrity verification.
Traits§
- Flash
Hardware - Hardware abstraction trait for raw flash devices.
- Key
- Trait which allows the type to be used as a key in a redb table
- Multimap
Table Handle - MutIn
Place Value - Implementing this trait indicates that the type can be mutated in-place as a &mut u8.
This enables the
.insert_reserve()method on Table - Readable
Database - Readable
Multimap Table - Readable
Table - Readable
Table Metadata - Storage
Backend - Implements persistent storage for a database.
- Table
Handle - Value
- Types that implement this trait can be used as values in a redb table