Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTree searches: return iterator for nearest neighbor search #90

Open
kylebarron opened this issue Jan 2, 2025 · 0 comments
Open

RTree searches: return iterator for nearest neighbor search #90

kylebarron opened this issue Jan 2, 2025 · 0 comments

Comments

@kylebarron
Copy link
Owner

Right now, our nearest neighbors implementation returns a materialized vec of all values that are within max_distance and max_results, but instead it would be cleaner to just return an iterator. I.e. this loop:

// pop items from the queue
while !queue.is_empty() && queue.peek().is_some_and(|val| (val.0.id & 1) != 0) {
let dist = queue.peek().unwrap().0.dist;
if dist > max_dist_squared {
break 'outer;
}
let item = queue.pop().unwrap();
results.push(item.0.id >> 1);
if max_results.is_some_and(|max_results| results.len() == max_results) {
break 'outer;
}
}

that results.push(item.0.id >> 1); should yield instead of return.

@kylebarron kylebarron changed the title RTree searches: return iterator RTree searches: return iterator for nearest neighbor search Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant