Skip to content

Commit

Permalink
make termdict always clone
Browse files Browse the repository at this point in the history
  • Loading branch information
trinity-1686a committed Jan 8, 2025
1 parent 037d12c commit 6ca84a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/termdict/fst_termdict/term_info_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl TermInfoBlockMeta {
}
}

#[derive(Clone)]
pub struct TermInfoStore {
num_terms: usize,
block_meta_bytes: OwnedBytes,
Expand Down
6 changes: 4 additions & 2 deletions src/termdict/fst_termdict/termdict.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::io::{self, Write};
use std::sync::Arc;

use common::{BinarySerializable, CountingWriter};
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -113,8 +114,9 @@ static EMPTY_TERM_DICT_FILE: Lazy<FileSlice> = 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<OwnedBytes>,
fst_index: Arc<tantivy_fst::Map<OwnedBytes>>,
term_info_store: TermInfoStore,
}

Expand All @@ -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,
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/termdict/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6ca84a6

Please sign in to comment.