Struct aho_corasick::packed::teddy::generic::Mask

source ·
struct Mask<V> {
    lo: V,
    hi: V,
}
Expand description

A vector generic mask for the low and high nybbles in a set of patterns. Each 8-bit lane j in a vector corresponds to a bitset where the ith bit is set if and only if the nybble j is in the bucket i at a particular position.

This is slightly tweaked dependending on whether Slim or Fat Teddy is being used. For Slim Teddy, the bitsets in the lower half are the same as the bitsets in the higher half, so that we can search V::BYTES bytes at a time. (Remember, the nybbles in the haystack are used as indices into these masks, and 256-bit shuffles only operate on 128-bit lanes.)

For Fat Teddy, the bitsets are not repeated, but instead, the high half bits correspond to an addition 8 buckets. So that a bitset 00100010 has buckets 1 and 5 set if it’s in the lower half, but has buckets 9 and 13 set if it’s in the higher half.

Fields§

§lo: V§hi: V

Implementations§

source§

impl<V: Vector> Mask<V>

source

unsafe fn members1(chunk: V, masks: [Mask<V>; 1]) -> V

Return a candidate for Teddy (fat or slim) that is searching for 1-byte candidates.

If a candidate is returned, it will be a collection of 8-bit bitsets (one bitset per lane), where the ith bit is set in the jth lane if and only if the byte occurring at the jth lane in chunk is in the bucket i. If no candidate is found, then the vector returned will have all lanes set to zero.

chunk should correspond to a V::BYTES window of the haystack (where the least significant byte corresponds to the start of the window). For fat Teddy, the haystack window length should be V::BYTES / 2, with the window repeated in each half of the vector.

mask1 should correspond to a low/high mask for the first byte of all patterns that are being searched.

source

unsafe fn members2(chunk: V, masks: [Mask<V>; 2]) -> (V, V)

Return a candidate for Teddy (fat or slim) that is searching for 2-byte candidates.

If candidates are returned, each will be a collection of 8-bit bitsets (one bitset per lane), where the ith bit is set in the jth lane if and only if the byte occurring at the jth lane in chunk is in the bucket i. Each candidate returned corresponds to the first and second bytes of the patterns being searched. If no candidate is found, then all of the lanes will be set to zero in at least one of the vectors returned.

chunk should correspond to a V::BYTES window of the haystack (where the least significant byte corresponds to the start of the window). For fat Teddy, the haystack window length should be V::BYTES / 2, with the window repeated in each half of the vector.

The masks should correspond to the masks computed for the first and second bytes of all patterns that are being searched.

source

unsafe fn members3(chunk: V, masks: [Mask<V>; 3]) -> (V, V, V)

Return a candidate for Teddy (fat or slim) that is searching for 3-byte candidates.

If candidates are returned, each will be a collection of 8-bit bitsets (one bitset per lane), where the ith bit is set in the jth lane if and only if the byte occurring at the jth lane in chunk is in the bucket i. Each candidate returned corresponds to the first, second and third bytes of the patterns being searched. If no candidate is found, then all of the lanes will be set to zero in at least one of the vectors returned.

chunk should correspond to a V::BYTES window of the haystack (where the least significant byte corresponds to the start of the window). For fat Teddy, the haystack window length should be V::BYTES / 2, with the window repeated in each half of the vector.

The masks should correspond to the masks computed for the first, second and third bytes of all patterns that are being searched.

source

unsafe fn members4(chunk: V, masks: [Mask<V>; 4]) -> (V, V, V, V)

Return a candidate for Teddy (fat or slim) that is searching for 4-byte candidates.

If candidates are returned, each will be a collection of 8-bit bitsets (one bitset per lane), where the ith bit is set in the jth lane if and only if the byte occurring at the jth lane in chunk is in the bucket i. Each candidate returned corresponds to the first, second, third and fourth bytes of the patterns being searched. If no candidate is found, then all of the lanes will be set to zero in at least one of the vectors returned.

chunk should correspond to a V::BYTES window of the haystack (where the least significant byte corresponds to the start of the window). For fat Teddy, the haystack window length should be V::BYTES / 2, with the window repeated in each half of the vector.

The masks should correspond to the masks computed for the first, second, third and fourth bytes of all patterns that are being searched.

Trait Implementations§

source§

impl<V: Clone> Clone for Mask<V>

source§

fn clone(&self) -> Mask<V>

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<V: Debug> Debug for Mask<V>

source§

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

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

impl<V: Copy> Copy for Mask<V>

Auto Trait Implementations§

§

impl<V> Freeze for Mask<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for Mask<V>
where V: RefUnwindSafe,

§

impl<V> Send for Mask<V>
where V: Send,

§

impl<V> Sync for Mask<V>
where V: Sync,

§

impl<V> Unpin for Mask<V>
where V: Unpin,

§

impl<V> UnwindSafe for Mask<V>
where V: UnwindSafe,

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.