From aa69308e4555ede4f96f9068881524ff6b4988bb Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Thu, 12 Sep 2024 11:48:00 +0200 Subject: [PATCH] Use a bufWriter to build word FSTs --- milli/src/update/new/merger.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/milli/src/update/new/merger.rs b/milli/src/update/new/merger.rs index b38dc0865..22c4baf26 100644 --- a/milli/src/update/new/merger.rs +++ b/milli/src/update/new/merger.rs @@ -6,6 +6,7 @@ use heed::types::Bytes; use heed::{Database, RoTxn}; use memmap2::Mmap; use roaring::RoaringBitmap; +use std::io::BufWriter; use tempfile::tempfile; use super::channel::*; @@ -60,8 +61,8 @@ pub fn merge_grenad_entries( let span = tracing::trace_span!(target: "indexing::documents::merge", "word_docids"); let _entered = span.enter(); - let mut add_words_fst = SetBuilder::new(tempfile()?)?; - let mut del_words_fst = SetBuilder::new(tempfile()?)?; + let mut add_words_fst = SetBuilder::new(BufWriter::new(tempfile()?))?; + let mut del_words_fst = SetBuilder::new(BufWriter::new(tempfile()?))?; merge_and_send_docids( merger, @@ -153,16 +154,16 @@ pub fn merge_grenad_entries( } fn compute_new_words_fst( - add_words_fst: SetBuilder, - del_words_fst: SetBuilder, + add_words_fst: SetBuilder>, + del_words_fst: SetBuilder>, words_fst: Set>, ) -> Result { let add_words_fst_file = add_words_fst.into_inner()?; - let add_words_fst_mmap = unsafe { Mmap::map(&add_words_fst_file)? }; + let add_words_fst_mmap = unsafe { Mmap::map(&add_words_fst_file.into_inner().unwrap())? }; let add_words_fst = Set::new(&add_words_fst_mmap)?; let del_words_fst_file = del_words_fst.into_inner()?; - let del_words_fst_mmap = unsafe { Mmap::map(&del_words_fst_file)? }; + let del_words_fst_mmap = unsafe { Mmap::map(&del_words_fst_file.into_inner().unwrap())? }; let del_words_fst = Set::new(&del_words_fst_mmap)?; let diff = words_fst.op().add(&del_words_fst).difference();