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)
Trait Implementations§
Source§impl Debug for ConcurrentPathTrie
impl Debug for ConcurrentPathTrie
Source§impl Default for ConcurrentPathTrie
impl Default for ConcurrentPathTrie
impl Send for ConcurrentPathTrie
impl Sync for ConcurrentPathTrie
Auto Trait Implementations§
impl !Freeze for ConcurrentPathTrie
impl !RefUnwindSafe for ConcurrentPathTrie
impl Unpin for ConcurrentPathTrie
impl !UnwindSafe for ConcurrentPathTrie
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more