(
&self,
lmdb: &MetaDb,
config: &Config,
_embeddings: &[Self::IndexingInput],
)
| 192 | } |
| 193 | |
| 194 | fn finalize_sampling( |
| 195 | &self, |
| 196 | lmdb: &MetaDb, |
| 197 | config: &Config, |
| 198 | _embeddings: &[Self::IndexingInput], |
| 199 | ) -> Result<(), WaCustomError> { |
| 200 | let values_count = self.sampling_data.values_collected.load(Ordering::Relaxed) as f32; |
| 201 | |
| 202 | let above_1_percent = |
| 203 | (self.sampling_data.above_1.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 204 | let above_2_percent = |
| 205 | (self.sampling_data.above_2.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 206 | let above_3_percent = |
| 207 | (self.sampling_data.above_3.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 208 | let above_4_percent = |
| 209 | (self.sampling_data.above_4.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 210 | let above_5_percent = |
| 211 | (self.sampling_data.above_5.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 212 | let above_6_percent = |
| 213 | (self.sampling_data.above_6.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 214 | let above_7_percent = |
| 215 | (self.sampling_data.above_7.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 216 | let above_8_percent = |
| 217 | (self.sampling_data.above_8.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 218 | let above_9_percent = |
| 219 | (self.sampling_data.above_9.load(Ordering::Relaxed) as f32 / values_count) * 100.0; |
| 220 | |
| 221 | let values_upper_bound = if above_1_percent <= config.indexing.clamp_margin_percent { |
| 222 | 1.0 |
| 223 | } else if above_2_percent <= config.indexing.clamp_margin_percent { |
| 224 | 2.0 |
| 225 | } else if above_3_percent <= config.indexing.clamp_margin_percent { |
| 226 | 3.0 |
| 227 | } else if above_4_percent <= config.indexing.clamp_margin_percent { |
| 228 | 4.0 |
| 229 | } else if above_5_percent <= config.indexing.clamp_margin_percent { |
| 230 | 5.0 |
| 231 | } else if above_6_percent <= config.indexing.clamp_margin_percent { |
| 232 | 6.0 |
| 233 | } else if above_7_percent <= config.indexing.clamp_margin_percent { |
| 234 | 7.0 |
| 235 | } else if above_8_percent <= config.indexing.clamp_margin_percent { |
| 236 | 8.0 |
| 237 | } else if above_9_percent <= config.indexing.clamp_margin_percent { |
| 238 | 9.0 |
| 239 | } else { |
| 240 | 10.0 |
| 241 | }; |
| 242 | |
| 243 | *self.values_upper_bound.write().unwrap() = values_upper_bound; |
| 244 | self.is_configured.store(true, Ordering::Release); |
| 245 | store_values_upper_bound(lmdb, values_upper_bound)?; |
| 246 | Ok(()) |
| 247 | } |
| 248 | |
| 249 | fn embeddings_collected(&self) -> &RwLock<Vec<Self::IndexingInput>> { |
| 250 | &self.vectors |
nothing calls this directly
no test coverage detected