pub struct GOCMap<C = Coding<u8>, GS: GroupSize = TwoToPowerBitsStatic<4>, SS: SeedSize = TwoToPowerBitsStatic<2>, S = BuildDefaultSeededHasher> { /* private fields */ }
Expand description
Finger-printing based compressed static function (immutable map) that uses group optimization and maps hashable keys to values of any type.
To represent a function f:X→Y, it uses the space slightly larger than |X|H, where H is the entropy of the distribution of the f values over X. The expected time complexity is O(c) for evaluation and O(|X|c) for construction (not counting building the encoding dictionary), where c is the average codeword length (given in code fragments) of the values.
Implementations§
source§impl<C: Coding, GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOCMap<C, GS, SS, S>
impl<C: Coding, GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOCMap<C, GS, SS, S>
sourcepub fn get_stats<K: Hash + ?Sized, A: AccessStatsCollector>(
&self,
key: &K,
access_stats: &mut A
) -> Option<<<C as Coding>::Decoder<'_> as Decoder>::Decoded>
pub fn get_stats<K: Hash + ?Sized, A: AccessStatsCollector>( &self, key: &K, access_stats: &mut A ) -> Option<<<C as Coding>::Decoder<'_> as Decoder>::Decoded>
Gets the value associated with the given key key
and reports statistics to access_stats
.
sourcepub fn get<K: Hash + ?Sized>(
&self,
k: &K
) -> Option<<<C as Coding>::Decoder<'_> as Decoder>::Decoded>
pub fn get<K: Hash + ?Sized>( &self, k: &K ) -> Option<<<C as Coding>::Decoder<'_> as Decoder>::Decoded>
Gets the value associated with the given key k
.
sourcepub fn with_fragments<K, LSC, BS, BC>(
keys: &mut [K],
values: &mut [C::Codeword],
value_coding: C,
conf: GOCMapConf<BC, LSC, GS, SS, S>,
stats: &mut BS
) -> Self
pub fn with_fragments<K, LSC, BS, BC>( keys: &mut [K], values: &mut [C::Codeword], value_coding: C, conf: GOCMapConf<BC, LSC, GS, SS, S>, stats: &mut BS ) -> Self
Build BBMap2 for given keys -> values map, where:
- keys are given directly
- values are encoded by Minimum-Redundancy (value_coding) and given in as values_fragments and corresponding values_fragments_sizes All three arrays must be of the same length. Note: conf.bits_per_fragment is ignored (since value_coding.bits_per_fragment is used).
source§impl<C: SerializableCoding, S: BuildSeededHasher, GS: GroupSize, SS: SeedSize> GOCMap<C, GS, SS, S>
impl<C: SerializableCoding, S: BuildSeededHasher, GS: GroupSize, SS: SeedSize> GOCMap<C, GS, SS, S>
sourcepub fn write_bytes(&self, bytes_per_value: usize) -> usize
pub fn write_bytes(&self, bytes_per_value: usize) -> usize
Returns number of bytes which write
will write, assuming that each call to write_value
writes bytes_per_value
bytes.
source§impl<GS: GroupSize, SS: SeedSize, C: Coding, S: BuildSeededHasher> GOCMap<C, GS, SS, S>
impl<GS: GroupSize, SS: SeedSize, C: Coding, S: BuildSeededHasher> GOCMap<C, GS, SS, S>
pub fn from_slices_with_coding_conf<K, LSC, BS, BC>( keys: &mut [K], values: &[C::Value], value_coding: C, conf: GOCMapConf<BC, LSC, GS, SS, S>, stats: &mut BS ) -> Self
pub fn from_slices_with_conf<K, LSC, BS, BC>(
keys: &mut [K],
values: &[C::Value],
conf: GOCMapConf<BC, LSC, GS, SS, S>,
stats: &mut BS
) -> Selfwhere
K: Hash,
LSC: LevelSizeChooser,
BS: BuildStatsCollector,
BC: BuildCoding<C::Value, Coding = C>,
pub fn from_map_with_coding_conf<K, H, LSC, BS, BC>(
map: &HashMap<K, C::Value, H>,
value_coding: C,
conf: GOCMapConf<BC, LSC, GS, SS, S>,
stats: &mut BS
) -> Selfwhere
K: Hash + Clone,
LSC: LevelSizeChooser,
BS: BuildStatsCollector,
BC: BuildCoding<C::Value, Coding = C>,
pub fn from_map_with_conf<K, H, LSC, BS, BC>(
map: &HashMap<K, C::Value, H>,
conf: GOCMapConf<BC, LSC, GS, SS, S>,
stats: &mut BS
) -> Selfwhere
K: Hash + Clone,
LSC: LevelSizeChooser,
BS: BuildStatsCollector,
BC: BuildCoding<C::Value, Coding = C>,
Trait Implementations§
source§impl<C: GetSize, GS: GroupSize, SS: SeedSize, S> GetSize for GOCMap<C, GS, SS, S>
impl<C: GetSize, GS: GroupSize, SS: SeedSize, S> GetSize for GOCMap<C, GS, SS, S>
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§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_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
.