pub trait GroupSize:
Sized
+ Mul<usize, Output = usize>
+ Copy
+ Into<u8>
+ TryFrom<u8, Error = &'static str> {
// Provided methods
fn validate(&self) -> Result<Self, &'static str> { ... }
fn hash_to_group(&self, hash: u32) -> u8 { ... }
fn in_group_index(&self, hash: u64, group_seed: u16) -> u8 { ... }
fn bit_index_for_seed(
&self,
hash: u64,
group_seed: u16,
group: u64,
) -> usize { ... }
fn level_size_groups_segments(
&self,
desired_total_size: usize,
) -> (usize, usize) { ... }
fn copy_group_if_better<CB>(
&self,
dst: &mut [u64],
src: &[u64],
group_index: usize,
callback: CB,
)
where CB: FnOnce() { ... }
fn write_size_bytes(&self) -> usize { ... }
fn write(&self, output: &mut dyn Write) -> Result<(), Error> { ... }
fn read(input: &mut dyn Read) -> Result<Self, Error> { ... }
}
Expand description
Implementations of GroupSize
represent group size in fingerprinting-based minimal perfect hashing with group optimization.
Provided Methods§
fn validate(&self) -> Result<Self, &'static str>
Sourcefn hash_to_group(&self, hash: u32) -> u8
fn hash_to_group(&self, hash: u32) -> u8
Returns hash
modulo self
.
Sourcefn in_group_index(&self, hash: u64, group_seed: u16) -> u8
fn in_group_index(&self, hash: u64, group_seed: u16) -> u8
Returns index in the group with given seed group_seed
using hasher
which must be modified earlier by group_nr
function.
Sourcefn bit_index_for_seed(&self, hash: u64, group_seed: u16, group: u64) -> usize
fn bit_index_for_seed(&self, hash: u64, group_seed: u16, group: u64) -> usize
Returns bit index inside the group with number group
and seed group_seed
,
assigned to the key hashed by the hasher
.
Sourcefn level_size_groups_segments(
&self,
desired_total_size: usize,
) -> (usize, usize)
fn level_size_groups_segments( &self, desired_total_size: usize, ) -> (usize, usize)
Returns number of groups and 64-bit segments for given desired_total_size
.
Sourcefn copy_group_if_better<CB>(
&self,
dst: &mut [u64],
src: &[u64],
group_index: usize,
callback: CB,
)where
CB: FnOnce(),
fn copy_group_if_better<CB>(
&self,
dst: &mut [u64],
src: &[u64],
group_index: usize,
callback: CB,
)where
CB: FnOnce(),
Returns number of ones in the group.
If group with given index has more ones in dst
than in src
, then copy it from src
to dst
and call callback
.
Sourcefn write_size_bytes(&self) -> usize
fn write_size_bytes(&self) -> usize
Returns number of bytes that self.write
writes to the output.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.