From 6ca84a61fad2126f64c93a910de0855c13db8040 Mon Sep 17 00:00:00 2001 From: trinity Pointard Date: Wed, 8 Jan 2025 16:19:54 +0100 Subject: [PATCH] make termdict always clone --- src/termdict/fst_termdict/term_info_store.rs | 1 + src/termdict/fst_termdict/termdict.rs | 6 ++++-- src/termdict/mod.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/termdict/fst_termdict/term_info_store.rs b/src/termdict/fst_termdict/term_info_store.rs index 0ad3a9d35a..1768c94118 100644 --- a/src/termdict/fst_termdict/term_info_store.rs +++ b/src/termdict/fst_termdict/term_info_store.rs @@ -93,6 +93,7 @@ impl TermInfoBlockMeta { } } +#[derive(Clone)] pub struct TermInfoStore { num_terms: usize, block_meta_bytes: OwnedBytes, diff --git a/src/termdict/fst_termdict/termdict.rs b/src/termdict/fst_termdict/termdict.rs index 23ed3606d4..fb3352d044 100644 --- a/src/termdict/fst_termdict/termdict.rs +++ b/src/termdict/fst_termdict/termdict.rs @@ -1,4 +1,5 @@ use std::io::{self, Write}; +use std::sync::Arc; use common::{BinarySerializable, CountingWriter}; use once_cell::sync::Lazy; @@ -113,8 +114,9 @@ static EMPTY_TERM_DICT_FILE: Lazy = Lazy::new(|| { /// The `Fst` crate is used to associate terms to their /// respective `TermOrdinal`. The `TermInfoStore` then makes it /// possible to fetch the associated `TermInfo`. +#[derive(Clone)] pub struct TermDictionary { - fst_index: tantivy_fst::Map, + fst_index: Arc>, term_info_store: TermInfoStore, } @@ -136,7 +138,7 @@ impl TermDictionary { let fst_index = open_fst_index(fst_file_slice)?; let term_info_store = TermInfoStore::open(values_file_slice)?; Ok(TermDictionary { - fst_index, + fst_index: Arc::new(fst_index), term_info_store, }) } diff --git a/src/termdict/mod.rs b/src/termdict/mod.rs index 3051492547..7153881251 100644 --- a/src/termdict/mod.rs +++ b/src/termdict/mod.rs @@ -74,7 +74,7 @@ const CURRENT_TYPE: DictionaryType = DictionaryType::SSTable; // TODO in the future this should become an enum of supported dictionaries /// A TermDictionary wrapping either an FST based dictionary or a SSTable based one. -#[cfg_attr(feature = "quickwit", derive(Clone))] +#[derive(Clone)] pub struct TermDictionary(InnerTermDict); impl TermDictionary {