ConcurrentPathTrie

Struct ConcurrentPathTrie 

Source
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

Source

pub fn new() -> Self

Create a new empty concurrent trie

Source

pub fn current_epoch(&self) -> u64

Get current epoch

Source

pub fn advance_epoch(&self) -> u64

Advance epoch (call periodically to allow GC)

Source

pub fn begin_read(&self) -> ReadGuard<'_>

Begin a read operation (returns epoch guard) The guard must be held for the duration of the read

Source

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

Source

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

Source

pub fn resolve_with_type(&self, path: &str) -> Option<(ColumnId, ColumnType)>

Resolve with type information (lock-free)

Source

pub fn prefix_match(&self, prefix: &str) -> Vec<(String, ColumnId)>

Get all paths that start with a prefix (lock-free)

Source

pub fn total_columns(&self) -> u32

Get total number of columns

Source

pub fn total_nodes(&self) -> usize

Get total number of nodes (memory usage indicator)

Source

pub fn update_min_reader_epoch(&self)

Update minimum reader epoch (call after readers complete)

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConcurrentPathTrie

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for ConcurrentPathTrie

Source§

impl Sync for ConcurrentPathTrie

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.