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