pub struct GOFunction<GS: GroupSize = TwoToPowerBitsStatic<4>, SS: SeedSize = TwoToPowerBitsStatic<2>, S = BuildDefaultSeededHasher> { /* private fields */ }Expand description
Fingerprinting-based minimal perfect hash function with group optimization (FMPHGO).
See:
- P. Beling, Fingerprinting-based minimal perfect hashing revisited, ACM Journal of Experimental Algorithmics, 2023, https://doi.org/10.1145/3596453
Implementations§
Source§impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOFunction<GS, SS, S>
impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOFunction<GS, SS, S>
Sourcepub fn get_stats<K: Hash + ?Sized, A: AccessStatsCollector>(
&self,
key: &K,
access_stats: &mut A,
) -> Option<u64>
pub fn get_stats<K: Hash + ?Sized, A: AccessStatsCollector>( &self, key: &K, access_stats: &mut A, ) -> Option<u64>
Gets the value associated with the given key and reports statistics to access_stats.
The returned value is in the range: 0 (inclusive), the number of elements in the input key collection (exclusive).
If the key was not in the input key collection given during construction,
either None or an undetermined value from the specified range is returned.
Sourcepub fn get<K: Hash + ?Sized>(&self, key: &K) -> Option<u64>
pub fn get<K: Hash + ?Sized>(&self, key: &K) -> Option<u64>
Gets the value associated with the given key.
The returned value is in the range: 0 (inclusive), the number of elements in the input key collection (exclusive).
If the key was not in the input key collection given during construction,
either None or an undetermined value from the specified range is returned.
Sourcepub fn get_stats_or_panic<K: Hash + ?Sized, A: AccessStatsCollector>(
&self,
key: &K,
access_stats: &mut A,
) -> u64
pub fn get_stats_or_panic<K: Hash + ?Sized, A: AccessStatsCollector>( &self, key: &K, access_stats: &mut A, ) -> u64
Gets the value associated with the given key and reports statistics to access_stats.
The returned value is in the range: 0 (inclusive), the number of elements in the input key collection (exclusive).
If the key was not in the input key collection given during construction,
it either panics or returns an undetermined value from the specified range.
Sourcepub fn get_or_panic<K: Hash + ?Sized>(&self, key: &K) -> u64
pub fn get_or_panic<K: Hash + ?Sized>(&self, key: &K) -> u64
Gets the value associated with the given key and reports statistics to access_stats.
The returned value is in the range: 0 (inclusive), the number of elements in the input key collection (exclusive).
If the key was not in the input key collection given during construction,
it either panics or returns an undetermined value from the specified range.
Sourcepub fn write_bytes(&self) -> usize
pub fn write_bytes(&self) -> usize
Returns number of bytes which write will write.
Sourcepub fn read_with_hasher(input: &mut dyn Read, hash_builder: S) -> Result<Self>
pub fn read_with_hasher(input: &mut dyn Read, hash_builder: S) -> Result<Self>
Reads Self from the input. Hash builder must be the same as the one used to write.
Sourcepub fn level_sizes(&self) -> &[usize]
pub fn level_sizes(&self) -> &[usize]
Returns sizes of the successive levels.
Source§impl<GS: GroupSize + Sync, SS: SeedSize, S: BuildSeededHasher + Sync> GOFunction<GS, SS, S>
impl<GS: GroupSize + Sync, SS: SeedSize, S: BuildSeededHasher + Sync> GOFunction<GS, SS, S>
Sourcepub fn try_with_conf_stats_or_partial<K, KS, BS>(
keys: KS,
conf: GOBuildConf<GS, SS, S>,
stats: &mut BS,
) -> Result<Self, (Self, KS, usize)>
pub fn try_with_conf_stats_or_partial<K, KS, BS>( keys: KS, conf: GOBuildConf<GS, SS, S>, stats: &mut BS, ) -> Result<Self, (Self, KS, usize)>
Constructs GOFunction for given input keys,
using the build configuration conf and reporting statistics with stats.
If the construction fails, it returns Err with a triple (f, k, s), where:
- f is a
GOFunctionhandling only part of the keys (that returns numbers in the interval [0, s-k.keys_len())); - k is a set of the remaining keys,
- s is the initial number of keys. If needed, the keys from k can be placed in another data structure to handle all the keys.
If the construction fails, it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used. The duplicate keys will be included in the k set.
Sourcepub fn try_with_conf_stats<K, KS, BS>(
keys: KS,
conf: GOBuildConf<GS, SS, S>,
stats: &mut BS,
) -> Option<Self>
pub fn try_with_conf_stats<K, KS, BS>( keys: KS, conf: GOBuildConf<GS, SS, S>, stats: &mut BS, ) -> Option<Self>
Constructs GOFunction for given keys, using the build configuration conf and reporting statistics with stats.
None is returned if the construction fails.
Then it is almost certain that the input contains either duplicate keys
or keys indistinguishable by any hash function from the family used.
Sourcepub fn with_conf_stats<K, KS, BS>(
keys: KS,
conf: GOBuildConf<GS, SS, S>,
stats: &mut BS,
) -> Self
pub fn with_conf_stats<K, KS, BS>( keys: KS, conf: GOBuildConf<GS, SS, S>, stats: &mut BS, ) -> Self
Builds GOFunction for given keys, using the build configuration conf and reporting statistics with stats.
Panics if the construction fails.
Sourcepub fn with_conf<K, KS>(keys: KS, conf: GOBuildConf<GS, SS, S>) -> Self
pub fn with_conf<K, KS>(keys: KS, conf: GOBuildConf<GS, SS, S>) -> Self
Builds GOFunction for given keys, using the build configuration conf.
Panics if the construction fails. Then it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used.
Sourcepub fn from_slice_with_conf_stats<K, BS>(
keys: &[K],
conf: GOBuildConf<GS, SS, S>,
stats: &mut BS,
) -> Self
pub fn from_slice_with_conf_stats<K, BS>( keys: &[K], conf: GOBuildConf<GS, SS, S>, stats: &mut BS, ) -> Self
Builds GOFunction for given keys, using the build configuration conf and reporting statistics with stats.
Panics if the construction fails. Then it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used.
Sourcepub fn from_slice_with_conf<K>(keys: &[K], conf: GOBuildConf<GS, SS, S>) -> Self
pub fn from_slice_with_conf<K>(keys: &[K], conf: GOBuildConf<GS, SS, S>) -> Self
Builds GOFunction for given keys, using the configuration conf.
Panics if the construction fails. Then it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used.
Sourcepub fn from_slice_mut_with_conf_stats<K, BS>(
keys: &mut [K],
conf: GOBuildConf<GS, SS, S>,
stats: &mut BS,
) -> Self
pub fn from_slice_mut_with_conf_stats<K, BS>( keys: &mut [K], conf: GOBuildConf<GS, SS, S>, stats: &mut BS, ) -> Self
Builds GOFunction for given keys, using the build configuration conf and reporting statistics with stats.
Note that keys can be reordered during construction.
Panics if the construction fails. Then it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used.
Sourcepub fn from_slice_mut_with_conf<K>(
keys: &mut [K],
conf: GOBuildConf<GS, SS, S>,
) -> Self
pub fn from_slice_mut_with_conf<K>( keys: &mut [K], conf: GOBuildConf<GS, SS, S>, ) -> Self
Builds GOFunction for given keys, using the build configuration conf.
Note that keys can be reordered during construction.
Panics if the construction fails. Then it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used.
Source§impl<GS: GroupSize + Sync, SS: SeedSize> GOFunction<GS, SS>
impl<GS: GroupSize + Sync, SS: SeedSize> GOFunction<GS, SS>
Sourcepub fn read(input: &mut dyn Read) -> Result<Self>
pub fn read(input: &mut dyn Read) -> Result<Self>
Reads Self from the input.
Only GOFunctions that use default hasher can be read by this method.
Source§impl GOFunction
impl GOFunction
Sourcepub fn from_slice_with_stats<K, BS>(keys: &[K], stats: &mut BS) -> Self
pub fn from_slice_with_stats<K, BS>(keys: &[K], stats: &mut BS) -> Self
Builds GOFunction for given keys, reporting statistics with stats.
Panics if the construction fails. Then it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used.
Sourcepub fn from_slice<K: Hash + Sync>(keys: &[K]) -> Self
pub fn from_slice<K: Hash + Sync>(keys: &[K]) -> Self
Builds GOFunction for given keys.
Panics if the construction fails. Then it is almost certain that the input contains either duplicate keys or keys indistinguishable by any hash function from the family used.
Trait Implementations§
Source§impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GetSize for GOFunction<GS, SS, S>
impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GetSize for GOFunction<GS, SS, S>
Source§const USES_DYN_MEM: bool = true
const USES_DYN_MEM: bool = true
true if and only if the variables of this type can use dynamic (heap) memory.Source§fn size_bytes_dyn(&self) -> usize
fn size_bytes_dyn(&self) -> usize
self.
Same as self.size_bytes() - std::mem::size_of_val(self).Source§fn size_bytes_content_dyn(&self) -> usize
fn size_bytes_content_dyn(&self) -> usize
self content.
It usually equals to size_bytes_dyn().
However, sometimes it is smaller by the amount of memory reserved but not yet used
(e.g., size_bytes_content_dyn() only takes into account the length of the vector and not its capacity).Source§fn size_bytes(&self) -> usize
fn size_bytes(&self) -> usize
self.Auto Trait Implementations§
impl<GS, SS, S> Freeze for GOFunction<GS, SS, S>
impl<GS, SS, S> RefUnwindSafe for GOFunction<GS, SS, S>where
S: RefUnwindSafe,
SS: RefUnwindSafe,
GS: RefUnwindSafe,
<SS as SeedSize>::VecElement: RefUnwindSafe,
impl<GS, SS, S> Send for GOFunction<GS, SS, S>
impl<GS, SS, S> Sync for GOFunction<GS, SS, S>
impl<GS, SS, S> Unpin for GOFunction<GS, SS, S>
impl<GS, SS, S> UnsafeUnpin for GOFunction<GS, SS, S>
impl<GS, SS, S> UnwindSafe for GOFunction<GS, SS, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more