Skip to main content

KeyValueInvertedIndex

Struct KeyValueInvertedIndex 

Source
pub struct KeyValueInvertedIndex { /* private fields */ }
Expand description

Inverted index implemented over KeyValueStore.

Implementations§

Source§

impl KeyValueInvertedIndex

Source

pub fn new( store: Arc<dyn KeyValueStore>, table: impl Into<String>, analyzer: Analyzer, ) -> Self

Trait Implementations§

Source§

impl Clone for KeyValueInvertedIndex

Source§

fn clone(&self) -> KeyValueInvertedIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl InvertedIndex for KeyValueInvertedIndex

Source§

fn visit_score_clusters( &self, field: &str, term: &TokenTermKey, after: Option<u64>, limit: usize, control: &StorageReadControl, visit: &mut ScoreClusterVisitor<'_>, ) -> StorageBackendResult<()>

Visit encoded score clusters in ascending order under the retained provider read. Temporary payloads must be reserved before fetching; callbacks must not reenter the provider.
Source§

fn get_occurrences_budgeted( &self, doc_id: DocId, field: &str, term: &TokenTermKey, control: &StorageReadControl, ) -> StorageBackendResult<Budgeted<Vec<TokenOccurrence>>>

Decode one document’s exact occurrences with provider-owned input and output reservations and cancellation checks.
Source§

fn field_stats_scalar_budgeted( &self, field: &str, control: &StorageReadControl, ) -> StorageBackendResult<IndexStats>

Read only field scoring scalars with producer-owned temporary reservations.
Source§

fn analyzer(&self) -> &Analyzer

Source§

fn source_rebuild_required(&self) -> StorageBackendResult<bool>

Whether persisted positional data must be rebuilt from original sources before this index can be read or mutated. The owning engine performs this after restoring exact analyzer revisions, in the same initial-open transaction.
Source§

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<()>

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.
Source§

fn remove_document(&mut self, doc_id: DocId) -> StorageBackendResult<()>

Source§

fn try_rebuild_documents( &mut self, documents: Vec<(DocId, BTreeMap<FieldName, String>)>, ) -> StorageBackendResult<()>

Source§

fn try_rebuild_documents_cancellable( &mut self, documents: Vec<(DocId, BTreeMap<FieldName, String>)>, cancellation: &CancellationToken, ) -> StorageBackendResult<()>

Rebuild under the caller’s cancellation token. Cancellation must retain the complete previous index; custom providers must implement atomic staging and cancellation.
Source§

fn clear(&mut self) -> StorageBackendResult<()>

Source§

fn get_posting_list( &self, field: &str, term: &str, ) -> StorageBackendResult<PostingList>

Source§

fn get_posting_list_key( &self, field: &str, term: &TokenTermKey, ) -> StorageBackendResult<PostingList>

Unique-position compatibility projection for an exact term key. Legacy providers accept scalar keys and reject unpaired UTF-16 explicitly.
Source§

fn posting_cursor( &self, field: &str, term: &str, ) -> StorageBackendResult<Box<dyn PostingCursor>>

Open a doc-id ordered score cursor for one term. Read more
Source§

fn posting_cursor_key( &self, field: &str, term: &TokenTermKey, ) -> StorageBackendResult<Box<dyn PostingCursor>>

Score cursor with exact term identity and occurrence frequency independent of unique positions.
Source§

fn get_occurrence_postings( &self, field: &str, term: &TokenTermKey, ) -> StorageBackendResult<Vec<OccurrencePosting>>

Complete graph edges in document order, preserving occurrence multiplicity and original source coordinates. Legacy positions cannot implement this contract without a source rebuild.
Source§

fn get_occurrences( &self, doc_id: DocId, field: &str, term: &TokenTermKey, ) -> StorageBackendResult<Vec<TokenOccurrence>>

Exact occurrences for one document and term; an absent document or term has no occurrences.
Source§

fn indexed_field_metadata( &self, doc_id: DocId, field: &str, ) -> StorageBackendResult<Option<IndexedFieldMetadata>>

Original stream-end state and revision metadata published with a document field, including fields that emitted no tokens.
Source§

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 uses posting support and the authoritative frequency accessor; persistent backends can stream compact frequency projections.
Source§

fn doc_freq(&self, field: &str, term: &str) -> StorageBackendResult<u64>

Source§

fn doc_freq_key( &self, field: &str, term: &TokenTermKey, ) -> StorageBackendResult<u64>

Source§

fn get_doc_length( &self, doc_id: DocId, field: &str, ) -> StorageBackendResult<u64>

Source§

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.
Source§

fn get_scoring_inputs_keys_bulk( &self, doc_ids: &[DocId], field: &str, terms: &[TokenTermKey], ) -> StorageBackendResult<Vec<(u64, Vec<u64>)>>

Exact-key scoring inputs aligned with both the document and query-term arrays, including repetitions.
Source§

fn get_term_freq( &self, doc_id: DocId, field: &str, term: &str, ) -> StorageBackendResult<u64>

Source§

fn get_term_freq_key( &self, doc_id: DocId, field: &str, term: &TokenTermKey, ) -> StorageBackendResult<u64>

Source§

fn doc_count(&self) -> StorageBackendResult<u64>

Source§

fn total_field_length(&self, field: &str) -> StorageBackendResult<u64>

Source§

fn field_doc_count(&self, field: &str) -> StorageBackendResult<u64>

Number of documents that have indexed content for field.
Source§

fn vocabulary_terms(&self, field: &str) -> StorageBackendResult<Vec<String>>

Sorted unique indexed terms for field. Read more
Source§

fn vocabulary_keys( &self, field: &str, ) -> StorageBackendResult<Vec<TokenTermKey>>

Sorted canonical term keys, including unpaired units. String-only vocabulary APIs must return an error if projection would lose identity.
Source§

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>

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>

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>

Number of distinct indexed terms. With field = Some(..), limits the count to one indexed field.
Source§

fn snapshot(&self) -> StorageBackendResult<Arc<dyn InvertedIndex>>

Read-only handle suitable for an ExecutionContext.
Source§

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>

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>

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

Index-time analyzer for field; falls back to InvertedIndex::analyzer when no override is set.
Source§

fn get_search_analyzer(&self, field: &str) -> Analyzer

Compatibility configuration for search. Built-in providers return their independent retained search revision’s inputs; this default preserves the index fallback for custom legacy providers. Use search_analyzer_revision for execution with exact resource ownership.
Source§

fn index_analyzer_revision( &self, field: &str, ) -> StorageBackendResult<Arc<CompiledAnalyzer>>

Retain the exact executable index revision. Built-in providers resolve their default once and keep field revisions immutable.
Source§

fn search_analyzer_revision( &self, field: &str, ) -> StorageBackendResult<Arc<CompiledAnalyzer>>

Retain the exact executable search revision independently of subsequent index assignments.
Source§

fn set_field_analyzer_revision( &mut self, field: &str, revision: Arc<CompiledAnalyzer>, phase: AnalyzerPhase, ) -> Result<(), String>

Install a validated revision without reopening its resources. This does not rebuild existing documents; graph providers reject a different index revision on a populated field and require rebuild_with_analyzer_revision instead.
Source§

fn set_field_analyzer_revisions( &mut self, field: &str, index: Arc<CompiledAnalyzer>, search: Arc<CompiledAnalyzer>, ) -> Result<(), String>

Install a complete retained pair atomically. Failure changes neither side; this does not rebuild existing postings.
Source§

fn rebuild_with_analyzer_revision( &mut self, field: &str, revision: Arc<CompiledAnalyzer>, phase: AnalyzerPhase, documents: Vec<(DocId, BTreeMap<FieldName, String>)>, ) -> StorageBackendResult<()>

Replace the complete indexed document set and selected analyzer sides together. Failure retains the previous postings and bindings; providers must implement their own atomic publication.
Source§

fn rebuild_with_analyzer_revision_cancellable( &mut self, field: &str, revision: Arc<CompiledAnalyzer>, phase: AnalyzerPhase, documents: Vec<(DocId, BTreeMap<FieldName, String>)>, cancellation: &CancellationToken, ) -> StorageBackendResult<()>

Replace postings and selected analyzer revisions together, retaining both on cancellation before publication.
Source§

fn try_add_document( &mut self, doc_id: DocId, fields: BTreeMap<FieldName, String>, ) -> StorageBackendResult<()>

Source§

fn try_remove_document(&mut self, doc_id: DocId) -> StorageBackendResult<()>

Source§

fn try_clear(&mut self) -> StorageBackendResult<()>

Source§

fn posting_read_cursor_key<'a>( &'a self, field: &'a str, term: &TokenTermKey, ) -> StorageBackendResult<Box<dyn PostingReadCursor + 'a>>

Traverse candidates while retaining this index read. Providers with borrowed posting maps can avoid copying the entire term support; owned persistent cursors keep their incremental reads.
Source§

fn posting_read_cursor_key_budgeted<'a>( &'a self, field: &'a str, term: &'a TokenTermKey, control: &StorageReadControl, ) -> StorageBackendResult<BudgetedPostingReadCursor<'a>>

