pub struct ApproxFilter {
pub trigrams: Vec<u64>,
pub min_required: usize,
}Expand description
Sound trigram filter for an approximate-regex query.
Fields§
§trigrams: Vec<u64>Distinct pattern trigram hashes, sorted ascending. Empty means the pattern has no extractable literal runs (no filter possible).
min_required: usizeMinimum number of Self::trigrams that must appear in
any matching doc. Always <= trigrams.len(). When zero
the filter degenerates to “no constraint” and the
caller must full-scan.
Implementations§
Source§impl ApproxFilter
impl ApproxFilter
Sourcepub fn build(ast: &Ast, k: u16) -> Self
pub fn build(ast: &Ast, k: u16) -> Self
Build the filter for a regex AST allowing up to k
edit operations.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Whether the filter imposes any constraint. A degenerate
filter (no required trigrams or min_required == 0)
passes every doc and the caller should full-scan.
Sourcepub fn candidates(&self, postings: &Postings) -> Vec<u32>
pub fn candidates(&self, postings: &Postings) -> Vec<u32>
Compute the candidate doc-id set for the filter.
The strategy is the postings UNION of every pattern
trigram. Any doc that contains at least one pattern
trigram is in the union; any doc with
min_required >= 1 must be in the union; this is
therefore a sound upper bound. Per-doc bloom filtering
is applied separately by the index in a tighter inner
loop that already has the doc record in hand.
The output is the surviving doc ids in ascending order.
Sourcepub fn passes(&self, bloom: &BloomFilter) -> bool
pub fn passes(&self, bloom: &BloomFilter) -> bool
Test the filter against a per-doc bloom filter.
Returns true if the doc may match the pattern under
the configured edit budget; false if the pattern
imposes more required-trigram constraints than the doc
can plausibly satisfy.
Trait Implementations§
Source§impl Clone for ApproxFilter
impl Clone for ApproxFilter
Source§fn clone(&self) -> ApproxFilter
fn clone(&self) -> ApproxFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ApproxFilter
impl RefUnwindSafe for ApproxFilter
impl Send for ApproxFilter
impl Sync for ApproxFilter
impl Unpin for ApproxFilter
impl UnsafeUnpin for ApproxFilter
impl UnwindSafe for ApproxFilter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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