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

Function build_search_hit

nodedb/src/data/executor/handlers/vector_search.rs:22–37  ·  view source on GitHub ↗

Build a search hit from raw search result data. `id` is the bound surrogate when present, else the local node id (so headless rows still round-trip).

(
    collection: Option<&VectorCollection>,
    local_id: u32,
    distance: f32,
)

Source from the content-addressed store, hash-verified

20/// surrogate when present, else the local node id (so headless rows
21/// still round-trip).
22pub(super) fn build_search_hit(
23 collection: Option<&VectorCollection>,
24 local_id: u32,
25 distance: f32,
26) -> super::super::response_codec::VectorSearchHit {
27 let id = collection
28 .and_then(|c| c.get_surrogate(local_id))
29 .map(|s| s.as_u32())
30 .unwrap_or(local_id);
31 super::super::response_codec::VectorSearchHit {
32 id,
33 distance,
34 doc_id: None,
35 body: None,
36 }
37}
38
39/// Translate a `SurrogateBitmap` (keyed by global surrogate IDs) into a
40/// `RoaringBitmap` keyed by the collection's global vector IDs.

Callers 3

execute_vector_searchMethod · 0.85
search_ivfMethod · 0.85

Calls 2

get_surrogateMethod · 0.45
as_u32Method · 0.45

Tested by

no test coverage detected