From 11ea5acff94b70ab0181010a277c663630b5d1d4 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Tue, 19 Sep 2023 18:29:21 +0200 Subject: [PATCH] Fix --- .../extract/extract_word_docids.rs | 2 +- .../extract_word_pair_proximity_docids.rs | 32 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/milli/src/update/index_documents/extract/extract_word_docids.rs b/milli/src/update/index_documents/extract/extract_word_docids.rs index 8c72ba48a..84c6f8635 100644 --- a/milli/src/update/index_documents/extract/extract_word_docids.rs +++ b/milli/src/update/index_documents/extract/extract_word_docids.rs @@ -73,7 +73,7 @@ pub fn extract_word_docids( while let Some((key, value)) = cursor.move_on_next()? { let (document_id_bytes, fid_bytes) = try_split_array_at(key) .ok_or(SerializationError::Decoding { db_name: Some(DOCID_WORD_POSITIONS) })?; - let (fid_bytes, _) = try_split_array_at(key) + let (fid_bytes, _) = try_split_array_at(fid_bytes) .ok_or(SerializationError::Decoding { db_name: Some(DOCID_WORD_POSITIONS) })?; let document_id = u32::from_be_bytes(document_id_bytes); fid = u16::from_be_bytes(fid_bytes); diff --git a/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs b/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs index 41604ff4a..6373d5822 100644 --- a/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs +++ b/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs @@ -47,25 +47,25 @@ pub fn extract_word_pair_proximity_docids( .ok_or(SerializationError::Decoding { db_name: Some(DOCID_WORD_POSITIONS) })?; let document_id = u32::from_be_bytes(document_id_bytes); - for (position, word) in KvReaderU16::new(&value).iter() { - // if we change document, we fill the sorter - if current_document_id.map_or(false, |id| id != document_id) { - while !word_positions.is_empty() { - word_positions_into_word_pair_proximity( - &mut word_positions, - &mut word_pair_proximity, - )?; - } - - document_word_positions_into_sorter( - document_id, - &word_pair_proximity, - &mut word_pair_proximity_docids_sorter, + // if we change document, we fill the sorter + if current_document_id.map_or(false, |id| id != document_id) { + while !word_positions.is_empty() { + word_positions_into_word_pair_proximity( + &mut word_positions, + &mut word_pair_proximity, )?; - word_pair_proximity.clear(); - word_positions.clear(); } + document_word_positions_into_sorter( + document_id, + &word_pair_proximity, + &mut word_pair_proximity_docids_sorter, + )?; + word_pair_proximity.clear(); + word_positions.clear(); + } + + for (position, word) in KvReaderU16::new(&value).iter() { // drain the proximity window until the head word is considered close to the word we are inserting. while word_positions.get(0).map_or(false, |(_w, p)| { positions_proximity(*p as u32, position as u32) > MAX_DISTANCE