pub struct Map<S = BuildDefaultSeededHasher> { /* private fields */ }Expand description
Static function (immutable map) that maps hashable keys to unsigned integer values of given bit-size.
It takes about 1.23bn bits to represent a function from an n-element set into a set of b-bit values. It has a computational construction and access time complexity of O(n) and O(1), respectively.
Its construction is based on solving linear system of equations by hyper-graphs peeling. The implementation is based on the paper:
- D. Belazzougui, P. Boldi, G. Ottaviano, R. Venturini, S. Vigna, Cache-Oblivious Peeling of Random Hypergraphs, In A. Bilgin, M. W. Marcellin, J. Serra-Sagristà, & J. A. Storer (Eds.), Proceedings of Data Compression Conference 26-28 March 2014, Snowbird, Utah, USA (pp. 352-361). (Data Compression Conference. Proceedings; Vol. 2375-0391). IEEE. https://doi.org/10.1109/DCC.2014.48
Implementations§
Source§impl<S> Map<S>
impl<S> Map<S>
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, hasher: S) -> Result<Self>
pub fn read_with_hasher(input: &mut dyn Read, hasher: S) -> Result<Self>
Reads self from the input (hasher must be the same as used by written Map).
Source§impl Map<BuildDefaultSeededHasher>
impl Map<BuildDefaultSeededHasher>
Sourcepub fn read(input: &mut dyn Read) -> Result<Self>
pub fn read(input: &mut dyn Read) -> Result<Self>
Reads self from the input. Only Maps that use default hasher can be read by this method.
pub fn try_with_fn<K, V, BC>( keys: &[K], values: V, bits_per_value: u8, ) -> Option<Self>
pub fn try_with_bitset<K, BC>( keys: &[K], values: &[u64], bits_per_value: u8, ) -> Option<Self>
pub fn try_with_kv_bpv<K, V, BC>( keys: &[K], values: &[V], bits_per_value: u8, ) -> Option<Self>
pub fn try_with_kv<K, V, BC>(keys: &[K], values: &[V]) -> Option<Self>
Source§impl<S: BuildSeededHasher> Map<S>
impl<S: BuildSeededHasher> Map<S>
Sourcepub fn try_with_conf_fn<K, KBorrow, KVIntoIterator, FKVIntoIterator, BM>(
kv: FKVIntoIterator,
kv_len: usize,
bits_per_value: u8,
conf: MapConf<BM, S>,
) -> Option<Self>where
KVIntoIterator: IntoIterator<Item = (KBorrow, u64)>,
FKVIntoIterator: Fn() -> KVIntoIterator,
K: Hash,
KBorrow: Borrow<K>,
BM: ValuesPreFiller,
pub fn try_with_conf_fn<K, KBorrow, KVIntoIterator, FKVIntoIterator, BM>(
kv: FKVIntoIterator,
kv_len: usize,
bits_per_value: u8,
conf: MapConf<BM, S>,
) -> Option<Self>where
KVIntoIterator: IntoIterator<Item = (KBorrow, u64)>,
FKVIntoIterator: Fn() -> KVIntoIterator,
K: Hash,
KBorrow: Borrow<K>,
BM: ValuesPreFiller,
Tries to construct Map with key-value pairs produced by the iterator returned by the kv function,
using the given configuration.
The iterator returned by kv should produce exactly kv_len key-value pairs.
Each value should occupy up to bits_per_value (least significant) bits
(the most significant bits must be zeroed).
Sourcepub fn try_with_conf_bitset<K, BM>(
keys: &[K],
values: &[u64],
bits_per_value: u8,
conf: MapConf<BM, S>,
) -> Option<Self>where
K: Hash,
BM: ValuesPreFiller,
pub fn try_with_conf_bitset<K, BM>(
keys: &[K],
values: &[u64],
bits_per_value: u8,
conf: MapConf<BM, S>,
) -> Option<Self>where
K: Hash,
BM: ValuesPreFiller,
Tries to construct Map with key-value pairs stored in keys and values respectively.
The values array should contain (at least) keys.len() fragments, each with a size of bits_per_value bits.
Sourcepub fn try_with_conf_kv_bpv<K, V, BM>(
keys: &[K],
values: &[V],
bits_per_value: u8,
conf: MapConf<BM, S>,
) -> Option<Self>
pub fn try_with_conf_kv_bpv<K, V, BM>( keys: &[K], values: &[V], bits_per_value: u8, conf: MapConf<BM, S>, ) -> Option<Self>
Tries to construct Map with key-value pairs stored in keys and values respectively.
The values array usually consists of u8, u16, u32 or u64 items.
The keys and values arrays must have the same length.
Each value must be convertible to u64 and should occupy up to bits_per_value (least significant) bits
(the most significant bits must be zeroed).
Sourcepub fn try_with_conf_kv<K, V, BM>(
keys: &[K],
values: &[V],
conf: MapConf<BM, S>,
) -> Option<Self>
pub fn try_with_conf_kv<K, V, BM>( keys: &[K], values: &[V], conf: MapConf<BM, S>, ) -> Option<Self>
Tries to construct Map with key-value pairs stored in keys and values respectively.
The values array usually consists of u8, u16, u32 or u64 items.
The keys and values arrays must have the same length.
Sourcepub fn try_from_hashmap_bpv<K, V, HMS, BM>(
map: HashMap<K, V, HMS>,
bits_per_value: u8,
conf: MapConf<BM, S>,
) -> Option<Self>
pub fn try_from_hashmap_bpv<K, V, HMS, BM>( map: HashMap<K, V, HMS>, bits_per_value: u8, conf: MapConf<BM, S>, ) -> Option<Self>
Tries to construct Map with key-value pairs stored in map.
Values are usually of type u8, u16, u32 or u64.
Each value must be convertible to u64 and should occupy up to bits_per_value (least significant) bits
(the most significant bits must be zeroed).
Trait Implementations§
Source§impl<K: Hash, V: Into<u64> + Clone, S: BuildSeededHasher + Default> From<&[(K, V)]> for Map<S>
impl<K: Hash, V: Into<u64> + Clone, S: BuildSeededHasher + Default> From<&[(K, V)]> for Map<S>
Source§impl<K: Hash, V: Into<u64> + Clone, S: BuildSeededHasher + Default, HMS> From<HashMap<K, V, HMS>> for Map<S>
impl<K: Hash, V: Into<u64> + Clone, S: BuildSeededHasher + Default, HMS> From<HashMap<K, V, HMS>> for Map<S>
Source§impl<S> GetSize for Map<S>
impl<S> GetSize for Map<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<S> Freeze for Map<S>where
S: Freeze,
impl<S> RefUnwindSafe for Map<S>where
S: RefUnwindSafe,
impl<S> Send for Map<S>where
S: Send,
impl<S> Sync for Map<S>where
S: Sync,
impl<S> Unpin for Map<S>where
S: Unpin,
impl<S> UnwindSafe for Map<S>where
S: 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