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

Method distance_prepared

nodedb-vector/src/rerank/sidecar.rs:136–145  ·  view source on GitHub ↗

Compute distance from a prepared query to the encoded vector at `id`. Returns `Ok(None)` when the id isn't in the sidecar (lost / not yet encoded); returns the distance otherwise.

(
        &self,
        prepared: &PreparedQuery,
        id: u32,
    )

Source from the content-addressed store, hash-verified

134 /// Returns `Ok(None)` when the id isn't in the sidecar (lost / not yet
135 /// encoded); returns the distance otherwise.
136 pub fn distance_prepared(
137 &self,
138 prepared: &PreparedQuery,
139 id: u32,
140 ) -> Result<Option<f32>, RerankError> {
141 match self.encoded.get(&id) {
142 None => Ok(None),
143 Some(bytes) => self.codec.distance_prepared(prepared, bytes).map(Some),
144 }
145 }
146}
147
148fn codec_name_to_u8(name: CodecName) -> u8 {

Calls 4

collectMethod · 0.80
getMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45