pub trait Phf: Sized + Send + Sync {
const MINIMAL: bool;
// Required methods
fn build_in_internal_memory_from_bytes<Keys: IntoIterator>(
&mut self,
keys: Keys,
config: &BuildConfiguration
) -> Result<BuildTimings, Exception>
where <Keys as IntoIterator>::IntoIter: ExactSizeIterator + Clone,
<<Keys as IntoIterator>::IntoIter as Iterator>::Item: Hashable;
fn hash(&self, key: impl Hashable) -> u64;
fn num_bits(&self) -> usize;
fn num_keys(&self) -> u64;
fn table_size(&self) -> u64;
fn save(&mut self, path: impl AsRef<Path>) -> Result<usize, Exception>;
fn load(path: impl AsRef<Path>) -> Result<Self, Exception>;
}
Expand description
A perfect-hash function implemented with the PTHash algorithm
Required Associated Constants§
Required Methods§
sourcefn build_in_internal_memory_from_bytes<Keys: IntoIterator>(
&mut self,
keys: Keys,
config: &BuildConfiguration
) -> Result<BuildTimings, Exception>where
<Keys as IntoIterator>::IntoIter: ExactSizeIterator + Clone,
<<Keys as IntoIterator>::IntoIter as Iterator>::Item: Hashable,
fn build_in_internal_memory_from_bytes<Keys: IntoIterator>(
&mut self,
keys: Keys,
config: &BuildConfiguration
) -> Result<BuildTimings, Exception>where
<Keys as IntoIterator>::IntoIter: ExactSizeIterator + Clone,
<<Keys as IntoIterator>::IntoIter as Iterator>::Item: Hashable,
Builds the function from a set of keys
In plain English, this function’s trait bound on keys is that they should be a collection that can provide cloneable iterators of hashable values.
sourcefn hash(&self, key: impl Hashable) -> u64
fn hash(&self, key: impl Hashable) -> u64
Returns the hash of the given key
If the key
was not one of the keys passed to
build_in_internal_memory_from_bytes
when building the function, the hash will collide with another key’s
sourcefn num_bits(&self) -> usize
fn num_bits(&self) -> usize
Returns the number of bits needed to represent this perfect-hash function
sourcefn table_size(&self) -> u64
fn table_size(&self) -> u64
Largest value returned by Self::hash
plus 1
Object Safety§
This trait is not object safe.