Skip to content

Commit

Permalink
fp maps return u64
Browse files Browse the repository at this point in the history
  • Loading branch information
beling committed Oct 4, 2024
1 parent d200e6e commit 9b69212
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions csf/src/fp/gomap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOMap<GS, SS, S> {
///
/// 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 + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> Option<u8> {
pub fn get_stats<K: Hash + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> Option<u64> {
let mut groups_before = 0u64;
let mut level_nr = 0u32;
loop {
Expand All @@ -51,7 +51,7 @@ impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOMap<GS, SS, S> {
if self.array.content.get_bit(bit_index) {
access_stats.found_on_level(level_nr);
//return Some(unsafe{self.array.rank_unchecked(bit_index)} as u64);
return Some(self.values.get_fragment(self.array.rank(bit_index), self.bits_per_value) as u8);
return Some(self.values.get_fragment(self.array.rank(bit_index), self.bits_per_value));
}
groups_before += level_size_groups;
level_nr += 1;
Expand All @@ -62,23 +62,23 @@ impl<GS: GroupSize, SS: SeedSize, S: BuildSeededHasher> GOMap<GS, SS, S> {
///
/// 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 + ?Sized>(&self, key: &K) -> Option<u8> {
#[inline] pub fn get<K: Hash + ?Sized>(&self, key: &K) -> Option<u64> {
self.get_stats(key, &mut ())
}

/// 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,
/// it either panics or returns a value assigned to other key is returned.
#[inline] pub fn get_stats_or_panic<K: Hash + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> u8 {
#[inline] pub fn get_stats_or_panic<K: Hash + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> u64 {
self.get_stats(key, access_stats).expect("Invalid access to a key outside the set given during construction.")
}

/// Gets the value associated with the given `key`.
///
/// If the `key` was not in the input key-value collection given during construction,
/// it either panics or returns a value assigned to other key is returned.
#[inline] pub fn get_or_panic<K: Hash + ?Sized>(&self, key: &K) -> u8 {
#[inline] pub fn get_or_panic<K: Hash + ?Sized>(&self, key: &K) -> u64 {
self.get_stats_or_panic(key, &mut ())
}

Expand Down
10 changes: 5 additions & 5 deletions csf/src/fp/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ impl<S: BuildSeededHasher> Map<S> {
///
/// 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 + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> Option<u8> {
pub fn get_stats<K: Hash + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> Option<u64> {
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, 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);
return Some(self.values.get_fragment(self.array.rank(i), self.bits_per_value));
}
array_begin_index += level_size;
level += 1;
Expand All @@ -95,23 +95,23 @@ impl<S: BuildSeededHasher> Map<S> {
///
/// 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 + ?Sized>(&self, key: &K) -> Option<u8> {
pub fn get<K: Hash + ?Sized>(&self, key: &K) -> Option<u64> {
self.get_stats(key, &mut ())
}

/// 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,
/// it either panics or returns a value assigned to other key is returned.
#[inline] pub fn get_stats_or_panic<K: Hash + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> u8 {
#[inline] pub fn get_stats_or_panic<K: Hash + ?Sized, A: stats::AccessStatsCollector>(&self, key: &K, access_stats: &mut A) -> u64 {
self.get_stats(key, access_stats).expect("Invalid access to a key outside the set given during construction.")
}

/// Gets the value associated with the given `key`.
///
/// If the `key` was not in the input key-value collection given during construction,
/// it either panics or returns a value assigned to other key is returned.
#[inline] pub fn get_or_panic<K: Hash + ?Sized>(&self, key: &K) -> u8 {
#[inline] pub fn get_or_panic<K: Hash + ?Sized>(&self, key: &K) -> u64 {
self.get_stats_or_panic(key, &mut ())
}

Expand Down

0 comments on commit 9b69212

Please sign in to comment.