From da61408e529a7d92315b9c149e6a9cf320ef9860 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Tue, 3 Sep 2024 15:14:16 +0200 Subject: [PATCH] Remove unimplemented from document changes --- milli/src/update/new/document_change.rs | 22 +++++++++++++------ .../update/new/extract/extract_word_docids.rs | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/milli/src/update/new/document_change.rs b/milli/src/update/new/document_change.rs index 9076f32db..b4eb4d1d2 100644 --- a/milli/src/update/new/document_change.rs +++ b/milli/src/update/new/document_change.rs @@ -2,7 +2,7 @@ use heed::RoTxn; use obkv::KvReader; use crate::update::new::KvReaderFieldId; -use crate::{DocumentId, FieldId, Index}; +use crate::{DocumentId, FieldId, Index, Result}; pub enum DocumentChange { Deletion(Deletion), @@ -52,8 +52,12 @@ impl Deletion { self.docid } - pub fn current(&self, rtxn: &RoTxn, index: &Index) -> &KvReader { - unimplemented!() + pub fn current<'a>( + &self, + rtxn: &'a RoTxn, + index: &'a Index, + ) -> Result>> { + index.documents.get(rtxn, &self.docid).map_err(crate::Error::from) } } @@ -67,7 +71,7 @@ impl Insertion { } pub fn new(&self) -> &KvReader { - unimplemented!() + self.new.as_ref() } } @@ -85,11 +89,15 @@ impl Update { self.docid } - pub fn current(&self, rtxn: &RoTxn, index: &Index) -> &KvReader { - unimplemented!() + pub fn current<'a>( + &self, + rtxn: &'a RoTxn, + index: &'a Index, + ) -> Result>> { + index.documents.get(rtxn, &self.docid).map_err(crate::Error::from) } pub fn new(&self) -> &KvReader { - unimplemented!() + self.new.as_ref() } } diff --git a/milli/src/update/new/extract/extract_word_docids.rs b/milli/src/update/new/extract/extract_word_docids.rs index 1f52ee086..55f13f221 100644 --- a/milli/src/update/new/extract/extract_word_docids.rs +++ b/milli/src/update/new/extract/extract_word_docids.rs @@ -115,7 +115,7 @@ impl SearchableExtractor for WordDocidsExtractor { cached_sorter.insert_del_u32(word.as_bytes(), inner.docid()).unwrap(); }; document_tokenizer.tokenize_document( - inner.current(rtxn, index), + inner.current(rtxn, index)?.unwrap(), fields_ids_map, &mut token_fn, )?; @@ -125,7 +125,7 @@ impl SearchableExtractor for WordDocidsExtractor { cached_sorter.insert_del_u32(word.as_bytes(), inner.docid()).unwrap(); }; document_tokenizer.tokenize_document( - inner.current(rtxn, index), + inner.current(rtxn, index)?.unwrap(), fields_ids_map, &mut token_fn, )?;