MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / route

Method route

nodedb-vector/src/sieve/router.rs:43–73  ·  view source on GitHub ↗

Execute a filtered k-NN query. # Parameters - `query` — query vector. - `predicate_signature` — optional stable predicate; if present and a subindex exists for it, that subindex is used directly. - `allowed` — bitmap of allowed IDs for the NaviX fallback path. Ignored when a subindex is matched. - `k` — number of nearest neighbours to return. - `ef_se

(
        &self,
        query: &[f32],
        predicate_signature: Option<&PredicateSignature>,
        allowed: RoaringBitmap,
        k: usize,
        ef_search: usize,
        metric: DistanceMe

Source from the content-addressed store, hash-verified

41 ///
42 /// Up to `k` nearest-neighbour results, sorted by ascending distance.
43 pub fn route(
44 &self,
45 query: &[f32],
46 predicate_signature: Option<&PredicateSignature>,
47 allowed: RoaringBitmap,
48 k: usize,
49 ef_search: usize,
50 metric: DistanceMetric,
51 ) -> Vec<SearchResult> {
52 // Fast path: subindex hit.
53 if let Some(sig) = predicate_signature
54 && let Some(subindex) = self.collection.get(sig)
55 {
56 return subindex.search(query, k, ef_search);
57 }
58
59 // Slow path: NaviX adaptive-local filtered search on the global index.
60 let opts = NavixSearchOptions {
61 k,
62 ef_search,
63 allowed,
64 brute_force_threshold: 0.001,
65 };
66 navix_search(self.fallback, query, &opts, metric)
67 .into_iter()
68 .map(|r| SearchResult {
69 id: r.id,
70 distance: r.distance,
71 })
72 .collect()
73 }
74}
75
76#[cfg(test)]

Callers 9

route_hits_subindexFunction · 0.80
spawn_mock_kmsFunction · 0.80
spawn_mock_vaultFunction · 0.80
build_routerFunction · 0.80
stub_routerFunction · 0.80
runFunction · 0.80
runFunction · 0.80

Calls 4

navix_searchFunction · 0.85
collectMethod · 0.80
getMethod · 0.45
searchMethod · 0.45

Tested by 3

route_hits_subindexFunction · 0.64