12#include <seqan3/contrib/sdsl-lite.hpp>
84template <data_layout data_layout_mode_ = data_layout::uncompressed>
89 template <data_layout data_layout_mode>
95 seqan3::contrib::sdsl::bit_vector,
96 seqan3::contrib::sdsl::sd_vector<>>;
99 size_t size_in_bits{};
108 13'043'817'825'332'782'213ULL,
109 10'650'232'656'628'343'401ULL,
110 16'499'269'484'942'379'435ULL,
111 4'893'150'838'803'335'377ULL};
120 inline constexpr size_t hash_and_fit(
size_t h,
size_t const seed)
const
123 h ^=
h >> hash_shift;
124 h *= 11'400'714'819'323'198'485ULL;
126#ifdef __SIZEOF_INT128__
163 size_in_bits = size.get();
164 hash_funs =
funs.get();
166 if (hash_funs == 0 || hash_funs > 5)
167 throw std::logic_error{
"The number of hash functions must be > 0 and <= 5."};
168 if (size_in_bits == 0)
172 data = seqan3::contrib::sdsl::bit_vector(size_in_bits);
191 data = seqan3::contrib::sdsl::sd_vector<>{
bf.data};
212 for (
size_t i = 0;
i < hash_funs; ++
i)
214 size_t idx = hash_and_fit(value, hash_seeds[
i]);
235 seqan3::contrib::sdsl::util::_set_zero_bits(data);
255 for (
size_t i = 0;
i < hash_funs;
i++)
257 size_t idx = hash_and_fit(value, hash_seeds[
i]);
284 template <std::ranges::range value_range_t>
287 static_assert(std::ranges::input_range<value_range_t>,
"The values must model input_range.");
288 static_assert(std::unsigned_integral<std::ranges::range_value_t<value_range_t>>,
289 "An individual value must be an unsigned integral.");
293 for (
auto && value : values)
374 template <cereal_archive archive_t>
Provides strong types for the (Interleaved) Bloom Filter.
Adaptions of concepts from the Cereal library.
The Bloom Filter. A data structure that efficiently answers set-membership queries.
Definition bloom_filter.hpp:86
friend bool operator!=(bloom_filter const &lhs, bloom_filter const &rhs) noexcept
Test for inequality.
Definition bloom_filter.hpp:339
constexpr data_type & raw_data() noexcept
Provides direct, unsafe access to the underlying data structure.
Definition bloom_filter.hpp:355
bloom_filter(bloom_filter &&)=default
Defaulted.
static constexpr data_layout data_layout_mode
Indicates whether the Bloom Filter is compressed.
Definition bloom_filter.hpp:136
constexpr data_type const & raw_data() const noexcept
Provides direct, unsafe access to the underlying data structure.
Definition bloom_filter.hpp:361
bloom_filter & operator=(bloom_filter const &)=default
Defaulted.
bool contains(size_t const value) const noexcept
Check whether a value is present in the Bloom Filter.
Definition bloom_filter.hpp:253
bloom_filter(bloom_filter< data_layout::uncompressed > const &bf)
Construct a compressed Bloom Filter.
Definition bloom_filter.hpp:186
friend bool operator==(bloom_filter const &lhs, bloom_filter const &rhs) noexcept
Test for equality.
Definition bloom_filter.hpp:328
void reset() noexcept
Remove all values from the Bloom Filter by setting all bits to 0.
Definition bloom_filter.hpp:232
bloom_filter(bloom_filter const &)=default
Defaulted.
size_t hash_function_count() const noexcept
Returns the number of hash functions used in the Bloom Filter.
Definition bloom_filter.hpp:306
size_t count(value_range_t &&values) const noexcept
Counts the occurrences for all values in a range.
Definition bloom_filter.hpp:285
bloom_filter()=default
Defaulted.
size_t bit_size() const noexcept
Returns the size of the underlying bitvector.
Definition bloom_filter.hpp:314
bloom_filter & operator=(bloom_filter &&)=default
Defaulted.
void emplace(size_t const value) noexcept
Inserts a value into the Bloom Filter.
Definition bloom_filter.hpp:209
~bloom_filter()=default
Defaulted.
bloom_filter(seqan3::bin_size size, seqan3::hash_function_count funs=seqan3::hash_function_count{2u})
Construct an uncompressed Bloom Filter.
Definition bloom_filter.hpp:160
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
data_layout
Determines if the Interleaved Bloom Filter is compressed.
Definition bloom_filter_strong_types.hpp:23
@ uncompressed
The Interleaved Bloom Filter is uncompressed.
Definition bloom_filter_strong_types.hpp:24
@ compressed
The Interleaved Bloom Filter is compressed.
Definition bloom_filter_strong_types.hpp:25
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
A strong type that represents the number of bits for each bin in the seqan3::interleaved_bloom_filter...
Definition bloom_filter_strong_types.hpp:38
A strong type that represents the number of hash functions for the seqan3::interleaved_bloom_filter.
Definition bloom_filter_strong_types.hpp:45
strong_type for seed.
Definition minimiser_hash.hpp:22