Skip to content

Commit

Permalink
doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
beling committed Oct 4, 2024
1 parent 5ef16e0 commit 350bcd8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
15 changes: 12 additions & 3 deletions csf/src/fp/gomap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ impl<GS: GroupSize, SS: SeedSize, S> GetSize for GOMap<GS, SS, S> {
}

impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOMap<GS, SS, S> {

/// Gets the value associated with the given `key` and reports statistics to `access_stats`.
///
/// If the `key` was not in the input key-value collection given during construction,
/// either [`None`] or a value assigned to other key is returned.
pub fn get_stats<K: Hash, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> Option<u8> {
let mut groups_before = 0u64;
let mut level_nr = 0u32;
Expand All @@ -54,8 +58,13 @@ impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOMap<GS, SS, S> {
}
}

/// Gets the value associated with the given key k.
pub fn get<K: Hash>(&self, k: &K) -> Option<u8> {
self.get_stats(k, &mut ())
/// Gets the value associated with the given `key`.
///
/// If the `key` was not in the input key-value collection given during construction,
/// either [`None`] or a value assigned to other key is returned.
#[inline] pub fn get<K: Hash>(&self, key: &K) -> Option<u8> {
self.get_stats(key, &mut ())
}


}
18 changes: 12 additions & 6 deletions csf/src/fp/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ impl Arrays {

impl<S: BuildSeededHasher> Map<S> {

/// Gets the value associated with the given key k and reports statistics to access_stats.
pub fn get_stats<K: Hash, A: stats::AccessStatsCollector>(&self, k: &K, access_stats: &mut A) -> Option<u8> {
/// Gets the value associated with the given `key` and reports statistics to `access_stats`.
///
/// If the `key` was not in the input key-value collection given during construction,
/// either [`None`] or a value assigned to other key is returned.
pub fn get_stats<K: Hash, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> Option<u8> {
let mut array_begin_index = 0usize;
let mut level = 0u32;
loop {
let level_size = *self.level_sizes.get(level as usize)? << 6usize;
let i = array_begin_index + index(&self.hash, k, level, level_size);
let i = array_begin_index + index(&self.hash, key, level, level_size);
if self.array.content.get_bit(i) {
access_stats.found_on_level(level);
return Some(self.values.get_fragment(self.array.rank(i), self.bits_per_value) as u8);
Expand All @@ -88,9 +91,12 @@ impl<S: BuildSeededHasher> Map<S> {
}
}

/// Gets the value associated with the given key k.
pub fn get<K: Hash>(&self, k: &K) -> Option<u8> {
self.get_stats(k, &mut ())
/// Gets the value associated with the given `key`.
///
/// If the `key` was not in the input key-value collection given during construction,
/// either [`None`] or a value assigned to other key is returned.
pub fn get<K: Hash>(&self, key: &K) -> Option<u8> {
self.get_stats(key, &mut ())
}

/// Pre-builds [`Map`] for given key-value pairs `kv`, using the build configuration `conf` and reporting statistics with `stats`.
Expand Down

0 comments on commit 350bcd8

Please sign in to comment.