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

Method prepare_query

nodedb-vector/src/rerank/codecs/binary.rs:71–82  ·  view source on GitHub ↗

Prepare the query for repeated distance calls. Binary encodes both the query and candidates to sign bits and computes Hamming distance. The prepared form is `PreparedQuery::Bytes` holding the packed query bits.

(&self, q: &[f32])

Source from the content-addressed store, hash-verified

69 /// Hamming distance. The prepared form is `PreparedQuery::Bytes` holding
70 /// the packed query bits.
71 fn prepare_query(&self, q: &[f32]) -> Result<PreparedQuery, RerankError> {
72 if q.len() != self.dim {
73 return Err(RerankError::BadInput(format!(
74 "binary prepare_query: query len {} != codec dim {}",
75 q.len(),
76 self.dim
77 )));
78 }
79 use nodedb_codec::vector_quant::codec::VectorCodec as _;
80 let query_bits = self.codec.prepare_query(q);
81 Ok(PreparedQuery::Bytes(query_bits))
82 }
83
84 /// Compute Hamming distance from a prepared query to a binary-encoded
85 /// candidate.

Calls 1

lenMethod · 0.45