From 5bef2f4d860976d70e6a6560c1469445dbc501a8 Mon Sep 17 00:00:00 2001 From: nnethercott Date: Mon, 15 Sep 2025 16:10:56 +0200 Subject: [PATCH] Update arroy-hannoy conversion internals --- crates/milli/src/vector/store.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/milli/src/vector/store.rs b/crates/milli/src/vector/store.rs index d4d3f26cb..667d6b37d 100644 --- a/crates/milli/src/vector/store.rs +++ b/crates/milli/src/vector/store.rs @@ -1046,6 +1046,10 @@ impl VectorStore { where R: rand::Rng + rand::SeedableRng, { + // No work if distances are the same + if AD::name() == HD::name() { + return Ok(()); + } for index in vector_store_range_for_embedder(self.embedder_index) { let arroy_reader: arroy::Reader = match arroy::Reader::open(arroy_rtxn, index, self.database.remap_types()) { @@ -1084,6 +1088,10 @@ impl VectorStore { where R: rand::Rng + rand::SeedableRng, { + // No work if distances are the same + if AD::name() == HD::name() { + return Ok(()); + } for index in vector_store_range_for_embedder(self.embedder_index) { let hannoy_reader: hannoy::Reader = match hannoy::Reader::open(hannoy_rtxn, index, self.database.remap_types()) { @@ -1098,12 +1106,8 @@ impl VectorStore { arroy_writer.clear(arroy_wtxn)?; for entry in hannoy_reader.iter(hannoy_rtxn)? { let (item, mut vector) = entry?; - // hannoy bug? the `vector` here can be longer than `dimensions`. - // workaround: truncating. - if vector.len() > dimensions { - vector.truncate(dimensions); - } - // arroy and hannoy disagreement over the 0 value + debug_assert!(vector.len() == dimensions); + // arroy and hannoy disagreement over the 0 value if distance is Hamming // - arroy does: // - if x >= 0 => 1 // - if x < 0 => -1