MCPcopy Create free account
hub / github.com/cosdata/cosdata / quantize

Method quantize

src/models/inverted_index.rs:168–172  ·  view source on GitHub ↗
(&self, value: f32, values_upper_bound: f32)

Source from the content-addressed store, hash-verified

166 }
167
168 pub fn quantize(&self, value: f32, values_upper_bound: f32) -> u8 {
169 let quantization = ((1u32 << self.quantization_bits) - 1) as u8;
170 let max_val = quantization as f32;
171 (((value / values_upper_bound) * max_val).clamp(0.0, max_val) as u8).min(quantization)
172 }
173
174 /// Inserts a value into the index at the specified dimension index.
175 /// Finds the quantized value and pushes the vec_Id in array at index = quantized_value

Callers 2

insertMethod · 0.45
deleteMethod · 0.45

Calls 1

minMethod · 0.80

Tested by

no test coverage detected