pub struct BuzHash<H: BuzHashHash> { /* private fields */ }Expand description
Describes an instance of BuzHash (aka cyclic polynomial hash).
Provides parameterization over the window size (k), hash function (h), chunk edge mask, and
max chunk size.
Uses fixed 32-bit width for the hash.
The trait BuzHashHash provides the internal hash function, see the implimentations of it
for built-in hash options (which include both Borg and silvasur/buzhash’s internal hash
tables).
Note that it’s helpful for k to be prime to prevent repeating strings form resulting
in total cancelation of the internal hash, which can cause overly long chunks.
Adjusting mask changes the average chunk size.
§Performance
BuzHash requires storing bytes equal to it’s window size (k). Because of this,
BuzHashIncr may have poor performance compared to BuzHash::find_chunk_edge().
Implementations§
Source§impl<H: BuzHashHash> BuzHash<H>
impl<H: BuzHashHash> BuzHash<H>
Sourcepub fn new(capacity: usize, mask: u32, hash: H, max_chunk_size: u64) -> Self
pub fn new(capacity: usize, mask: u32, hash: H, max_chunk_size: u64) -> Self
Create an instance with the given capacity (k) and chunk termination mask, and a internal
hash function.
capacity is the number of bytes that are taken into account for a given hash.
mask affects how chunk edges are determined.
hash is applied to each byte of input prior to mixing into the rolling hash.
Trait Implementations§
Source§impl<H: BuzHashHash + Clone> Chunk for BuzHash<H>
impl<H: BuzHashHash + Clone> Chunk for BuzHash<H>
Source§type SearchState = BuzHashSearchState
type SearchState = BuzHashSearchState
SearchState allows searching for the chunk edge to resume without duplicating work
already done.Source§fn to_search_state(&self) -> Self::SearchState
fn to_search_state(&self) -> Self::SearchState
SearchState] for use with [find_chunk_edge()]. Generally, for each
input one should generate a new [SearchState].Source§fn find_chunk_edge(
&self,
state: &mut Self::SearchState,
data: &[u8],
) -> (Option<usize>, usize)
fn find_chunk_edge( &self, state: &mut Self::SearchState, data: &[u8], ) -> (Option<usize>, usize)
data to emit Read moreSource§impl<H: BuzHashHash + Clone> From<&BuzHash<H>> for BuzHashIncr<H>
impl<H: BuzHashHash + Clone> From<&BuzHash<H>> for BuzHashIncr<H>
Source§impl<H: BuzHashHash> From<BuzHash<H>> for BuzHashIncr<H>
impl<H: BuzHashHash> From<BuzHash<H>> for BuzHashIncr<H>
Source§impl<H: BuzHashHash + Clone> ToChunkIncr for BuzHash<H>
impl<H: BuzHashHash + Clone> ToChunkIncr for BuzHash<H>
Source§type Incr = BuzHashIncr<H>
type Incr = BuzHashIncr<H>
Incr provides the incrimental interface to this chunking instance