pub struct PqAdcTables { /* private fields */ }Expand description
Per-(query, metric) precomputed ADC lookup tables built from a
ProductQuantizer.
Build once with ProductQuantizer::build_query_tables, then
score many PqCodes against it via PqAdcTables::distance
without rebuilding the M × K table per call.
Row m of the internal table holds the distances from query
subvector q_m to each of the K centroids of codebook m,
packed row-major. For DistanceMetric::Euclidean the row holds
squared L2 values (so they sum decomposably across
subvectors); PqAdcTables::distance takes sqrt of the total
exactly once for Euclidean.
Implementations§
Source§impl PqAdcTables
impl PqAdcTables
Sourcepub fn distance(&self, code: &PqCode) -> Result<f32>
pub fn distance(&self, code: &PqCode) -> Result<f32>
Score a single PqCode against the prepared tables.
The returned value matches
Quantizer::distance for the
same (query, code, metric) — for DistanceMetric::Euclidean
the table holds squared L2 per subvector and this method
sqrts the sum exactly once; the other supported metrics
(DotProduct, Manhattan) sum directly.
§Errors
Returns IqdbError::DimensionMismatch if code was produced
by a ProductQuantizer with a different M or trained dim
— typically the same quantizer that built the tables.
Sourcepub fn metric(&self) -> DistanceMetric
pub fn metric(&self) -> DistanceMetric
The metric these tables were built for.
Sourcepub fn n_subvectors(&self) -> usize
pub fn n_subvectors(&self) -> usize
The number of subvectors M.
Sourcepub fn n_centroids(&self) -> usize
pub fn n_centroids(&self) -> usize
The number of centroids per subvector codebook K.
Trait Implementations§
Source§impl Clone for PqAdcTables
impl Clone for PqAdcTables
Source§fn clone(&self) -> PqAdcTables
fn clone(&self) -> PqAdcTables
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more