ProllyTree
A probabilistic B-tree implementation in Rust that combines B-tree efficiency with Merkle tree cryptographic properties. Designed for distributed systems, version control, and verifiable data structures.
Features
- High Performance: O(log n) operations with cache-friendly probabilistic balancing
- Cryptographically Verifiable: Merkle tree properties for data integrity and inclusion proofs
- Multiple Storage Backends: In-memory, File, RocksDB, and Git-backed persistence
- Distributed-Ready: Efficient diff, sync, and three-way merge with pluggable conflict resolvers
- Python Bindings: Full API coverage via PyO3 with async support
- SQL Interface: Query trees with SQL via GlueSQL integration
Quick Start
Add to your Cargo.toml:
[]
= "0.3.2"
# Optional features
= { = "0.3.2", = ["git", "sql"] }
Examples
Basic Tree Operations
use ;
use InMemoryNodeStorage;
let storage = new;
let mut tree = new;
// Insert data
tree.insert;
tree.insert;
// Query data - find returns a node, extract the value
if let Some = tree.find
// Generate cryptographic proof
let proof = tree.generate_proof;
let is_valid = tree.verify;
Git-backed Versioned Storage
use StoreFactory;
// Create a Git-backed versioned key-value store
let mut store = ?;
// Insert and commit
store.insert?;
store.commit?;
// Retrieve data
if let Some = store.get
// Create branches for parallel development
store.create_branch?;
// Thread-safe variant for concurrent access
let ts_store = ?;
Multiple Storage Backends
use ;
use ;
// In-memory storage (fast, temporary)
let mem_storage = new;
let mut mem_tree = new;
mem_tree.insert;
// File-based storage (persistent)
let file_storage = new?;
let mut file_tree = new;
file_tree.insert;
// Both trees support the same operations
if let Some = mem_tree.find
Feature Flags
| Feature | Description | Default |
|---|---|---|
git |
Git-backed versioned storage with branching, merging, and history | Yes |
sql |
SQL query interface via GlueSQL | Yes |
rocksdb_storage |
RocksDB persistent storage backend | No |
python |
Python bindings via PyO3 | No |
tracing |
Observability via the tracing crate |
No |
digest_base64 |
Base64 encoding for digests | Yes |
[]
= "0.3.2"
= ["git", "sql", "rocksdb_storage"]
Performance
Benchmarks (Apple M3 Pro, 18GB RAM):
- Insert: ~8-21 us (scales O(log n))
- Lookup: ~1-3 us (sub-linear due to caching)
- Memory: ~100 bytes per key-value pair
- Batch operations: ~25% faster than individual ops
Run benchmarks: cargo bench
Testing
Unit Tests
# Run all unit tests with default features
# Run with specific features
# Run a specific test
Integration Tests
The project includes a comprehensive integration test suite in tests/:
| Test file | Description |
|---|---|
cli_commands.rs |
End-to-end tests for all git-prolly CLI commands |
store_factory.rs |
StoreFactory API for all backend types |
versioned_store_cross_backend.rs |
Cross-backend consistency (Git vs InMemory vs File) |
sql_integration.rs |
Full SQL query lifecycle via GlueSQL |
conflict_resolvers.rs |
All conflict resolvers through real branch merges |
git_versioning_lifecycle.rs |
Branching, merging, history, and persistence |
worktree_integration.rs |
WorktreeManager concurrent operations |
storage_backends.rs |
InMemory and File NodeStorage CRUD |
error_recovery.rs |
Error paths: corrupted config, missing repos, bad branches |
scale_and_stress.rs |
Large datasets and concurrent stress (marked #[ignore]) |
# Run all integration tests
# Run a specific integration test file
# Run scale/stress tests (slower, ignored by default)
# Run only unit tests (skip integration)
Python Tests
# Build Python bindings first
# Run Python tests
Documentation & Examples
- Full API Documentation
- Python Documentation
- Use Cases & Examples - Version control, SQL, proofs, storage backends
- Python Bindings - Complete Python API
CLI Tool
# Install git-prolly CLI
# Setup git repository and create dataset
&&
&&
# Key-value operations
# Branching and merging (uses git branches)
# SQL queries (requires sql feature)
# History and inspection
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
License
Licensed under the Apache License 2.0. See LICENSE.