Insert multiple vectors for a single document (ColBERT-style). All N vectors are bound to the same `document_surrogate`.
(
&mut self,
vectors: &[&[f32]],
document_surrogate: Surrogate,
)
| 30 | /// Insert multiple vectors for a single document (ColBERT-style). |
| 31 | /// All N vectors are bound to the same `document_surrogate`. |
| 32 | pub fn insert_multi_vector( |
| 33 | &mut self, |
| 34 | vectors: &[&[f32]], |
| 35 | document_surrogate: Surrogate, |
| 36 | ) -> Vec<u32> { |
| 37 | let mut ids = Vec::with_capacity(vectors.len()); |
| 38 | for &v in vectors { |
| 39 | let id = self.insert(v.to_vec()); |
| 40 | if document_surrogate != Surrogate::ZERO { |
| 41 | self.surrogate_map.insert(id, document_surrogate); |
| 42 | } |
| 43 | ids.push(id); |
| 44 | } |
| 45 | if document_surrogate != Surrogate::ZERO { |
| 46 | self.multi_doc_map.insert(document_surrogate, ids.clone()); |
| 47 | } |
| 48 | ids |
| 49 | } |
| 50 | |
| 51 | /// Delete all vectors belonging to a multi-vector document. |
| 52 | pub fn delete_multi_vector(&mut self, document_surrogate: Surrogate) -> usize { |