pub struct PartialSyncManager { /* private fields */ }Expand description
Manages partial sync of HNSW graph changes between peers.
Wraps a DirtyRegionTracker and adds outbound delta bookkeeping so the
caller can detect when a peer has not yet acknowledged a delta.
Implementations§
Source§impl PartialSyncManager
impl PartialSyncManager
Sourcepub fn new(
max_dirty_nodes: usize,
max_pending: usize,
local_peer_id: impl Into<String>,
) -> Self
pub fn new( max_dirty_nodes: usize, max_pending: usize, local_peer_id: impl Into<String>, ) -> Self
Create a new manager.
max_dirty_nodes: denominator fordirty_ratio(forwarded to the innerDirtyRegionTracker).max_pending: maximum number of un-acked deltas held in memory.local_peer_id: identifier stamped onto outbound deltas.
Sourcepub fn record_change(&self, layer: usize, node_id: u64)
pub fn record_change(&self, layer: usize, node_id: u64)
Record that the vector for node_id in layer has changed.
Sourcepub fn build_delta<F>(
&self,
region: &EmbeddingRegion,
get_vector: F,
now_ms: u64,
) -> EmbeddingDelta
pub fn build_delta<F>( &self, region: &EmbeddingRegion, get_vector: F, now_ms: u64, ) -> EmbeddingDelta
Build a delta containing all dirty nodes that fall inside region.
get_vector is called for each dirty node ID to retrieve its current
embedding. If get_vector returns None for a node the node is
skipped (it may have been deleted).
Sourcepub fn build_all_deltas<F>(
&self,
get_vector: F,
now_ms: u64,
) -> Vec<EmbeddingDelta>
pub fn build_all_deltas<F>( &self, get_vector: F, now_ms: u64, ) -> Vec<EmbeddingDelta>
Build one delta per dirty layer, covering all dirty nodes in that layer.
get_vector receives (layer, node_id) and should return the current
embedding for that node, or None if the node no longer exists.
Layers with no dirty nodes are omitted from the result.
Sourcepub fn apply_delta(&self, delta: &EmbeddingDelta)
pub fn apply_delta(&self, delta: &EmbeddingDelta)
Apply an incoming delta from a peer.
Clears the local dirty status for all nodes mentioned in the delta (the peer has the authoritative version of those nodes).
Sourcepub fn push_pending(&self, delta: EmbeddingDelta) -> bool
pub fn push_pending(&self, delta: EmbeddingDelta) -> bool
Push a delta onto the pending list (waiting for peer acknowledgement).
Returns false when the pending list is already at capacity; the
caller should ack older deltas first.
Sourcepub fn ack_generation(&self, generation: u64) -> usize
pub fn ack_generation(&self, generation: u64) -> usize
Remove all pending deltas whose generation is ≤ generation.
Returns the number of deltas removed.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of pending (un-acked) deltas.
Sourcepub fn tracker(&self) -> &DirtyRegionTracker
pub fn tracker(&self) -> &DirtyRegionTracker
Access the underlying DirtyRegionTracker.
Sourcepub fn dirty_ratio(&self) -> f64
pub fn dirty_ratio(&self) -> f64
Convenience wrapper: dirty_ratio of the inner tracker.
Auto Trait Implementations§
impl !Freeze for PartialSyncManager
impl !RefUnwindSafe for PartialSyncManager
impl !UnwindSafe for PartialSyncManager
impl Send for PartialSyncManager
impl Sync for PartialSyncManager
impl Unpin for PartialSyncManager
impl UnsafeUnpin for PartialSyncManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.