pub struct PredicatedScorer<'a> { /* private fields */ }Expand description
Wraps a driving Scorer with filter conditions pushed down.
Used by the query planner to flip iteration order: the SHOULD scorer drives and MUST/MUST_NOT clauses are checked per-doc via:
- O(1) predicate closures (e.g., fast-field range checks)
- seek()-based verifier scorers (e.g., TermQuery posting list lookups)
Verifier scorers contribute their actual per-doc score (e.g., BM25).
Implementations§
Trait Implementations§
Source§impl DocSet for PredicatedScorer<'_>
impl DocSet for PredicatedScorer<'_>
Source§fn supports_doc_windows(&self) -> bool
fn supports_doc_windows(&self) -> bool
Whether this cursor benefits from bounded score-free membership batches.
Source§fn fill_doc_window(&mut self, base: DocId, bits: &mut DocWindow)
fn fill_doc_window(&mut self, base: DocId, bits: &mut DocWindow)
Consume exact matches in
[base, base + DOC_WINDOW_SIZE), replacing
bits, and leave the cursor on its first match at or after the end.
Calls are forward-only; previously consumed documents stay consumed.Source§fn doc(&self) -> DocId
fn doc(&self) -> DocId
Current document ID, or
TERMINATED if exhausted.Source§fn advance(&mut self) -> DocId
fn advance(&mut self) -> DocId
Advance to the next document. Returns the new doc ID or
TERMINATED.Source§fn seek(&mut self, target: DocId) -> DocId
fn seek(&mut self, target: DocId) -> DocId
Seek to the first document >=
target. Returns doc ID or TERMINATED.Source§fn supports_doc_batches(&self) -> bool
fn supports_doc_batches(&self) -> bool
Whether compact membership batches amortize this cursor’s work.
Source§fn fill_doc_batch(&mut self, docs: &mut DocBatch) -> usize
fn fill_doc_batch(&mut self, docs: &mut DocBatch) -> usize
Consume up to 128 exact sorted matches starting at doc(), leaving
the cursor on the first unconsumed match. Zero means exhausted.
Source§impl Scorer for PredicatedScorer<'_>
impl Scorer for PredicatedScorer<'_>
Source§fn supports_filtered_windows(&self) -> bool
fn supports_filtered_windows(&self) -> bool
Whether this scorer’s batches remain useful when every match
needs a predicate check. Composite scorers can amortize child
traversal; leaf bitmap production alone may cost more than a
scalar pass once filtering visits every set bit again.
Source§fn supports_score_windows(&self) -> bool
fn supports_score_windows(&self) -> bool
Whether score-only collection benefits from bounded score windows.
Positions still require ordinary per-document collection.
Source§fn fill_score_window(
&mut self,
base: DocId,
scores: &mut [Score; 4096],
bits: &mut DocWindow,
)
fn fill_score_window( &mut self, base: DocId, scores: &mut [Score; 4096], bits: &mut DocWindow, )
Replace a bounded window of exact scores and membership. Only
advertised through
supports_score_windows when it is beneficial.Source§fn matched_positions(&self) -> Option<MatchedPositions>
fn matched_positions(&self) -> Option<MatchedPositions>
Get matched positions for the current document (if available)
Returns (field_id, positions) pairs where positions are encoded as per PositionMode
Source§fn supports_candidate_score_bounds(&self) -> bool
fn supports_candidate_score_bounds(&self) -> bool
Opt into final-score bounds before candidate confirmation.
Only a top-level ranked collector may use this to omit matches;
complete collectors and enclosing scorers retain exact traversal.
Source§fn candidate_score_upper_bound(&self) -> Score
fn candidate_score_upper_bound(&self) -> Score
Conservative upper bound on
score() if the current candidate
confirms. Must include floating-point rounding and use this
scorer’s final score space. The default never excludes a score.Source§fn candidate_block_upper_bound(&mut self) -> Option<(DocId, Score)>
fn candidate_block_upper_bound(&mut self) -> Option<(DocId, Score)>
Conservative final-score bound through an inclusive physical doc ID.
The interval starts at the current candidate. Only a top-level ranked
collector may skip it; exact/nested traversal stays unchanged.
Returning None opts out for the remaining traversal. A skipped
interval is left through seek_candidate, including deadline checks.
Source§fn advance_competitive_candidate(
&mut self,
_minimum: Score,
_allow_equal: bool,
) -> DocId
fn advance_competitive_candidate( &mut self, _minimum: Score, _allow_equal: bool, ) -> DocId
Advance while optionally omitting candidates whose final-score bound
cannot compete with
minimum. Only top-level ranked collection
may call this. allow_equal = false certifies that every remaining
stable ID loses an equal-score tie against the full local heap.Source§fn seed_ranked_score(&mut self, _limit: usize) -> Option<Score>
fn seed_ranked_score(&mut self, _limit: usize) -> Option<Score>
Optionally prove a lower bound on the kth best score using
distinct real matches. Restore the current candidate unless
cancelled. Emit no sampled hits; normal traversal still owns them.
Only top-level ranked collection may use this hint. Equality
remains competitive until its own heap resolves stable-ID ties.
Source§fn supports_score_batches(&self) -> bool
fn supports_score_batches(&self) -> bool
Whether compact exact-score batches amortize this scorer’s work.
Source§fn fill_score_batch(
&mut self,
docs: &mut DocBatch,
scores: &mut ScoreBatch,
) -> usize
fn fill_score_batch( &mut self, docs: &mut DocBatch, scores: &mut ScoreBatch, ) -> usize
Consume a sorted exact prefix, leaving the first unconsumed match.
Scores correspond to docs[..returned_len]; zero means exhausted.
Source§fn score_batch_matches(
&mut self,
docs: &DocBatch,
len: usize,
scores: &mut ScoreBatch,
matches: &mut ScoreBatchMask,
)
fn score_batch_matches( &mut self, docs: &DocBatch, len: usize, scores: &mut ScoreBatch, matches: &mut ScoreBatchMask, )
Probe sorted unique docs[..len] without changing their order.
Set membership bits index the input and its exact final scores.
The cursor remains at or beyond the last probe.
Source§fn accumulate_score_window(
&mut self,
base: DocId,
scores: &mut [Score; 4096],
bits: &mut DocWindow,
)
fn accumulate_score_window( &mut self, base: DocId, scores: &mut [Score; 4096], bits: &mut DocWindow, )
Add each exact match’s final score in a forward-only document window.
Existing values and membership bits are retained. A nested scorer
contributes its complete score once, preserving its summation order.
The cursor ends at the first match after the interval. Previously
consumed matches stay consumed, just as with
fill_doc_window.Source§fn advance_candidate(&mut self) -> DocId
fn advance_candidate(&mut self) -> DocId
Move to the next candidate for a two-phase conjunction. Candidates
may be false positives: the caller must call
confirm_candidate
before consuming scores or positions. Ordinary DocSet traversal
remains exact, including after candidate traversal. The default
simply advances the exact stream.Source§fn seek_candidate(&mut self, target: DocId) -> DocId
fn seek_candidate(&mut self, target: DocId) -> DocId
Seek a candidate at or beyond
target, without skipping any
possible exact match. See advance_candidate for the protocol.Source§fn confirm_candidate(&mut self) -> bool
fn confirm_candidate(&mut self) -> bool
Exactly verify the current candidate without advancing it.
Repeated calls must agree unless cancellation ends the stream.
Only a true result permits consuming its score/positions.
Source§fn exact_ranked_count(&self) -> Option<u64>
fn exact_ranked_count(&self) -> Option<u64>
Exact cardinality supplied only for an explicit top-level ranked
count request. Ordinary streams and ranked scorers return None.
Source§fn precomputed_top_k(
&mut self,
limit: usize,
collect_positions: bool,
) -> Option<(Vec<SearchResult>, u32)>
fn precomputed_top_k( &mut self, limit: usize, collect_positions: bool, ) -> Option<(Vec<SearchResult>, u32)>
Standalone fast path for scorers that wrap an already ranked
top-k list (text and vector executors). When this query is the top-level
query of a segment search, the caller may take the ranked list
directly instead of walking the DocSet and re-collecting it:
the result must be exactly what a
TopKCollector of size
limit would produce (score desc, doc id asc, total_seen). Read moreAuto Trait Implementations§
impl<'a> !RefUnwindSafe for PredicatedScorer<'a>
impl<'a> !UnwindSafe for PredicatedScorer<'a>
impl<'a> Freeze for PredicatedScorer<'a>
impl<'a> Send for PredicatedScorer<'a>
impl<'a> Sync for PredicatedScorer<'a>
impl<'a> Unpin for PredicatedScorer<'a>
impl<'a> UnsafeUnpin for PredicatedScorer<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more