pub struct HnswIndex {
pub params: HnswParams,
pub distance: DistanceMetric,
pub entry_point: Option<i64>,
pub top_layer: usize,
pub nodes: HashMap<i64, Node>,
/* private fields */
}Expand description
In-memory HNSW graph. See module docs for the model.
Fields§
§params: HnswParams§distance: DistanceMetric§entry_point: Option<i64>Node id of the entry point. None iff the index is empty.
At all times this is the id of the node with the highest
max-layer; if multiple nodes tie for the top layer, the
most-recently-promoted one wins.
top_layer: usizeHighest layer currently populated. 0 when the index has at most one node, grows as new nodes get assigned higher layers.
nodes: HashMap<i64, Node>Node id → its per-layer neighbor lists.
Implementations§
Source§impl HnswIndex
impl HnswIndex
Sourcepub fn new(distance: DistanceMetric, seed: u64) -> Self
pub fn new(distance: DistanceMetric, seed: u64) -> Self
Builds an empty HNSW index with default parameters and the given distance metric + RNG seed. A seed of 0 is mapped to a small nonzero constant — xorshift gets stuck at zero.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HnswIndex
impl RefUnwindSafe for HnswIndex
impl Send for HnswIndex
impl Sync for HnswIndex
impl Unpin for HnswIndex
impl UnsafeUnpin for HnswIndex
impl UnwindSafe for HnswIndex
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