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§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<C, GS, SS, S> Freeze for GOCMap<C, GS, SS, S>
impl<C, GS, SS, S> RefUnwindSafe for GOCMap<C, GS, SS, S>where
C: RefUnwindSafe,
S: RefUnwindSafe,
SS: RefUnwindSafe,
GS: RefUnwindSafe,
<SS as SeedSize>::VecElement: RefUnwindSafe,
impl<C, GS, SS, S> Send for GOCMap<C, GS, SS, S>
impl<C, GS, SS, S> Sync for GOCMap<C, GS, SS, S>
impl<C, GS, SS, S> Unpin for GOCMap<C, GS, SS, S>
impl<C, GS, SS, S> UnwindSafe for GOCMap<C, GS, SS, S>where
C: UnwindSafe,
S: UnwindSafe,
SS: UnwindSafe,
GS: UnwindSafe,
<SS as SeedSize>::VecElement: UnwindSafe,
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> 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