21#include <cereal/cereal.hpp>
22#include <cereal/macros.hpp>
23#include <cereal/types/base_class.hpp>
24#include <cereal/types/vector.hpp>
26#include <hibf/cereal/concepts.hpp>
27#include <hibf/contrib/std/enumerate_view.hpp>
30#include <hibf/misc/next_multiple_of_64.hpp>
168 template <
typename t>
177 size_t technical_bins{};
188 13043817825332782213ULL,
189 10650232656628343401ULL,
190 16499269484942379435ULL,
191 4893150838803335377ULL};
200 [[gnu::always_inline]]
inline constexpr size_t hash_and_fit(
size_t h,
size_t const seed)
const
203 assert(hash_shift < 64);
204 h ^= h >> hash_shift;
205 h *= 11400714819323198485ULL;
207 h =
static_cast<uint64_t
>((
static_cast<__uint128_t
>(h) *
static_cast<__uint128_t
>(bin_size_)) >> 64);
213 class containment_agent_type;
214 template <std::
integral value_t>
215 class counting_agent_type;
216 class membership_agent_type;
306 template <
typename rng_t>
307 void clear(rng_t && bin_range)
noexcept
309 static_assert(std::ranges::forward_range<rng_t>,
"The range of bins to clear must model a forward_range.");
311 "The reference type of the range to clear must be seqan::hibf::bin_index.");
313 for (
auto && bin : bin_range)
314 assert(bin.value < technical_bins);
317 for (
size_t offset = 0, i = 0; i < bin_size_; offset += technical_bins, ++i)
318 for (
auto && bin : bin_range)
319 (*
this)[bin.value + offset] = 0;
397 template <
typename value_t = u
int16_t>
494 template <cereal_archive archive_t>
495 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
497 uint32_t parsed_version{
version};
498 archive(cereal::make_nvp(
"version", parsed_version));
500 archive(technical_bins);
505 archive(cereal::base_class<base_t>(
this));
550 ibf_ptr(
std::addressof(ibf)),
596template <std::
integral value_t>
622 containment_agent(ibf),
624 result_buffer(ibf.bin_count())
631 result_buffer.
resize(ibf.bin_count());
633# if defined(_LIBCPP_VERSION)
634# if __has_feature(address_sanitizer)
637 result_buffer.
data() + result_buffer.
size(),
668 template <std::ranges::range value_range_t>
671 static_assert(std::ranges::input_range<value_range_t>,
"The values must model input_range.");
673 "An individual value must be an unsigned integral.");
677 for (
auto && value : values)
680 return result_buffer;
684 template <std::ranges::range value_range_t>
760 template <std::ranges::forward_range value_range_t>
762 uint16_t
const threshold) &
noexcept
764 static_assert(std::ranges::forward_range<value_range_t>,
"The values must model forward_range.");
766 "An individual value must be an unsigned integral.");
768 result_buffer.
clear();
772 if (result_buffer.
capacity() < counts_per_bin.size())
775 for (
auto [bin,
count] : seqan::stl::views::enumerate(counts_per_bin))
776 if (
count >= threshold)
779 return result_buffer;
783 template <std::ranges::forward_range value_range_t>
785 uint16_t
const threshold) &&
noexcept =
delete;
790 template <
typename t>
794 template <
typename t =
void>
795 [[nodiscard]]
bit_vector const & bulk_contains(
size_t const) &
noexcept
798 always_false<t>::value,
799 "The functionality of the membership_agent has been changed to be analogous to the "
800 "hierarchical_interleaved_bloom_filter's version. As such, the interleaved_bloom_filter's membership_agent "
801 "now only offers membership_for, which returns bin indices that exceed a given threshold when querying a "
802 "range of values. bulk_contains is now part of a new agent: containment_agent. If you want to use "
803 "bulk_contains, change ibf.membership_agent() to ibf.containment_agent().");
807 [[nodiscard]]
bit_vector const & bulk_contains(
size_t const) &&
noexcept =
delete;
Provides seqan::hibf::bit_vector.
An bit vector.
Definition bit_vector.hpp:66
constexpr size_type size() const noexcept
Returns the number of elements.
Definition bit_vector.hpp:651
constexpr size_t count() const noexcept
Returns the number of bits that are set to true.
Definition bit_vector.hpp:630
A data structure that behaves like a std::vector and can be used to consolidate the results of multip...
Definition counting_vector.hpp:145
Manages containment queries for the seqan::hibf::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:523
containment_agent_type(containment_agent_type const &)=default
Defaulted.
containment_agent_type()=default
Defaulted.
bit_vector const & bulk_contains(size_t const value) &noexcept
Determines containment (set membership) of a given value.
containment_agent_type(containment_agent_type &&) noexcept=default
Defaulted.
bit_vector const & bulk_contains(size_t const value) &&noexcept=delete
Deleted. Calling this function on a temporary would result in a dangling reference.
containment_agent_type & operator=(containment_agent_type const &)=default
Defaulted.
Manages counting ranges of values for the seqan::hibf::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:598
counting_vector< value_t > const & bulk_count(value_range_t &&values) &noexcept
Counts the occurrences in each bin for all values in a range.
Definition interleaved_bloom_filter.hpp:669
counting_agent_type()=default
Defaulted.
counting_vector< value_t > const & bulk_count(value_range_t &&values) &&noexcept=delete
Deleted. Calling this function on a temporary would result in a dangling reference.
counting_agent_type(counting_agent_type const &)=default
Defaulted.
counting_agent_type(counting_agent_type &&) noexcept=default
Defaulted.
counting_agent_type & operator=(counting_agent_type const &)=default
Defaulted.
Manages membership queries for the seqan::hibf::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:700
membership_agent_type(membership_agent_type const &)=default
Defaulted.
void sort_results()
Has no effect.
Definition interleaved_bloom_filter.hpp:735
std::vector< uint64_t > const & membership_for(value_range_t &&values, uint16_t const threshold) &&noexcept=delete
Deleted. Calling this function on a temporary would result in a dangling reference.
membership_agent_type(membership_agent_type &&) noexcept=default
Defaulted.
std::vector< uint64_t > const & membership_for(value_range_t &&values, uint16_t const threshold) &noexcept
Determines set membership for all bins contained in this index, based on values and the threshold.
Definition interleaved_bloom_filter.hpp:761
membership_agent_type & operator=(membership_agent_type const &)=default
Defaulted.
membership_agent_type()=default
Defaulted.
The IBF binning directory. A data structure that efficiently answers set-membership queries for multi...
Definition interleaved_bloom_filter.hpp:162
bool track_occupancy
Whether to track the occupancy of the bins.
Definition interleaved_bloom_filter.hpp:481
std::vector< size_t > occupancy
Contains the number of unique values inserted into each bin.
Definition interleaved_bloom_filter.hpp:478
size_t bit_size() const noexcept
Returns the size of the underlying bitvector.
Definition interleaved_bloom_filter.hpp:447
interleaved_bloom_filter(config &configuration, size_t const max_bin_elements=0u)
Construct an Interleaved Bloom Filter.
interleaved_bloom_filter()=default
Defaulted.
counting_agent_type< value_t > counting_agent() const
Returns a seqan::hibf::interleaved_bloom_filter::counting_agent_type to be used for counting.
Definition interleaved_bloom_filter.hpp:398
void increase_bin_number_to(bin_count const new_bin_count)
Increases the number of bins stored in the Interleaved Bloom Filter.
friend struct cereal::base_class
Allow cereal to cast the IBF into its base class.
Definition interleaved_bloom_filter.hpp:169
size_t hash_function_count() const noexcept
Returns the number of hash functions used in the Interleaved Bloom Filter.
Definition interleaved_bloom_filter.hpp:423
void emplace(size_t const value, bin_index const bin) noexcept
Inserts a value into a specific bin.
void clear(bin_index const bin) noexcept
Clears a specific bin.
interleaved_bloom_filter & operator=(interleaved_bloom_filter const &)=default
Defaulted.
bool try_increase_bin_number_to(bin_count const new_bin_count) noexcept
Tries increasing the number of bins stored in the Interleaved Bloom Filter without reallocating memor...
void clear(rng_t &&bin_range) noexcept
Clears a range of bins.
Definition interleaved_bloom_filter.hpp:307
membership_agent_type membership_agent() const
Returns a seqan::hibf::interleaved_bloom_filter::membership_agent_type to be used for lookup.
Definition interleaved_bloom_filter.hpp:812
containment_agent_type containment_agent() const
Returns a seqan::hibf::interleaved_bloom_filter::containment_agent_type to be used for lookup.
Definition interleaved_bloom_filter.hpp:582
friend struct seqan::hibf::inspector
Allow access to private members. Used for util/inspect.
Definition interleaved_bloom_filter.hpp:172
static constexpr uint32_t version
The version of the HIBF.
Definition interleaved_bloom_filter.hpp:486
interleaved_bloom_filter(interleaved_bloom_filter const &)=default
Defaulted.
interleaved_bloom_filter(interleaved_bloom_filter &&) noexcept=default
Defaulted.
size_t bin_size() const noexcept
Returns the size of a single bin that the Interleaved Bloom Filter manages.
Definition interleaved_bloom_filter.hpp:439
size_t bin_count() const noexcept
Returns the number of bins that the Interleaved Bloom Filter manages.
Definition interleaved_bloom_filter.hpp:431
Provides seqan::hibf::counting_vector.
T emplace_back(T... args)
constexpr size_t next_multiple_of_64(size_t const value) noexcept
Returns the smallest integer that is greater or equal to value and a multiple of 64....
Definition next_multiple_of_64.hpp:18
A strong type that represents the number of bins for the seqan::hibf::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:49
A strong type that represents the bin index for the seqan::hibf::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:76
A strong type that represents the number of bits for each bin in the seqan::hibf::interleaved_bloom_f...
Definition interleaved_bloom_filter.hpp:58
The configuration used to build an (H)IBF.
Definition config.hpp:76
A strong type that represents the empty bin fraction for the seqan::hibf::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:85
A strong type that represents the number of hash functions for the seqan::hibf::interleaved_bloom_fil...
Definition interleaved_bloom_filter.hpp:67
A strong type that represents whether to track occupancy for the seqan::hibf::interleaved_bloom_filte...
Definition interleaved_bloom_filter.hpp:94
Provides seqan::hibf::unreachable.
void unreachable()
Marks unreachable code paths.
Definition unreachable.hpp:37