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

Method prepare_query

nodedb-codec/src/vector_quant/rabitq.rs:313–327  ·  view source on GitHub ↗
(&self, q: &[f32])

Source from the content-addressed store, hash-verified

311 }
312
313 fn prepare_query(&self, q: &[f32]) -> Self::Query {
314 let dim = self.dim;
315 let residual: Vec<f32> = q
316 .iter()
317 .zip(self.centroid.iter())
318 .map(|(&qi, &ci)| qi - ci)
319 .collect();
320 let query_norm = residual.iter().map(|x| x * x).sum::<f32>().sqrt();
321 let rotated = self.apply_rotation(&residual);
322 let rotated_signs = sign_pack(&rotated, dim);
323 RaBitQQuery {
324 rotated_signs,
325 query_norm,
326 }
327 }
328
329 /// Symmetric distance estimate: both `q` and `v` are quantized.
330 ///

Callers 1

Calls 4

sign_packFunction · 0.85
collectMethod · 0.80
iterMethod · 0.45
apply_rotationMethod · 0.45

Tested by 1