SimdDualTableWithHashLookup

Struct SimdDualTableWithHashLookup 

Source
pub struct SimdDualTableWithHashLookup<'a> { /* private fields */ }
Expand description

Dual table lookup kernel using FxHashMap for table2.

This kernel is optimized for the case where table2 has a very small number of entries (sparse), making a hash map lookup more memory-efficient than a full lookup table. NOTE: We also tried writing a kernel with PHF-based EntropyMap, but it is slower than the HashMap version.

  • Table1: Standard &[u8] lookup table (can be large)
  • Table2: FxHashMap<u32, u8> (optimized for sparse data with fast hashing)

The lookup behavior is the same as SimdDualTableU32U8Lookup:

  • Table2 is only looked up if table1 returns a non-zero value
  • Results are passed to the user function as (u8x16, u8x16, num_bytes)

UPDATE: Testing on Intel Xeon shows that this kernel is maybe 20% slower than the V2 kernel with an optimized writer.

Implementations§

Source§

impl<'a> SimdDualTableWithHashLookup<'a>

Source

pub fn new( lookup_table1: &'a [u8], lookup_table2: &'a FxHashMap<u32, u8>, ) -> Self

Creates a new dual table lookup kernel with table1 as a slice and table2 as FxHashMap.

Source

pub fn lookup_func<F>(&self, values1: &[u32], values2: &[u32], f: &mut F)
where F: FnMut(u8x16, u8x16, usize),

Given two slices of equal length &u32 indices, looks up each one and calls the user given function on assembled u8x16 results.

  • lookup_table1 (slice) is used for the first slice
  • lookup_table2 (FxHashMap) is used for the second slice
  • Table2 is only looked up if table1 returns a non-zero value
  • The user function is passed (lookedup_values1: u8x16, lookedup_values2: u8x16, num_bytes)
Source

pub fn lookup_into_vec<F>( &self, values1: &[u32], values2: &[u32], output: &mut Vec<u8>, f: &mut F, )
where F: FnMut(u8x16, u8x16) -> u8x16,

Convenience function which does dual lookup, combines the results using a user-defined combiner function, and extends the combined results into a Vec (pushing all combined results)

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.