Skip to main content

Crate shodh_redb

Crate shodh_redb 

Source
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, BTreeMap based API
  • Fully ACID-compliant transactions with MVCC
  • Crash-safe by default with savepoints and rollbacks
  • no_std compatible (with std feature flag, enabled by default)

§Extended Features

§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::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§

AccessGuard
Scoped accessor to data in the database
AccessGuardMut
AccessGuardMutInPlace
BlobCompactionHandle
Handle for online blob compaction that allows concurrent readers between phases.
BlobCompactionProgress
Progress report from a blob compaction step.
Builder
Configuration builder of a redb Database.
CacheStats
Information regarding the usage of the in-memory cache
CompactionHandle
Handle for an incremental online compaction.
CompactionProgress
Progress report from a single compaction step.
CorruptPageInfo
Details about a single corrupt page found during verification.
Database
DatabaseStats
Informational storage stats about the database
ExtractIf
FlashBackend
Storage backend for bare-metal flash devices.
FlashGeometry
Describes the physical geometry of a flash device.
FlashWearStats
Aggregate wear statistics for the flash device.
Legacy
Legacy wrapper for tuple types created with redb version 2.x
MultimapRange
MultimapTable
A multimap table
MultimapTableDefinition
Defines the name and types of a multimap table
MultimapValue
Range
RawEntryGuard
Entry from raw (untyped) table iteration, holding references to key and value bytes.
RawEntryIter
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.
ReadOnlyDatabase
A redb database opened in read-only mode
ReadOnlyMultimapTable
A read-only multimap table
ReadOnlyTable
A read-only table
ReadOnlyUntypedMultimapTable
A read-only untyped multimap table
ReadOnlyUntypedTable
A read-only untyped table
ReadTransaction
A read-only transaction
RepairSession
SalvageReport
Results of a best-effort database recovery (salvage) operation.
Savepoint
A database savepoint
Table
A table containing key-value mappings
TableDefinition
Defines the name and types of a table
TableStats
Informational storage stats about a table
TransactionInfo
Opened redb database file
TypeName
UntypedMultimapTableHandle
UntypedTableHandle
VerifyReport
Results of a database integrity verification.
WriteTransaction
A read/write transaction

Enums§

CompressionConfig
User-facing compression configuration.
Durability
ReadVerification
Controls inline checksum verification during B-tree reads.
ReadVerificationAction
Action to take when a read verification failure is detected.
VerifyLevel
Controls the depth of integrity verification.

Traits§

FlashHardware
Hardware abstraction trait for raw flash devices.
Key
Trait which allows the type to be used as a key in a redb table
MultimapTableHandle
MutInPlaceValue
Implementing this trait indicates that the type can be mutated in-place as a &mut u8. This enables the .insert_reserve() method on Table
ReadableDatabase
ReadableMultimapTable
ReadableTable
ReadableTableMetadata
StorageBackend
Implements persistent storage for a database.
TableHandle
Value
Types that implement this trait can be used as values in a redb table

Type Aliases§

Result