Skip to main content

PredicatedScorer

Struct PredicatedScorer 

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

Source§

impl<'a> PredicatedScorer<'a>

Source

pub fn new( driver: Box<dyn Scorer + 'a>, predicates: Vec<DocPredicate<'a>>, must_verifiers: Vec<Box<dyn Scorer + 'a>>, must_not_verifiers: Vec<Box<dyn Scorer + 'a>>, ) -> Self

Trait Implementations§

Source§

impl DocSet for PredicatedScorer<'_>

Source§

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)

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

Current document ID, or TERMINATED if exhausted.
Source§

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

Seek to the first document >= target. Returns doc ID or TERMINATED.
Source§

fn size_hint(&self) -> u32

Estimated number of remaining documents.
Source§

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

Consume up to 128 exact sorted matches starting at doc(), leaving the cursor on the first unconsumed match. Zero means exhausted.
Source§

fn retain_doc_batch(&mut self, docs: &mut DocBatch, len: usize) -> usize

Retain matches from the sorted unique prefix docs[..len]. The cursor remains at or beyond the last probe; earlier IDs stay consumed.
Source§

impl Scorer for PredicatedScorer<'_>

Source§

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

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

Replace a bounded window of exact scores and membership. Only advertised through supports_score_windows when it is beneficial.
Source§

fn score(&self) -> Score

Score for current document
Source§

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

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

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

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

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>

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

Whether compact exact-score batches amortize this scorer’s work.
Source§

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

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

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

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

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

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>

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

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 more

Auto 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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more