pub struct ConcurrentPathTrie { /* private fields */ }Expand description
Concurrent Path Trie with lock-free reads and epoch-based reclamation
This trie supports:
- Lock-free concurrent reads via DashMap
- Concurrent inserts with fine-grained locking
- Epoch-based garbage collection for safe memory reclamation
§Performance
- Read: O(|path|) with no locking (DashMap provides lock-free reads)
- Insert: O(|path|) with minimal lock contention
- Memory reclamation: Deferred until no readers access old nodes
Implementations§
Source§impl ConcurrentPathTrie
impl ConcurrentPathTrie
Sourcepub fn current_epoch(&self) -> u64
pub fn current_epoch(&self) -> u64
Get current epoch
Sourcepub fn advance_epoch(&self) -> u64
pub fn advance_epoch(&self) -> u64
Advance epoch (call periodically to allow GC)
Sourcepub fn begin_read(&self) -> ReadGuard<'_>
pub fn begin_read(&self) -> ReadGuard<'_>
Begin a read operation (returns epoch guard) The guard must be held for the duration of the read
Sourcepub fn insert(&self, path: &str, column_type: ColumnType) -> ColumnId
pub fn insert(&self, path: &str, column_type: ColumnType) -> ColumnId
Insert a path and get its column ID (thread-safe)
Path format: “users.profile.settings.theme” Returns the assigned column ID
Sourcepub fn resolve(&self, path: &str) -> Option<ColumnId>
pub fn resolve(&self, path: &str) -> Option<ColumnId>
Resolve a path to its column ID in O(|path|) time (lock-free)
Returns None if path doesn’t exist
Sourcepub fn resolve_with_type(&self, path: &str) -> Option<(ColumnId, ColumnType)>
pub fn resolve_with_type(&self, path: &str) -> Option<(ColumnId, ColumnType)>
Resolve with type information (lock-free)
Sourcepub fn prefix_match(&self, prefix: &str) -> Vec<(String, ColumnId)>
pub fn prefix_match(&self, prefix: &str) -> Vec<(String, ColumnId)>
Get all paths that start with a prefix (lock-free)
Sourcepub fn total_columns(&self) -> u32
pub fn total_columns(&self) -> u32
Get total number of columns
Sourcepub fn total_nodes(&self) -> usize
pub fn total_nodes(&self) -> usize
Get total number of nodes (memory usage indicator)
Sourcepub fn update_min_reader_epoch(&self)
pub fn update_min_reader_epoch(&self)
Update minimum reader epoch (call after readers complete)
Sourcepub fn min_reader_epoch(&self) -> u64
pub fn min_reader_epoch(&self) -> u64
Get minimum reader epoch (nodes older than this can be reclaimed)