pub struct SemanticRoutingTable { /* private fields */ }Expand description
Routing table for semantic DHT
Implementations§
Source§impl SemanticRoutingTable
impl SemanticRoutingTable
Sourcepub fn new(config: SemanticDHTConfig) -> Self
pub fn new(config: SemanticDHTConfig) -> Self
Create a new semantic routing table
Sourcepub fn update_local_embedding(&self, embedding: Vec<f32>) -> Result<()>
pub fn update_local_embedding(&self, embedding: Vec<f32>) -> Result<()>
Update local peer’s embedding based on stored data
Sourcepub fn add_peer(&self, peer: SemanticPeer) -> Result<()>
pub fn add_peer(&self, peer: SemanticPeer) -> Result<()>
Add or update a peer in the routing table
Sourcepub fn remove_peer(&self, peer_id: &PeerId)
pub fn remove_peer(&self, peer_id: &PeerId)
Remove a peer from the routing table
Sourcepub fn find_nearest_peers(
&self,
embedding: &[f32],
k: usize,
) -> Vec<(PeerId, f32)>
pub fn find_nearest_peers( &self, embedding: &[f32], k: usize, ) -> Vec<(PeerId, f32)>
Find k nearest peers to a given embedding (greedy routing)
Sourcepub fn find_nearest_peers_balanced(
&self,
embedding: &[f32],
k: usize,
) -> Vec<(PeerId, f32)>
pub fn find_nearest_peers_balanced( &self, embedding: &[f32], k: usize, ) -> Vec<(PeerId, f32)>
Find k nearest peers with load balancing consideration
Sourcepub fn get_cluster_peers(&self, cluster_id: usize) -> Vec<PeerId>
pub fn get_cluster_peers(&self, cluster_id: usize) -> Vec<PeerId>
Get peers in a specific cluster
Sourcepub fn num_clusters(&self) -> usize
pub fn num_clusters(&self) -> usize
Get number of clusters
Sourcepub fn get_cached_route(&self, embedding: &[f32]) -> Option<Vec<PeerId>>
pub fn get_cached_route(&self, embedding: &[f32]) -> Option<Vec<PeerId>>
Check route cache for cached routing decision
Sourcepub fn cache_route(&self, embedding: &[f32], peers: Vec<PeerId>)
pub fn cache_route(&self, embedding: &[f32], peers: Vec<PeerId>)
Cache a routing decision for future queries
Sourcepub fn clear_route_cache(&self)
pub fn clear_route_cache(&self)
Clear the route cache (useful when network topology changes significantly)
Sourcepub fn route_cache_stats(&self) -> (usize, usize)
pub fn route_cache_stats(&self) -> (usize, usize)
Get route cache statistics
Sourcepub fn update_clusters(&self, num_clusters: usize) -> Result<()>
pub fn update_clusters(&self, num_clusters: usize) -> Result<()>
Update peer clusters using k-means clustering
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SemanticRoutingTable
impl !RefUnwindSafe for SemanticRoutingTable
impl Send for SemanticRoutingTable
impl Sync for SemanticRoutingTable
impl Unpin for SemanticRoutingTable
impl !UnwindSafe for SemanticRoutingTable
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.