pub struct SQLiteInvertedIndex { /* private fields */ }Implementations§
Source§impl SQLiteInvertedIndex
impl SQLiteInvertedIndex
Sourcepub fn skip_to(
&self,
field: &str,
term: &str,
target_doc_id: DocId,
) -> StorageBackendResult<(DocId, usize)>
pub fn skip_to( &self, field: &str, term: &str, target_doc_id: DocId, ) -> StorageBackendResult<(DocId, usize)>
Read the nearest materialized skip pointer without mutating storage.
Call Self::flush_skip_pointers from an explicit maintenance/write
boundary after postings change.
pub fn build_block_max_scores<S: BlockMaxScorer + ?Sized>( &self, field: &str, term: &str, scorer: &S, ) -> StorageBackendResult<()>
Sourcepub fn build_block_max_scores_versioned<S: BlockMaxScorer + ?Sized>(
&self,
field: &str,
term: &str,
scorer: &S,
scorer_fingerprint: &str,
) -> StorageBackendResult<()>
pub fn build_block_max_scores_versioned<S: BlockMaxScorer + ?Sized>( &self, field: &str, term: &str, scorer: &S, scorer_fingerprint: &str, ) -> StorageBackendResult<()>
Build one scorer-versioned block-max posting. The version is checked on load so changed BM25 parameters or field statistics can never feed an unsafe pruning bound.
pub fn build_all_block_max_scores<S: BlockMaxScorer + ?Sized>( &self, field: &str, scorer: &S, ) -> StorageBackendResult<()>
pub fn get_block_max_score( &self, field: &str, term: &str, block_idx: usize, ) -> StorageBackendResult<f64>
pub fn get_all_block_max_scores( &self, field: &str, term: &str, ) -> StorageBackendResult<Vec<f64>>
pub fn get_versioned_block_max_scores( &self, field: &str, term: &str, scorer_fingerprint: &str, ) -> StorageBackendResult<Option<Vec<f64>>>
pub fn get_versioned_block_max_scores_bulk( &self, field: &str, terms: &[String], scorer_fingerprint: &str, ) -> StorageBackendResult<Vec<Option<Vec<f64>>>>
pub fn load_block_max_into( &self, target: &mut BlockMaxIndex, ) -> StorageBackendResult<()>
Source§impl SQLiteInvertedIndex
impl SQLiteInvertedIndex
pub const BLOCK_SIZE: usize = DEFAULT_BLOCK_SIZE
pub fn new( conn: ManagedConnection, table: impl Into<String>, analyzer: Analyzer, ) -> Self
Sourcepub fn tokenize(
&self,
text: &str,
field: &str,
) -> StorageBackendResult<Vec<String>>
pub fn tokenize( &self, text: &str, field: &str, ) -> StorageBackendResult<Vec<String>>
Tokenize text with the analyzer bound to field.
pub fn skip_table_name(&self, field: &str) -> String
pub fn blockmax_table_name(&self, field: &str) -> String
pub fn flush_skip_pointers(&self) -> StorageBackendResult<()>
Trait Implementations§
Source§impl Clone for SQLiteInvertedIndex
impl Clone for SQLiteInvertedIndex
Source§fn clone(&self) -> SQLiteInvertedIndex
fn clone(&self) -> SQLiteInvertedIndex
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl InvertedIndex for SQLiteInvertedIndex
impl InvertedIndex for SQLiteInvertedIndex
fn analyzer(&self) -> &Analyzer
fn add_document( &mut self, doc_id: DocId, fields: BTreeMap<FieldName, String>, ) -> StorageBackendResult<()>
Source§fn try_add_documents(
&mut self,
documents: Vec<(DocId, BTreeMap<FieldName, String>)>,
) -> StorageBackendResult<()>
fn try_add_documents( &mut self, documents: Vec<(DocId, BTreeMap<FieldName, String>)>, ) -> StorageBackendResult<()>
Add or replace several documents in input order. The default preserves the point-mutation contract for custom backends; transactional persistent backends can override this to make the call atomic and coalesce writes that share physical posting clusters.
fn remove_document(&mut self, doc_id: DocId) -> StorageBackendResult<()>
fn clear(&mut self) -> StorageBackendResult<()>
fn try_rebuild_documents( &mut self, documents: Vec<(DocId, BTreeMap<FieldName, String>)>, ) -> StorageBackendResult<()>
fn get_posting_list( &self, field: &str, term: &str, ) -> StorageBackendResult<PostingList>
fn get_posting_lists_bulk( &self, field: &str, terms: &[String], ) -> StorageBackendResult<Vec<PostingList>>
Source§fn posting_cursor(
&self,
field: &str,
term: &str,
) -> StorageBackendResult<Box<dyn PostingCursor>>
fn posting_cursor( &self, field: &str, term: &str, ) -> StorageBackendResult<Box<dyn PostingCursor>>
Open a doc-id ordered score cursor for one term. Read more
fn posting_cursors_bulk( &self, field: &str, terms: &[String], ) -> StorageBackendResult<Vec<Box<dyn PostingCursor>>>
Source§fn rebuild_persisted_block_max(
&mut self,
field: &str,
scorer: &dyn BlockMaxScorer,
scorer_fingerprint: &str,
) -> StorageBackendResult<bool>
fn rebuild_persisted_block_max( &mut self, field: &str, scorer: &dyn BlockMaxScorer, scorer_fingerprint: &str, ) -> StorageBackendResult<bool>
Persist scorer-specific block maxima for every term in
field. Read moreSource§fn persisted_block_max_scores(
&self,
field: &str,
term: &str,
scorer_fingerprint: &str,
) -> StorageBackendResult<Option<Vec<f64>>>
fn persisted_block_max_scores( &self, field: &str, term: &str, scorer_fingerprint: &str, ) -> StorageBackendResult<Option<Vec<f64>>>
Load scorer-versioned block maxima for one posting list.
None means
the backend has no complete, valid materialization for this scorer.Source§fn persisted_block_max_scores_bulk(
&self,
field: &str,
terms: &[String],
scorer_fingerprint: &str,
) -> StorageBackendResult<Vec<Option<Vec<f64>>>>
fn persisted_block_max_scores_bulk( &self, field: &str, terms: &[String], scorer_fingerprint: &str, ) -> StorageBackendResult<Vec<Option<Vec<f64>>>>
Load scorer-versioned block maxima for several terms while preserving input order; persistent backends override this to avoid one storage round trip per term.
Source§fn for_each_term_freq(
&self,
field: &str,
term: &str,
visit: &mut dyn FnMut(DocId, u64),
) -> StorageBackendResult<()>
fn for_each_term_freq( &self, field: &str, term: &str, visit: &mut dyn FnMut(DocId, u64), ) -> StorageBackendResult<()>
Visit
(doc_id, term_frequency) pairs without requiring callers to
materialize or decode payload details they do not use. The default
keeps every backend compatible through the posting-list contract;
persistent backends can stream compact frequency projections.fn doc_freq(&self, field: &str, term: &str) -> StorageBackendResult<u64>
fn get_doc_length( &self, doc_id: DocId, field: &str, ) -> StorageBackendResult<u64>
Source§fn get_doc_lengths_bulk(
&self,
doc_ids: &[DocId],
field: &str,
) -> StorageBackendResult<BTreeMap<DocId, u64>>
fn get_doc_lengths_bulk( &self, doc_ids: &[DocId], field: &str, ) -> StorageBackendResult<BTreeMap<DocId, u64>>
Bulk doc-length lookup. Default falls back to per-id calls.
Source§fn get_scoring_inputs_bulk(
&self,
doc_ids: &[DocId],
field: &str,
terms: &[String],
) -> StorageBackendResult<Vec<(u64, Vec<u64>)>>
fn get_scoring_inputs_bulk( &self, doc_ids: &[DocId], field: &str, terms: &[String], ) -> StorageBackendResult<Vec<(u64, Vec<u64>)>>
Fetch the document length and one term frequency per query term for
every requested document. Results stay aligned with
doc_ids.
Persistent backends override this to collapse the scoring loop’s
per-document point reads into a small number of set-oriented queries.fn get_term_freq( &self, doc_id: DocId, field: &str, term: &str, ) -> StorageBackendResult<u64>
fn doc_count(&self) -> StorageBackendResult<u64>
fn total_field_length(&self, field: &str) -> StorageBackendResult<u64>
Source§fn vocabulary_terms(&self, field: &str) -> StorageBackendResult<Vec<String>>
fn vocabulary_terms(&self, field: &str) -> StorageBackendResult<Vec<String>>
Sorted unique indexed terms for
field. Read moreSource§fn stats(&self) -> StorageBackendResult<IndexStats>
fn stats(&self) -> StorageBackendResult<IndexStats>
Fully-populated
IndexStats snapshot for the cost model and
scoring layer. Implementations may cache this between mutations.Source§fn posting_count(&self, field: Option<&str>) -> StorageBackendResult<u64>
fn posting_count(&self, field: Option<&str>) -> StorageBackendResult<u64>
Number of posting rows. With
field = Some(..), limits the count
to one indexed field.Source§fn doc_length_count(&self, field: Option<&str>) -> StorageBackendResult<u64>
fn doc_length_count(&self, field: Option<&str>) -> StorageBackendResult<u64>
Number of
(doc_id, field) length rows. With field = Some(..),
this is the number of documents indexed for that field.Source§fn term_count(&self, field: Option<&str>) -> StorageBackendResult<u64>
fn term_count(&self, field: Option<&str>) -> StorageBackendResult<u64>
Number of distinct indexed terms. With
field = Some(..), limits
the count to one indexed field.Source§fn snapshot(&self) -> StorageBackendResult<Arc<dyn InvertedIndex>>
fn snapshot(&self) -> StorageBackendResult<Arc<dyn InvertedIndex>>
Read-only handle suitable for an
ExecutionContext.Source§fn field_names(&self) -> StorageBackendResult<Vec<FieldName>>
fn field_names(&self) -> StorageBackendResult<Vec<FieldName>>
Names of every field with at least one indexed document.
Default implementation walks the
IndexStats snapshot’s
total-length map. Backends with a richer schema can override.Source§fn set_field_analyzer(
&mut self,
field: &str,
analyzer: Analyzer,
phase: AnalyzerPhase,
) -> Result<(), String>
fn set_field_analyzer( &mut self, field: &str, analyzer: Analyzer, phase: AnalyzerPhase, ) -> Result<(), String>
Bind an analyzer to a single field for the given phase.
Both writes to both the index-side and search-side maps; the
default impl errors so backends that don’t support per-field
analyzers fail loud rather than silently dropping the request.Source§fn remove_field_analyzers(&mut self, field: &str) -> Result<(), String>
fn remove_field_analyzers(&mut self, field: &str) -> Result<(), String>
Remove every per-field analyzer override for
field. This is the
inverse of set_field_analyzer(..., Both) and is required when the
final logical FTS index for a field is dropped. The default errors so
a backend cannot silently retain stale analysis behavior.Source§fn get_field_analyzer(&self, field: &str) -> Analyzer
fn get_field_analyzer(&self, field: &str) -> Analyzer
Index-time analyzer for
field; falls back to
InvertedIndex::analyzer when no override is set.Source§fn get_search_analyzer(&self, field: &str) -> Analyzer
fn get_search_analyzer(&self, field: &str) -> Analyzer
Search-time analyzer for
field; falls back to the index-time analyzer,
then to the default.fn try_add_document( &mut self, doc_id: DocId, fields: BTreeMap<FieldName, String>, ) -> StorageBackendResult<()>
fn try_remove_document(&mut self, doc_id: DocId) -> StorageBackendResult<()>
fn try_clear(&mut self) -> StorageBackendResult<()>
Source§fn for_each_posting(
&self,
field: &str,
term: &str,
visit: &mut dyn FnMut(&PostingEntry),
) -> StorageBackendResult<()>
fn for_each_posting( &self, field: &str, term: &str, visit: &mut dyn FnMut(&PostingEntry), ) -> StorageBackendResult<()>
Visit every posting entry for
(field, term) in ascending
doc-id order without handing out an owned list. Read moreSource§fn field_doc_count(&self, field: &str) -> StorageBackendResult<u64>
fn field_doc_count(&self, field: &str) -> StorageBackendResult<u64>
Number of documents that have indexed content for
field.Source§fn field_stats(&self, field: &str) -> StorageBackendResult<IndexStats>
fn field_stats(&self, field: &str) -> StorageBackendResult<IndexStats>
Field-specific statistics for BM25 scoring. Read more
Source§fn field_stats_scalar(&self, field: &str) -> StorageBackendResult<IndexStats>
fn field_stats_scalar(&self, field: &str) -> StorageBackendResult<IndexStats>
InvertedIndex::field_stats without the vocabulary-wide
document-frequency map. Read moreSource§fn writable_snapshot(&self) -> StorageBackendResult<Box<dyn InvertedIndex>>
fn writable_snapshot(&self) -> StorageBackendResult<Box<dyn InvertedIndex>>
Independent writable copy used to restore an in-memory engine
transaction without reconstructing analyzer state from documents.
Source§fn get_posting_list_any_field(
&self,
term: &str,
) -> StorageBackendResult<PostingList>
fn get_posting_list_any_field( &self, term: &str, ) -> StorageBackendResult<PostingList>
Posting list for
term across every indexed field, unioned
together. Default implementation sums per-field posting lists
via PostingList::merge_union.Source§fn doc_freq_any_field(&self, term: &str) -> StorageBackendResult<u64>
fn doc_freq_any_field(&self, term: &str) -> StorageBackendResult<u64>
Document frequency of
term across every indexed field.Source§fn get_total_doc_length(&self, doc_id: DocId) -> StorageBackendResult<u64>
fn get_total_doc_length(&self, doc_id: DocId) -> StorageBackendResult<u64>
Sum of all per-field token lengths for a single doc.
Source§fn get_term_freqs_bulk(
&self,
doc_ids: &[DocId],
field: &str,
term: &str,
) -> StorageBackendResult<BTreeMap<DocId, u64>>
fn get_term_freqs_bulk( &self, doc_ids: &[DocId], field: &str, term: &str, ) -> StorageBackendResult<BTreeMap<DocId, u64>>
Bulk term-frequency lookup. Default falls back to per-id calls.
Source§fn get_total_term_freq(
&self,
doc_id: DocId,
term: &str,
) -> StorageBackendResult<u64>
fn get_total_term_freq( &self, doc_id: DocId, term: &str, ) -> StorageBackendResult<u64>
Total term frequency for a doc summed across every indexed
field.
Auto Trait Implementations§
impl !RefUnwindSafe for SQLiteInvertedIndex
impl !UnwindSafe for SQLiteInvertedIndex
impl Freeze for SQLiteInvertedIndex
impl Send for SQLiteInvertedIndex
impl Sync for SQLiteInvertedIndex
impl Unpin for SQLiteInvertedIndex
impl UnsafeUnpin for SQLiteInvertedIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more