Take ownership of points
This commit is contained in:
parent
9b4eae13e4
commit
d6b0171e7a
|
@ -41,7 +41,7 @@ impl Hnsw {
|
||||||
.map(FloatArray::try_from)
|
.map(FloatArray::try_from)
|
||||||
.collect::<Result<Vec<_>, PyErr>>()?;
|
.collect::<Result<Vec<_>, PyErr>>()?;
|
||||||
|
|
||||||
let (inner, ids) = instant_distance::Builder::from(config).build(&points);
|
let (inner, ids) = instant_distance::Builder::from(config).build(points);
|
||||||
let ids = Vec::from_iter(ids.into_iter().map(|pid| pid.into_inner()));
|
let ids = Vec::from_iter(ids.into_iter().map(|pid| pid.into_inner()));
|
||||||
Ok((Self { inner }, ids))
|
Ok((Self { inner }, ids))
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ fn build_heuristic(bench: &mut Bencher) {
|
||||||
.map(|_| Point(rng.gen(), rng.gen()))
|
.map(|_| Point(rng.gen(), rng.gen()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
bench.iter(|| Builder::default().seed(seed).build(&points))
|
bench.iter(|| Builder::default().seed(seed).build(points.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl Builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the `Hnsw` with the given set of points
|
/// 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: Vec<P>) -> (Hnsw<P>, Vec<PointId>) {
|
||||||
Hnsw::new(points, self)
|
Hnsw::new(points, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ where
|
||||||
Builder::default()
|
Builder::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(points: &[P], builder: Builder) -> (Self, Vec<PointId>) {
|
fn new(points: Vec<P>, builder: Builder) -> (Self, Vec<PointId>) {
|
||||||
let ef_search = builder.ef_search;
|
let ef_search = builder.ef_search;
|
||||||
let ef_construction = builder.ef_construction;
|
let ef_construction = builder.ef_construction;
|
||||||
let ml = builder.ml;
|
let ml = builder.ml;
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn randomized(builder: Builder) -> (u64, usize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (hnsw, pids) = builder.seed(seed).build(&points);
|
let (hnsw, pids) = builder.seed(seed).build(points);
|
||||||
let mut search = Search::default();
|
let mut search = Search::default();
|
||||||
let results = hnsw.search(&query, &mut search);
|
let results = hnsw.search(&query, &mut search);
|
||||||
assert!(results.len() >= 100);
|
assert!(results.len() >= 100);
|
||||||
|
|
Loading…
Reference in New Issue