| Crates.io | range_search |
| lib.rs | range_search |
| version | 0.1.0 |
| created_at | 2025-08-29 17:01:24.588809+00 |
| updated_at | 2025-08-29 17:01:24.588809+00 |
| description | An automaton that queries a finite state transducer for nearest neighbors. |
| homepage | https://github.com/aalekhpatel07/range_search |
| repository | https://github.com/aalekhpatel07/range_search |
| max_upload_size | |
| id | 1816179 |
| size | 20,708 |
An automaton to query for nearest neighbours of a byte vector (within a given distance) against an Fst that contains a population of byte vectors.
cargo add range_search
use range_search::RangeSearch;
use fst::{Automaton, set::{Set, SetBuilder}, IntoStreamer, Streamer};
fn main() {
// the vector we want to find neighbors for.
let query = [0x01; 144];
let aut = RangeSearch::<144>::new_l2(&query, 100_000.0).unwrap();
// Suppose you have some fst::Set of vectors.
let set = SetBuilder::memory().into_set();
// Iterate over the set of vectors close enough to the query vector.
let mut stream = set.search(aut).into_stream();
while let Some(hit) = stream.next() {
eprintln!("found a vector within the given range of the query vector {hit:#?}");
}
}
use range_search::RangeSearch;
use fst::{Automaton, set::{Set, SetBuilder}, IntoStreamer, Streamer};
fn main() {
// the 256-dimensional binary vector (packed into single bit per component) that we want to find neighbors for.
let query = [0x01; 32];
let aut = RangeSearch::<32>::new_hamming(&query, 5).unwrap();
// Suppose you have some fst::Set of vectors.
let set = SetBuilder::memory().into_set();
// Iterate over the set of vectors close enough to the query vector.
let mut stream = set.search(aut).into_stream();
while let Some(hit) = stream.next() {
eprintln!("found a vector within the given range of the query vector {hit:#?}");
}
}