| 308 | /// Adds a sparse vector to the index. |
| 309 | #[allow(unused)] |
| 310 | pub fn add_sparse_vector( |
| 311 | &self, |
| 312 | vector: SparseVector, |
| 313 | version: VersionNumber, |
| 314 | values_upper_bound: f32, |
| 315 | ) -> Result<(), BufIoError> { |
| 316 | let vector_id = vector.vector_id; |
| 317 | vector |
| 318 | .entries |
| 319 | .par_iter() |
| 320 | .map(|(dim_index, value)| { |
| 321 | if *value != 0.0 { |
| 322 | return self.insert(*dim_index, *value, vector_id, version, values_upper_bound); |
| 323 | } |
| 324 | Ok(()) |
| 325 | }) |
| 326 | .collect() |
| 327 | } |
| 328 | |
| 329 | pub fn serialize(&self) -> Result<(), BufIoError> { |
| 330 | let cursor = self.cache.dim_bufman.open_cursor()?; |