uqa_storage_sqlite/inverted_index/
core.rs1use super::{
10 Analyzer, InvertedIndex, ManagedConnection, SQLiteInvertedIndex, StorageBackendResult,
11 DEFAULT_BLOCK_SIZE,
12};
13
14impl SQLiteInvertedIndex {
15 pub const BLOCK_SIZE: usize = DEFAULT_BLOCK_SIZE;
16
17 pub fn new(conn: ManagedConnection, table: impl Into<String>, analyzer: Analyzer) -> Self {
18 Self {
19 conn,
20 table: table.into(),
21 bindings: uqa_storage::inverted_index::AnalyzerBindings::new(analyzer),
22 }
23 }
24
25 pub fn tokenize(&self, text: &str, field: &str) -> StorageBackendResult<Vec<String>> {
27 Ok(self.bindings.index_revision(field)?.analyze(text)?)
28 }
29
30 pub fn skip_table_name(&self, field: &str) -> String {
31 format!("_skip_{}_{}", self.table, field)
32 }
33
34 pub fn blockmax_table_name(&self, field: &str) -> String {
35 format!("_blockmax_{}_{}", self.table, field)
36 }
37
38 pub fn flush_skip_pointers(&self) -> StorageBackendResult<()> {
39 let fields = self.field_names()?;
40 for field in fields {
41 self.rebuild_skip_pointers_for_field(&field)?;
42 }
43 Ok(())
44 }
45}