redb-extras
Use-case agnostic utilities for redb, featuring sharded roaring bitmap tables.
Overview
redb-extras provides focused storage primitives that solve common low-level problems while maintaining explicit, synchronous behavior and integrating naturally with redb's transaction model.
Main Feature: Partitioned Roaring Bitmap Tables
A key-value store where:
- Keys are opaque byte slices (you control the structure)
- Values are Roaring bitmaps (
RoaringTreemap<u64>) - Automatic sharding spreads writes for hot keys
- Segment-based storage controls write amplification
- KV-like mental model - sharding is invisible to callers
Quick Start
use Database;
use PartitionedRoaringTable;
// Create database and table
let db = create?;
let table = new;
// Insert data
let mut write_txn = db.begin_write?;
write_txn.commit?;
// Read data
let read_txn = db.begin_read?;
let reader = table.read;
let sessions = reader.get?;
println!;
Features
- Bounded write cost - avoid rewriting ever-growing bitmap blobs
- Deterministic sharding - consistent element placement across shards
- Size-based segmentation - segments roll when serialized size exceeds threshold
- Opaque keys - you control key structure and semantics
- Explicit transactions - no background threads, fully synchronous
- No domain semantics - pure storage primitive for higher-level systems
Configuration
use ;
let config = new;
Use Cases
- Session tracking systems
- Real-time analytics indices
- Event sourcing append-only logs
- Large-scale set operations
- Any scenario needing efficient bitmap storage with controlled write amplification
Architecture
The library uses a layered design:
- Facade Layer (
PartitionedRoaringTable): High-level opinionated API - Partition Layer: Generic sharded + segmented byte storage
- Value Layer: Roaring-specific value handling and optimization
This separation allows advanced users to use lower-level primitives directly when the facade is too restrictive.
Dependencies
redb- Embedded B-tree database with ACID transactionsroaring- Fast compressed bitmap implementationxxhash-rust- High-speed hashing for shard selection
License
Apache License 2.0