16#include <cereal/cereal.hpp>
17#include <cereal/macros.hpp>
18#include <cereal/types/vector.hpp>
20#include <hibf/cereal/concepts.hpp>
21#include <hibf/config.hpp>
23#include <hibf/layout/layout.hpp>
144 size_t number_of_user_bins{};
152 template <std::
integral value_t>
247 template <std::
integral value_t = u
int16_t>
268 template <seqan::hibf::cereal_archive archive_t>
269 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
271 uint32_t parsed_version{
version};
272 archive(cereal::make_nvp(
"version", parsed_version));
273 archive(number_of_user_bins);
285 concurrent_timer layout_union_estimation_timer{};
286 concurrent_timer layout_rearrangement_timer{};
287 concurrent_timer layout_dp_algorithm_timer{};
288 concurrent_timer index_allocation_timer{};
289 concurrent_timer user_bin_io_timer{};
290 concurrent_timer merge_kmers_timer{};
291 concurrent_timer fill_ibf_timer{};
304 template <seqan::hibf::cereal_archive archive_t>
305 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
313hierarchical_interleaved_bloom_filter::operator==(hierarchical_interleaved_bloom_filter
const &)
const =
default;
322 template <std::ranges::forward_range value_range_t>
323 void membership_for_impl(value_range_t && values,
size_t const ibf_idx, uint16_t
const threshold)
325 auto agent = hibf_ptr->
ibf_vector[ibf_idx].template counting_agent<uint16_t>();
326 auto & result = agent.bulk_count(values);
330 for (
size_t bin{}; bin < result.size(); ++bin)
340 case bin_kind::deleted:
342 case bin_kind::merged:
343 if (sum >= threshold)
344 membership_for_impl(values, hibf_ptr->
next_ibf_id[ibf_idx][bin], threshold);
350 if (sum >= threshold)
425 template <std::ranges::forward_range value_range_t>
427 uint16_t
const threshold) &
noexcept
429 assert(hibf_ptr !=
nullptr);
431 static_assert(std::ranges::forward_range<value_range_t>,
"The values must model forward_range.");
433 "An individual value must be an unsigned integral.");
435 result_buffer.
clear();
437 membership_for_impl(values, 0u, threshold);
439 return result_buffer;
443 template <std::ranges::range value_range_t>
445 uint16_t
const threshold) &&
noexcept =
delete;
455template <std::
integral value_t>
463 template <std::ranges::forward_range value_range_t>
464 void bulk_count_impl(value_range_t && values,
size_t const ibf_idx,
size_t const threshold)
466 auto agent = hibf_ptr->
ibf_vector[ibf_idx].template counting_agent<value_t>();
467 auto & result = agent.bulk_count(values);
471 for (
size_t bin{}; bin < result.size(); ++bin)
481 case bin_kind::deleted:
483 case bin_kind::merged:
484 if (sum >= threshold)
485 bulk_count_impl(values, hibf_ptr->
next_ibf_id[ibf_idx][bin], threshold);
491 if (sum >= threshold)
492 result_buffer[user_bin_id] = sum;
518 hibf_ptr(
std::addressof(hibf)),
519 result_buffer(hibf_ptr->number_of_user_bins)
550 template <std::ranges::forward_range value_range_t>
552 size_t const threshold) &
noexcept
554 assert(hibf_ptr !=
nullptr);
555 assert(threshold > 0u);
556 assert(result_buffer.
size() == hibf_ptr->number_of_user_bins);
558 static_assert(std::ranges::forward_range<value_range_t>,
"The values must model forward_range.");
560 "An individual value must be an unsigned integral.");
564 bulk_count_impl(values, 0u, threshold);
566 return result_buffer;
570 template <std::ranges::range value_range_t>
572 size_t const threshold) &&
noexcept =
delete;
576template <std::
integral value_t>
A timer with a thread-safe operator+=().
Definition timer.hpp:155
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 counting ranges of values for the seqan::hibf::hierarchical_interleaved_bloom_filter.
Definition hierarchical_interleaved_bloom_filter.hpp:457
counting_agent_type(counting_agent_type const &)=default
Defaulted.
counting_agent_type(counting_agent_type &&)=default
Defaulted.
counting_agent_type & operator=(counting_agent_type const &)=default
Defaulted.
counting_vector< value_t > const & bulk_count(value_range_t &&values, size_t const threshold) &&noexcept=delete
Deleted. Calling this function on a temporary would result in a dangling reference.
counting_agent_type & operator=(counting_agent_type &&)=default
Defaulted.
counting_agent_type()=default
Defaulted.
~counting_agent_type()=default
Defaulted.
counting_vector< value_t > const & bulk_count(value_range_t &&values, size_t const threshold) &noexcept
Counts the occurrences in each bin for all values in a range.
Definition hierarchical_interleaved_bloom_filter.hpp:551
Definition hierarchical_interleaved_bloom_filter.hpp:316
membership_agent_type(membership_agent_type &&)=default
Defaulted.
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()=default
Defaulted.
membership_agent_type & operator=(membership_agent_type &&)=default
Defaulted.
membership_agent_type & operator=(membership_agent_type const &)=default
Defaulted.
std::vector< uint64_t > const & membership_for(value_range_t &&values, uint16_t const threshold) &noexcept
Determines set membership for all user bins contained in this index, based on values and the threshol...
Definition hierarchical_interleaved_bloom_filter.hpp:426
void sort_results()
Sorts the results.
Definition hierarchical_interleaved_bloom_filter.hpp:381
membership_agent_type(membership_agent_type const &)=default
Defaulted.
~membership_agent_type()=default
Defaulted.
The Hierarchical Interleaved Bloom Filter (HIBF) - Fast answers to set-membership queries for multipl...
Definition hierarchical_interleaved_bloom_filter.hpp:139
~hierarchical_interleaved_bloom_filter()=default
Defaulted.
std::vector< previous_ibf_id_pair > prev_ibf_id
Stores for each IBF of the HIBF the ID of the parent IBF and the bin index of the parent IBF.
Definition hierarchical_interleaved_bloom_filter.hpp:230
hierarchical_interleaved_bloom_filter(config &configuration, layout::layout const &layout)
[Advanced] Constructs the HIBF from a config and layout.
std::vector< std::vector< uint64_t > > ibf_bin_to_user_bin_id
Stores for each bin in each IBF of the HIBF the user bin ID.
Definition hierarchical_interleaved_bloom_filter.hpp:239
hierarchical_interleaved_bloom_filter(config &configuration)
Constructs the HIBF from the given configuration.
hierarchical_interleaved_bloom_filter & operator=(hierarchical_interleaved_bloom_filter &&)=default
Defaulted.
std::vector< interleaved_bloom_filter > ibf_vector
The individual interleaved Bloom filters.
Definition hierarchical_interleaved_bloom_filter.hpp:210
counting_agent_type< value_t > counting_agent() const
Returns a counting_agent_type to be used for counting.
Definition hierarchical_interleaved_bloom_filter.hpp:578
membership_agent_type membership_agent() const
Returns a membership_agent to be used for counting.
Definition hierarchical_interleaved_bloom_filter.hpp:450
hierarchical_interleaved_bloom_filter()=default
Defaulted.
std::vector< std::vector< uint64_t > > next_ibf_id
Stores for each bin in each IBF of the HIBF the ID of the next IBF.
Definition hierarchical_interleaved_bloom_filter.hpp:219
hierarchical_interleaved_bloom_filter & operator=(hierarchical_interleaved_bloom_filter const &)=default
Defaulted.
hierarchical_interleaved_bloom_filter(hierarchical_interleaved_bloom_filter &&)=default
Defaulted.
hierarchical_interleaved_bloom_filter(hierarchical_interleaved_bloom_filter const &)=default
Defaulted.
static constexpr uint32_t version
The version of the HIBF.
Definition hierarchical_interleaved_bloom_filter.hpp:259
Provides seqan::hibf::counting_vector.
T emplace_back(T... args)
Provides seqan::hibf::interleaved_bloom_filter.
The configuration used to build an (H)IBF.
Definition config.hpp:76
Contains information about the parent IBF and bin index.
Definition hierarchical_interleaved_bloom_filter.hpp:298
size_t ibf_idx
The index of the parent IBF in ibf_vector.
Definition hierarchical_interleaved_bloom_filter.hpp:299
size_t bin_idx
The index of the bin in the parent IBF of which an IBF is the child of.
Definition hierarchical_interleaved_bloom_filter.hpp:300
The layout.
Definition layout.hpp:36
Provides seqan::hibf::timer.