Struct aho_corasick::util::prefilter::RareBytesBuilder

source ·
struct RareBytesBuilder {
    ascii_case_insensitive: bool,
    rare_set: ByteSet,
    byte_offsets: RareByteOffsets,
    available: bool,
    count: usize,
    rank_sum: u16,
}
Expand description

A builder for constructing a rare byte prefilter.

A rare byte prefilter attempts to pick out a small set of rare bytes that occurr in the patterns, and then quickly scan to matches of those rare bytes.

Fields§

§ascii_case_insensitive: bool

Whether this prefilter should account for ASCII case insensitivity or not.

§rare_set: ByteSet

A set of rare bytes, indexed by byte value.

§byte_offsets: RareByteOffsets

A set of byte offsets associated with bytes in a pattern. An entry corresponds to a particular bytes (its index) and is only non-zero if the byte occurred at an offset greater than 0 in at least one pattern.

If a byte’s offset is not representable in 8 bits, then the rare bytes prefilter becomes inert.

§available: bool

Whether this is available as a prefilter or not. This can be set to false during construction if a condition is seen that invalidates the use of the rare-byte prefilter.

§count: usize

The number of bytes set to an active value in byte_offsets.

§rank_sum: u16

The sum of frequency ranks for the rare bytes detected. This is intended to give a heuristic notion of how rare the bytes are.

Implementations§

source§

impl RareBytesBuilder

source

fn new() -> RareBytesBuilder

Create a new builder for constructing a rare byte prefilter.

source

fn ascii_case_insensitive(self, yes: bool) -> RareBytesBuilder

Enable ASCII case insensitivity. When set, byte strings added to this builder will be interpreted without respect to ASCII case.

source

fn build(&self) -> Option<Prefilter>

Build the rare bytes prefilter.

If there are more than 3 distinct rare bytes found, or if heuristics otherwise determine that this prefilter should not be used, then None is returned.

source

fn add(&mut self, bytes: &[u8])

Add a byte string to this builder.

All patterns added to an Aho-Corasick automaton should be added to this builder before attempting to construct the prefilter.

source

fn set_offset(&mut self, pos: usize, byte: u8)

source

fn add_rare_byte(&mut self, byte: u8)

source

fn add_one_rare_byte(&mut self, byte: u8)

Trait Implementations§

source§

impl Clone for RareBytesBuilder

source§

fn clone(&self) -> RareBytesBuilder

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for RareBytesBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.