Skip to content

Generic Storage Backend Support for VersionedKvStore - #73

Merged
zhangfengcdt merged 7 commits into
mainfrom
feature/ai.agent.financial.multipleStorages
Jul 26, 2025
Merged

Generic Storage Backend Support for VersionedKvStore#73
zhangfengcdt merged 7 commits into
mainfrom
feature/ai.agent.financial.multipleStorages

Conversation

@zhangfengcdt

Copy link
Copy Markdown
Owner

This PR enhances the VersionedKvStore to support all storage backends (InMemory, File, RocksDB, Git) while maintaining
backward compatibility and keeping Git as the default storage backend.

Key Changes

Core Implementation

  • Modified VersionedKvStore to be generic over storage type <const N: usize, S: NodeStorage>
  • Added StorageBackend enum in types.rs to track which storage backend is being used
  • Created type aliases for convenient usage:
    • GitVersionedKvStore (default, maintains backward compatibility)
    • InMemoryVersionedKvStore
    • FileVersionedKvStore
    • RocksDBVersionedKvStore (when rocksdb_storage feature enabled)

Storage-Specific Initialization

  • Added backend-specific init() and open() methods for each storage type
  • Maintained Git-specific functionality like reload_tree_from_head() only for Git storage
  • Updated all imports and usages across the codebase to use appropriate type aliases

Usage Examples

  // Git storage (default, backward compatible)
  let store = GitVersionedKvStore::<32>::init(&path)?;

  // In-memory storage
  let store = InMemoryVersionedKvStore::<32>::init(&path)?;

  // File storage
  let store = FileVersionedKvStore::<32>::init(&path)?;

  // RocksDB storage (with feature flag)
  let store = RocksDBVersionedKvStore::<32>::init(&path)?;

Benefits

  1. Flexibility - Users can choose the most appropriate storage backend for their use case
  2. Performance - Access to optimized storage backends like RocksDB for high-performance scenarios
  3. Development - InMemory storage for testing, File storage for simple persistence
  4. Production - Git storage for version control integration, RocksDB for high-throughput applications
  5. Backward Compatibility - Existing code works without changes

This enhancement significantly expands the versatility of ProllyTree while maintaining its core versioning capabilities
across all storage backends.

@zhangfengcdt
zhangfengcdt merged commit f512fb7 into main Jul 26, 2025
3 checks passed
@zhangfengcdt
zhangfengcdt deleted the feature/ai.agent.financial.multipleStorages branch July 29, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant