pub struct SharedSubtreeManager {
pub shared_nodes: Arc<RwLock<HashMap<usize, SharedTreeNode>>>,
pub pattern_cache: Arc<RwLock<HashMap<SubtreePattern, usize>>>,
pub next_node_id: Arc<RwLock<usize>>,
pub config: SubtreeConfig,
}Expand description
Shared subtree manager for memory optimization
Fields§
Shared nodes indexed by ID
pattern_cache: Arc<RwLock<HashMap<SubtreePattern, usize>>>Pattern to shared node ID mapping
next_node_id: Arc<RwLock<usize>>Next available node ID
config: SubtreeConfigConfiguration for subtree sharing
Implementations§
pub fn new(config: SubtreeConfig) -> Self
Sourcepub fn extract_patterns(
&self,
tree_nodes: &[TreeNode],
) -> Result<Vec<SubtreePattern>>
pub fn extract_patterns( &self, tree_nodes: &[TreeNode], ) -> Result<Vec<SubtreePattern>>
Extract subtree patterns from a tree for potential sharing
Find or create a shared subtree for a given pattern
Sourcepub fn calculate_memory_savings(&self) -> Result<SubtreeSharingStats>
pub fn calculate_memory_savings(&self) -> Result<SubtreeSharingStats>
Calculate memory savings from subtree sharing
Trait Implementations§
Source§fn clone(&self) -> SharedSubtreeManager
fn clone(&self) -> SharedSubtreeManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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