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
impl RareBytesBuilder
sourcefn new() -> RareBytesBuilder
fn new() -> RareBytesBuilder
Create a new builder for constructing a rare byte prefilter.
sourcefn ascii_case_insensitive(self, yes: bool) -> RareBytesBuilder
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.
sourcefn build(&self) -> Option<Prefilter>
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.
sourcefn add(&mut self, bytes: &[u8])
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.
fn set_offset(&mut self, pos: usize, byte: u8)
fn add_rare_byte(&mut self, byte: u8)
fn add_one_rare_byte(&mut self, byte: u8)
Trait Implementations§
source§impl Clone for RareBytesBuilder
impl Clone for RareBytesBuilder
source§fn clone(&self) -> RareBytesBuilder
fn clone(&self) -> RareBytesBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more