Skip to content

Commit

Permalink
no bits_per_value in GOMapConf
Browse files Browse the repository at this point in the history
  • Loading branch information
beling committed Sep 29, 2024
1 parent e52164a commit 7e388b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
48 changes: 7 additions & 41 deletions csf/src/fp/gomap/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ pub struct GOMapConf<
SS: SeedSize = TwoToPowerBitsStatic<2>,
S = BuildDefaultSeededHasher
> {
/// Bits per each value, 0 for autodetect.
pub bits_per_value: u8,
/// Configuration of family of (group-optimized) hash functions (default: [`GOConf::default`]).
pub goconf: GOConf<GS, SS, S>,
/// Choose the size of each level.
Expand All @@ -24,27 +22,15 @@ pub struct GOMapConf<

impl Default for GOMapConf {
fn default() -> Self { Self {
bits_per_value: Default::default(),
goconf: Default::default(),
level_size_chooser: Default::default(),
collision_solver: Default::default(),
} }
}

impl GOMapConf {
pub fn bpv(bits_per_value: u8) -> Self {
Self { bits_per_value, ..Default::default() }
}
}

impl<CSB: CollisionSolverBuilder> GOMapConf<OptimalLevelSize, CSB, TwoToPowerBitsStatic::<4>, TwoToPowerBitsStatic<2>, BuildDefaultSeededHasher> {
#[inline] pub fn cs(collision_solver: CSB) -> Self {
Self::cs_bpv(collision_solver, Default::default())
}

pub fn cs_bpv(collision_solver: CSB, bits_per_value: u8) -> Self {
pub fn cs(collision_solver: CSB) -> Self {
Self {
bits_per_value,
goconf: Default::default(),
level_size_chooser: Default::default(),
collision_solver,
Expand All @@ -53,13 +39,8 @@ impl<CSB: CollisionSolverBuilder> GOMapConf<OptimalLevelSize, CSB, TwoToPowerBit
}

impl<GS: GroupSize, SS: SeedSize, S> GOMapConf<OptimalLevelSize, LoMemAcceptEquals, GS, SS, S> {
#[inline] pub fn groups(goconf: GOConf<GS, SS, S>) -> Self {
Self::groups_bpv(goconf, Default::default())
}

pub fn groups_bpv(goconf: GOConf<GS, SS, S>, bits_per_value: u8) -> Self {
pub fn groups(goconf: GOConf<GS, SS, S>) -> Self {
Self {
bits_per_value,
goconf,
level_size_chooser: Default::default(),
collision_solver: Default::default(),
Expand All @@ -68,13 +49,8 @@ impl<GS: GroupSize, SS: SeedSize, S> GOMapConf<OptimalLevelSize, LoMemAcceptEqua
}

impl<CSB: CollisionSolverBuilder, GS: GroupSize, SS: SeedSize, S> GOMapConf<OptimalLevelSize, CSB, GS, SS, S> {
#[inline] pub fn groups_cs(goconf: GOConf<GS, SS, S>, collision_solver: CSB) -> Self {
Self::groups_cs_bpv(goconf, collision_solver, Default::default())
}

pub fn groups_cs_bpv(goconf: GOConf<GS, SS, S>, collision_solver: CSB, bits_per_value: u8) -> Self {
pub fn groups_cs(goconf: GOConf<GS, SS, S>, collision_solver: CSB) -> Self {
Self {
bits_per_value,
goconf,
level_size_chooser: Default::default(),
collision_solver,
Expand All @@ -90,12 +66,7 @@ impl<GS: GroupSize, SS: SeedSize, S> From<GOConf<GS, SS, S>> for GOMapConf<Optim

impl<LSC> GOMapConf<LSC, LoMemAcceptEquals, TwoToPowerBitsStatic::<4>, TwoToPowerBitsStatic<2>, BuildDefaultSeededHasher> {
pub fn lsize(level_size_chooser: LSC) -> Self {
Self::lsize_bpv(level_size_chooser, Default::default())
}

pub fn lsize_bpv(level_size_chooser: LSC, bits_per_value: u8) -> Self {
Self {
bits_per_value,
goconf: Default::default(),
level_size_chooser,
collision_solver: Default::default(),
Expand All @@ -105,12 +76,7 @@ impl<LSC> GOMapConf<LSC, LoMemAcceptEquals, TwoToPowerBitsStatic::<4>, TwoToPowe

impl<LSC, CSB: CollisionSolverBuilder> GOMapConf<LSC, CSB, TwoToPowerBitsStatic::<4>, TwoToPowerBitsStatic<2>, BuildDefaultSeededHasher> {
pub fn lsize_cs(level_size_chooser: LSC, collision_solver: CSB) -> Self {
Self::lsize_cs_bpv(level_size_chooser, collision_solver, Default::default())
}

pub fn lsize_cs_bpv(level_size_chooser: LSC, collision_solver: CSB, bits_per_value: u8) -> Self {
Self {
bits_per_value,
goconf: Default::default(),
level_size_chooser,
collision_solver,
Expand All @@ -119,13 +85,13 @@ impl<LSC, CSB: CollisionSolverBuilder> GOMapConf<LSC, CSB, TwoToPowerBitsStatic:
}

impl<LSC, GS: GroupSize, SS: SeedSize, S> GOMapConf<LSC, LoMemAcceptEquals, GS, SS, S> {
pub fn groups_lsize_bpv(goconf: GOConf<GS, SS, S>, level_size_chooser: LSC, bits_per_value: u8) -> Self {
Self { bits_per_value, goconf, level_size_chooser, collision_solver: Default::default() }
pub fn groups_lsize(goconf: GOConf<GS, SS, S>, level_size_chooser: LSC) -> Self {
Self { goconf, level_size_chooser, collision_solver: Default::default() }
}
}

impl<LSC, CSB: CollisionSolverBuilder, GS: GroupSize, SS: SeedSize, S> GOMapConf<LSC, CSB, GS, SS, S> {
pub fn groups_lsize_cs_bpv(goconf: GOConf<GS, SS, S>, level_size_chooser: LSC, collision_solver: CSB, bits_per_value: u8) -> Self {
Self { bits_per_value, goconf, level_size_chooser, collision_solver }
pub fn groups_lsize_cs(goconf: GOConf<GS, SS, S>, level_size_chooser: LSC, collision_solver: CSB) -> Self {
Self { goconf, level_size_chooser, collision_solver }
}
}
4 changes: 2 additions & 2 deletions csf/src/fp/kvset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<K, S> KVSet<K> for HashMap<K, u8, S> {
for (k, v) in self { f(k, *v) }
}

fn bits_per_value(&self) -> u8 {
fn bits_per_value(&self) -> u8 { // TODO wrong, should always returns the same
bits_to_store_any_of_ref(self.values())
}

Expand All @@ -86,7 +86,7 @@ impl<K: Ord> KVSet<K> for BTreeMap<K, u8> {
for (k, v) in self { f(k, *v) }
}

fn bits_per_value(&self) -> u8 {
fn bits_per_value(&self) -> u8 { // TODO wrong, should always returns the same
bits_to_store_any_of_ref(self.values())
}

Expand Down

0 comments on commit 7e388b4

Please sign in to comment.