From 63bfe1cee22fcd5c620e01edad3b75a8e0e97511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 27 Jun 2023 12:28:32 +0200 Subject: [PATCH] Ignore when there are too many vectors --- .../extract/extract_vector_points.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/milli/src/update/index_documents/extract/extract_vector_points.rs b/milli/src/update/index_documents/extract/extract_vector_points.rs index ddf25917c..0fad3be07 100644 --- a/milli/src/update/index_documents/extract/extract_vector_points.rs +++ b/milli/src/update/index_documents/extract/extract_vector_points.rs @@ -50,16 +50,12 @@ pub fn extract_vector_points( } }; - for (i, vector) in vectors.into_iter().enumerate() { - match u16::try_from(i) { - Ok(i) => { - let mut key = docid_bytes.to_vec(); - key.extend_from_slice(&i.to_ne_bytes()); - let bytes = cast_slice(&vector); - writer.insert(key, bytes)?; - } - Err(_) => continue, - } + for (i, vector) in vectors.into_iter().enumerate().take(u16::MAX as usize) { + let index = u16::try_from(i).unwrap(); + let mut key = docid_bytes.to_vec(); + key.extend_from_slice(&index.to_be_bytes()); + let bytes = cast_slice(&vector); + writer.insert(key, bytes)?; } } // else => the `_vectors` object was `null`, there is nothing to do