pub struct ProbabilisticRouter { /* private fields */ }Expand description
Probabilistic routing layer for HNSW search.
Implementations§
Source§impl ProbabilisticRouter
impl ProbabilisticRouter
Sourcepub fn new(config: ProbabilisticRoutingConfig) -> Self
pub fn new(config: ProbabilisticRoutingConfig) -> Self
Create a new probabilistic router.
Sourcepub fn filter_neighbors<'a>(
&mut self,
query: &[f32],
current_pos: &[f32],
current_best_dist: f32,
neighbors: &'a [(u32, &[f32])],
) -> Vec<(u32, &'a [f32], f32)>
pub fn filter_neighbors<'a>( &mut self, query: &[f32], current_pos: &[f32], current_best_dist: f32, neighbors: &'a [(u32, &[f32])], ) -> Vec<(u32, &'a [f32], f32)>
Filter neighbors to test based on probability.
Returns indices of neighbors that should be tested.
Sourcepub fn search(
&mut self,
query: &[f32],
entry_point: u32,
entry_pos: &[f32],
get_neighbors: impl Fn(u32) -> Vec<(u32, Vec<f32>)>,
ef: usize,
) -> Vec<(u32, f32)>
pub fn search( &mut self, query: &[f32], entry_point: u32, entry_pos: &[f32], get_neighbors: impl Fn(u32) -> Vec<(u32, Vec<f32>)>, ef: usize, ) -> Vec<(u32, f32)>
Perform probabilistic beam search.
This is a search implementation that uses probabilistic routing internally.
Sourcepub fn stats(&self) -> &ProbabilisticStats
pub fn stats(&self) -> &ProbabilisticStats
Get statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProbabilisticRouter
impl RefUnwindSafe for ProbabilisticRouter
impl Send for ProbabilisticRouter
impl Sync for ProbabilisticRouter
impl Unpin for ProbabilisticRouter
impl UnsafeUnpin for ProbabilisticRouter
impl UnwindSafe for ProbabilisticRouter
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