diff --git a/bitm/src/rank_select/select.rs b/bitm/src/rank_select/select.rs index 3e7f0df..3337b26 100644 --- a/bitm/src/rank_select/select.rs +++ b/bitm/src/rank_select/select.rs @@ -494,6 +494,7 @@ impl CombinedSamplingDensity for AdaptiveCombinedSamplingD /// - Zhou D., Andersen D.G., Kaminsky M. (2013) "Space-Efficient, High-Performance Rank and Select Structures on Uncompressed Bit Sequences". /// In: Bonifaci V., Demetrescu C., Marchetti-Spaccamela A. (eds) Experimental Algorithms. SEA 2013. /// Lecture Notes in Computer Science, vol 7933. Springer, Berlin, Heidelberg. +/// /// However, our implementation can automatically adjust the sampling density according to the content of the vector /// (see [`AdaptiveCombinedSamplingDensity`]). /// diff --git a/csf/src/fp/gomap/conf.rs b/csf/src/fp/gomap/conf.rs index b9840e8..55eaee8 100644 --- a/csf/src/fp/gomap/conf.rs +++ b/csf/src/fp/gomap/conf.rs @@ -67,6 +67,21 @@ impl GOMapConf GOMapConf { + #[inline] pub fn groups_cs(goconf: GOConf, collision_solver: CSB) -> Self { + Self::groups_cs_bpv(goconf, collision_solver, Default::default()) + } + + pub fn groups_cs_bpv(goconf: GOConf, collision_solver: CSB, bits_per_value: u8) -> Self { + Self { + bits_per_value, + goconf, + level_size_chooser: Default::default(), + collision_solver, + } + } +} + impl From> for GOMapConf { #[inline] fn from(value: GOConf) -> Self { Self::groups(value) @@ -88,6 +103,21 @@ impl GOMapConf, TwoToPowe } } +impl GOMapConf, 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, + } + } +} + impl GOMapConf { pub fn groups_lsize_bpv(goconf: GOConf, level_size_chooser: LSC, bits_per_value: u8) -> Self { Self { bits_per_value, goconf, level_size_chooser, collision_solver: Default::default() } diff --git a/csf/src/fp/gomap/mod.rs b/csf/src/fp/gomap/mod.rs index 0383365..cc6a6c9 100644 --- a/csf/src/fp/gomap/mod.rs +++ b/csf/src/fp/gomap/mod.rs @@ -1,4 +1,33 @@ +use ph::{BuildDefaultSeededHasher, BuildSeededHasher, stats, utils::ArrayWithRank}; +use ph::fmph::{goindexing::group_nr, GroupSize, SeedSize, TwoToPowerBitsStatic}; +pub use ph::fmph::GOConf; +use dyn_size_of::GetSize; + mod conf; pub use conf::GOMapConf; -pub struct GOMap {} \ No newline at end of file +/// Finger-printing based compressed static function (immutable map) +/// that uses group optimization and maps hashable keys to unsigned integer values of given bit-size. +/// +/// It usually takes somewhat more than *nb* bits to represent a function from an *n*-element set into a set of *b*-bit values. +/// (Smaller sizes are achieved when the set of values is small and the same values are assigned to multiple keys.) +/// The expected time complexities of its construction and evaluation are *O(n)* and *O(1)*, respectively. +pub struct GOMap, SS: SeedSize = TwoToPowerBitsStatic<2>, S = BuildDefaultSeededHasher> { + array: ArrayWithRank, + values: Box<[u64]>, // BitVec + bits_per_value: u8, + group_seeds: Box<[SS::VecElement]>, // Box<[u8]>, + level_size: Box<[u64]>, // number of groups + goconf: GOConf, +} + +impl GetSize for GOMap { + fn size_bytes_dyn(&self) -> usize { + self.array.size_bytes_dyn() + + self.values.size_bytes_dyn() + + self.group_seeds.size_bytes_dyn() + + self.level_size.size_bytes_dyn() + } + const USES_DYN_MEM: bool = true; +} +