Ignore when there are too many vectors

This commit is contained in:
Clément Renault 2023-06-27 12:28:32 +02:00
parent f3e4d70638
commit 63bfe1cee2
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -50,16 +50,12 @@ pub fn extract_vector_points<R: io::Read + io::Seek>(
}
};
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