Open a cursor that owns every query allocation under the supplied allowance. Providers must implement this capability without an unbounded materialization fallback.
Source§

fn get_posting_lists_bulk( &self, field: &str, terms: &[String], ) -> StorageBackendResult<Vec<PostingList>>

Source§

fn posting_cursors_bulk( &self, field: &str, terms: &[String], ) -> StorageBackendResult<Vec<Box<dyn PostingCursor>>>

Source§

fn posting_cursors_keys_bulk( &self, field: &str, terms: &[TokenTermKey], ) -> StorageBackendResult<Vec<Box<dyn PostingCursor>>>

Open exact-key cursors in input order, retaining repeated query terms. Scalar custom backends retain their optimized bulk implementation.
Source§

fn get_posting_lists_keys_bulk( &self, field: &str, terms: &[TokenTermKey], ) -> StorageBackendResult<Vec<PostingList>>

Read exact-key support without projecting UTF-16 term identity.
Source§

fn persisted_block_max_scores_keys_bulk( &self, field: &str, terms: &[TokenTermKey], scorer_fingerprint: &str, ) -> StorageBackendResult<Vec<Option<Vec<f64>>>>

Load exact-key scorer-versioned bounds. Custom scalar providers expose no raw-key materialization by default.
Source§

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 more
Source§

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>>>>

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_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 more
Source§

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>

InvertedIndex::field_stats without the vocabulary-wide document-frequency map. Read more
Source§

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>

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>

Document frequency of term across every indexed field.
Source§

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_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_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>

Total term frequency for a doc summed across every indexed field.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.