Add some documentation for the Builder type
This commit is contained in:
parent
d3f07fcad1
commit
3feb763d92
|
@ -396,6 +396,7 @@ impl Default for Search {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parameters for building the `Hnsw`
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
ef_search: Option<usize>,
|
ef_search: Option<usize>,
|
||||||
|
@ -405,11 +406,16 @@ pub struct Builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Builder {
|
impl Builder {
|
||||||
|
/// Set the `efConstruction` parameter from the paper
|
||||||
pub fn ef_construction(mut self, ef_construction: usize) -> Self {
|
pub fn ef_construction(mut self, ef_construction: usize) -> Self {
|
||||||
self.ef_construction = Some(ef_construction);
|
self.ef_construction = Some(ef_construction);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the `ef` parameter from the paper
|
||||||
|
///
|
||||||
|
/// If the `efConstruction` parameter is not already set, it will be set
|
||||||
|
/// to the same value as `ef` by default.
|
||||||
pub fn ef(mut self, ef: usize) -> Self {
|
pub fn ef(mut self, ef: usize) -> Self {
|
||||||
self.ef_search = Some(ef);
|
self.ef_search = Some(ef);
|
||||||
if self.ef_construction.is_none() {
|
if self.ef_construction.is_none() {
|
||||||
|
@ -418,12 +424,14 @@ impl Builder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A `ProgressBar` to track `Hnsw` construction progress
|
||||||
#[cfg(feature = "indicatif")]
|
#[cfg(feature = "indicatif")]
|
||||||
pub fn progress(mut self, bar: ProgressBar) -> Self {
|
pub fn progress(mut self, bar: ProgressBar) -> Self {
|
||||||
self.progress = Some(bar);
|
self.progress = Some(bar);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Build the `Hnsw` with the given set of points
|
||||||
pub fn build<P: Point>(self, points: &[P]) -> (Hnsw<P>, Vec<PointId>) {
|
pub fn build<P: Point>(self, points: &[P]) -> (Hnsw<P>, Vec<PointId>) {
|
||||||
Hnsw::new(points, self)
|
Hnsw::new(points, self)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue