pub struct NodePool { /* private fields */ }
Expand description
线程安全的节点池封装
使用 Arc
实现快速克隆,内部使用不可变数据结构保证线程安全
Implementations§
Source§impl NodePool
impl NodePool
pub fn new(inner: Arc<Tree>) -> Arc<NodePool>
pub fn root(&self) -> Arc<Node>
pub fn root_id(&self) -> &Box<str>
pub fn get_inner(&self) -> &Arc<Tree>
pub fn get_parent_node(&self, id: &Box<str>) -> Option<Arc<Node>>
Sourcepub fn contains_node(&self, id: &Box<str>) -> bool
pub fn contains_node(&self, id: &Box<str>) -> bool
检查节点是否存在
Sourcepub fn children(
&self,
parent_id: &Box<str>,
) -> Option<GenericVector<Box<str>, ArcK>>
pub fn children( &self, parent_id: &Box<str>, ) -> Option<GenericVector<Box<str>, ArcK>>
获取直接子节点列表
pub fn for_each<F>(&self, id: &Box<str>, f: F)
Sourcepub fn validate_hierarchy(&self) -> Result<(), Error>
pub fn validate_hierarchy(&self) -> Result<(), Error>
验证父子关系一致性
Sourcepub fn filter_nodes<P>(&self, predicate: P) -> Vec<Arc<Node>>
pub fn filter_nodes<P>(&self, predicate: P) -> Vec<Arc<Node>>
根据类型筛选节点
Sourcepub fn get_subtree_size(&self, node_id: &Box<str>) -> usize
pub fn get_subtree_size(&self, node_id: &Box<str>) -> usize
Sourcepub fn get_lowest_common_ancestor(
&self,
node1_id: &Box<str>,
node2_id: &Box<str>,
) -> Option<Box<str>>
pub fn get_lowest_common_ancestor( &self, node1_id: &Box<str>, node2_id: &Box<str>, ) -> Option<Box<str>>
Sourcepub fn parallel_query<P>(&self, predicate: P) -> Vec<Arc<Node>>
pub fn parallel_query<P>(&self, predicate: P) -> Vec<Arc<Node>>
Sourcepub fn parallel_batch_query<'a, P>(
&'a self,
batch_size: usize,
predicate: P,
) -> Vec<Arc<Node>>
pub fn parallel_batch_query<'a, P>( &'a self, batch_size: usize, predicate: P, ) -> Vec<Arc<Node>>
Sourcepub fn parallel_query_map<'a, P, T, F>(
&'a self,
predicate: P,
transform: F,
) -> Vec<T>
pub fn parallel_query_map<'a, P, T, F>( &'a self, predicate: P, transform: F, ) -> Vec<T>
Source§impl NodePool
impl NodePool
Sourcepub fn optimized_query(
&self,
config: QueryCacheConfig,
) -> Result<OptimizedQueryEngine, Error>
pub fn optimized_query( &self, config: QueryCacheConfig, ) -> Result<OptimizedQueryEngine, Error>
创建优化查询引擎(带缓存)
Source§impl NodePool
impl NodePool
Sourcepub fn lazy_query(&self, config: LazyQueryConfig) -> LazyQueryEngine
pub fn lazy_query(&self, config: LazyQueryConfig) -> LazyQueryEngine
创建懒加载查询引擎
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NodePool
impl<'de> Deserialize<'de> for NodePool
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodePool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodePool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for NodePool
impl Serialize for NodePool
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for NodePool
Auto Trait Implementations§
impl Freeze for NodePool
impl RefUnwindSafe for NodePool
impl Send for NodePool
impl Sync for NodePool
impl Unpin for NodePool
impl UnwindSafe for NodePool
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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