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, RocksDB, and Git-backed persistence
- Distributed-Ready: Efficient diff, sync, and three-way merge capabilities
- Python Bindings: Full API coverage via PyO3 with async support
- SQL Interface: Query trees with SQL via GlueSQL integration
- AI Agent Memory: Purpose-built for LLM applications and agent systems
Quick Start
Add to your Cargo.toml
:
[]
= "0.3.0"
# Optional features
= { = "0.3.0", = ["git", "sql", "rig"] }
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 GitVersionedKvStore;
use Command;
use fs;
// Setup: Create a temporary Git repository (in real use, you'd have an existing repo)
let repo_path = "/tmp/demo_git_repo";
create_dir_all?;
new.args.current_dir.output?;
// Switch to repo directory and create dataset
set_current_dir?;
create_dir_all?;
let mut store = init?;
// Now use Git-backed versioned storage
store.insert?;
store.commit?;
// Retrieve data
if let Some = store.get
// Add more data and commit
store.insert?;
store.commit?;
// Create branches for parallel development
store.create_branch?;
println!;
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
// For SQL functionality, see examples/sql.rs
println!;
Feature Flags
[]
= "0.3.0"
= [
"git", # Git-backed versioned storage
"sql", # SQL interface via GlueSQL
"rig", # Rig framework integration for AI
"python", # Python bindings via PyO3
"rocksdb_storage", # RocksDB persistent storage backend
]
Performance
Benchmarks (Apple M3 Pro, 18GB RAM):
- Insert: ~8-21 µs (scales O(log n))
- Lookup: ~1-3 µs (sub-linear due to caching)
- Memory: ~100 bytes per key-value pair
- Batch operations: ~25% faster than individual ops
Run benchmarks: cargo bench
Documentation & Examples
- Full API Documentation
- Use Cases & Examples - AI agents, version control, distributed systems
- Python Bindings - Complete Python API
- Performance Guide - Optimization tips
CLI Tool
# Install git-prolly CLI
# Setup git repository and create dataset
&&
&&
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
License
Licensed under the Apache License 2.0. See LICENSE.