Struct hnsw::Hnsw [−][src]
Expand description
This provides a HNSW implementation for any distance function.
The type T
must implement space::Metric
to get implementations.
Implementations
Creates a new HNSW with a PRNG which is default seeded to produce deterministic behavior.
Creates a new HNSW with a default seeded PRNG and with the specified params.
Creates a HNSW with the passed params
and prng
.
Inserts a feature into the HNSW.
Does a k-NN search where q
is the query element and it attempts to put up to M
nearest neighbors into dest
.
ef
is the candidate pool size. ef
can be increased to get better recall at the expense of speed.
If ef
is less than dest.len()
then dest
will only be filled with ef
elements.
Returns a slice of the filled neighbors.
Extract the feature for a given item returned by [HNSW::nearest
].
The item
must be retrieved from [HNSW::search_layer
].
Extract the feature from a particular level for a given item returned by [HNSW::search_layer
].
Retrieve the item ID for a given layer item returned by [HNSW::search_layer
].
Performs the same algorithm as [HNSW::nearest
], but stops on a particular layer of the network
and returns the unique index on that layer rather than the item index.
If this is passed a level
of 0
, then this has the exact same functionality as [HNSW::nearest
]
since the unique indices at layer 0
are the item indices.
Trait Implementations
impl<'de, Met, T, R, const M: usize, const M0: usize> Deserialize<'de> for Hnsw<Met, T, R, M, M0> where
Met: Deserialize<'de>,
T: Deserialize<'de>,
R: Deserialize<'de>,
impl<'de, Met, T, R, const M: usize, const M0: usize> Deserialize<'de> for Hnsw<Met, T, R, M, M0> where
Met: Deserialize<'de>,
T: Deserialize<'de>,
R: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Get num
nearest neighbor points of target
. Read more
Auto Trait Implementations
impl<Met, T, R, const M: usize, const M0: usize> RefUnwindSafe for Hnsw<Met, T, R, M, M0> where
Met: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<Met, T, R, const M: usize, const M0: usize> Send for Hnsw<Met, T, R, M, M0> where
Met: Send,
R: Send,
T: Send,
impl<Met, T, R, const M: usize, const M0: usize> Sync for Hnsw<Met, T, R, M, M0> where
Met: Sync,
R: Sync,
T: Sync,
impl<Met, T, R, const M: usize, const M0: usize> Unpin for Hnsw<Met, T, R, M, M0> where
Met: Unpin,
R: Unpin,
T: Unpin,
impl<Met, T, R, const M: usize, const M0: usize> UnwindSafe for Hnsw<Met, T, R, M, M0> where
Met: UnwindSafe,
R: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more