Struct aho_corasick::packed::teddy::builder::Builder

source ·
pub(crate) struct Builder {
    only_fat: Option<bool>,
    only_256bit: Option<bool>,
    heuristic_pattern_limits: bool,
}
Expand description

A builder for constructing a Teddy matcher.

The builder primarily permits fine grained configuration of the Teddy matcher. Most options are made only available for testing/benchmarking purposes. In reality, options are automatically determined by the nature and number of patterns given to the builder.

Fields§

§only_fat: Option<bool>

When none, this is automatically determined. Otherwise, false means slim Teddy is used (8 buckets) and true means fat Teddy is used (16 buckets). Fat Teddy requires AVX2, so if that CPU feature isn’t available and Fat Teddy was requested, no matcher will be built.

§only_256bit: Option<bool>

When none, this is automatically determined. Otherwise, false means that 128-bit vectors will be used (up to SSSE3 instructions) where as true means that 256-bit vectors will be used. As with fat, if 256-bit vectors are requested and they aren’t available, then a searcher will not be built.

§heuristic_pattern_limits: bool

When true (the default), the number of patterns will be used as a heuristic for refusing construction of a Teddy searcher. The point here is that too many patterns can overwhelm Teddy. But this can be disabled in cases where the caller knows better.

Implementations§

source§

impl Builder

source

pub(crate) fn new() -> Builder

Create a new builder for configuring a Teddy matcher.

source

pub(crate) fn build(&self, patterns: Arc<Patterns>) -> Option<Searcher>

Build a matcher for the set of patterns given. If a matcher could not be built, then None is returned.

Generally, a matcher isn’t built if the necessary CPU features aren’t available, an unsupported target or if the searcher is believed to be slower than standard techniques (i.e., if there are too many literals).

source

pub(crate) fn only_fat(&mut self, yes: Option<bool>) -> &mut Builder

Require the use of Fat (true) or Slim (false) Teddy. Fat Teddy uses 16 buckets where as Slim Teddy uses 8 buckets. More buckets are useful for a larger set of literals.

None is the default, which results in an automatic selection based on the number of literals and available CPU features.

source

pub(crate) fn only_256bit(&mut self, yes: Option<bool>) -> &mut Builder

Request the use of 256-bit vectors (true) or 128-bit vectors (false). Generally, a larger vector size is better since it either permits matching more patterns or matching more bytes in the haystack at once.

None is the default, which results in an automatic selection based on the number of literals and available CPU features.

source

pub(crate) fn heuristic_pattern_limits(&mut self, yes: bool) -> &mut Builder

Request that heuristic limitations on the number of patterns be employed. This useful to disable for benchmarking where one wants to explore how Teddy performs on large number of patterns even if the heuristics would otherwise refuse construction.

This is enabled by default.

source

fn build_imp(&self, patterns: Arc<Patterns>) -> Option<Searcher>

Trait Implementations§

source§

impl Clone for Builder

source§

fn clone(&self) -> Builder

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 Builder

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Builder

source§

fn default() -> Builder

Returns the “default value” for a type. 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> 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,

§

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

§

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

§

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.