mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-12 06:24:29 +01:00
Stop iterating through the whole list of points
We stop when there is no possible candidates left
This commit is contained in:
parent
cfc62a1c15
commit
91ce4d1721
@ -104,14 +104,18 @@ impl Criterion for Geo<'_> {
|
|||||||
|
|
||||||
fn geo_point(
|
fn geo_point(
|
||||||
rtree: &RTree<GeoPoint>,
|
rtree: &RTree<GeoPoint>,
|
||||||
candidates: RoaringBitmap,
|
mut candidates: RoaringBitmap,
|
||||||
point: [f64; 2],
|
point: [f64; 2],
|
||||||
) -> Box<dyn Iterator<Item = RoaringBitmap>> {
|
) -> Box<dyn Iterator<Item = RoaringBitmap>> {
|
||||||
let results = rtree
|
let mut results = Vec::new();
|
||||||
.nearest_neighbor_iter(&point)
|
for point in rtree.nearest_neighbor_iter(&point) {
|
||||||
.filter_map(move |point| candidates.contains(point.data).then(|| point.data))
|
if candidates.remove(point.data) {
|
||||||
.map(|id| iter::once(id).collect::<RoaringBitmap>())
|
results.push(std::iter::once(point.data).collect());
|
||||||
.collect::<Vec<_>>();
|
if candidates.is_empty() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Box::new(results.into_iter())
|
Box::new(results.into_iter())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user