From ce61cb7fe61bc2f877ec3c10d666690e626543e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 10 Jul 2024 10:11:44 +0200 Subject: [PATCH] Simplify and speedup an intersection pass --- milli/src/search/new/exact_attribute.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/milli/src/search/new/exact_attribute.rs b/milli/src/search/new/exact_attribute.rs index b013adfa0..269879ad6 100644 --- a/milli/src/search/new/exact_attribute.rs +++ b/milli/src/search/new/exact_attribute.rs @@ -193,7 +193,7 @@ impl State { let mut candidates_per_attribute = Vec::with_capacity(searchable_fields_ids.len()); // then check that there exists at least one attribute that has all of the terms for fid in searchable_fields_ids { - let mut intersection = MultiOps::intersection( + let intersection = MultiOps::intersection( words_positions .iter() .flat_map(|(words, ..)| words.iter()) @@ -201,12 +201,10 @@ impl State { .flatten() .map(|word| -> Result<_> { Ok(ctx - .get_db_word_fid_docids(Some(universe), *word, fid)? + .get_db_word_fid_docids(Some(&candidates), *word, fid)? .unwrap_or_default()) }), )?; - // TODO Why not doing this intersection in the MultiOps above? - intersection &= &candidates; if !intersection.is_empty() { // Although not really worth it in terms of performance, // if would be good to put this in cache for the sake of consistency