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

Method prepare_query

nodedb-vector/src/quantize/pq_codec.rs:91–100  ·  view source on GitHub ↗

Prepare the query by precomputing the M×K asymmetric distance table. The `VectorCodec` trait does not propagate errors. A `PqCodec` used via this trait path is created by `PqCodec::train` which sets no governor; `build_distance_table` therefore always returns `Ok` here. If a governor is attached and its budget is exhausted the caller that constructed the codec is responsible for handling the err

(&self, q: &[f32])

Source from the content-addressed store, hash-verified

89 /// panics with a descriptive message so the budget violation is never
90 /// silently ignored.
91 fn prepare_query(&self, q: &[f32]) -> Self::Query {
92 let distance_table = self.build_distance_table(q).expect(
93 "PqCodec::prepare_query: build_distance_table failed; \
94 if a governor is attached ensure it has sufficient budget",
95 );
96 PqQuery {
97 distance_table,
98 raw: q.to_vec(),
99 }
100 }
101
102 /// Build the `AdcLut` from the precomputed distance table for use by
103 /// SIMD rerank kernels (`pshufb` / `vpermb`).

Calls 3

build_distance_tableMethod · 0.80
expectMethod · 0.45
to_vecMethod · 0.45