45 template <
typename index_t,
typename query_t,
typename configuration_t>
46 inline auto search_single(index_t
const & index, query_t & query, configuration_t
const & cfg)
48 using cfg_t = remove_cvref_t<configuration_t>;
51 detail::search_param max_error{0, 0, 0, 0};
52 if constexpr (cfg.template exists<search_cfg::max_error>())
54 auto & [total, subs, ins, del] = max_error;
56 get<search_cfg::max_error>(cfg).value);
58 else if constexpr (cfg.template exists<search_cfg::max_error_rate>())
62 auto & [total, subs, ins, del] = max_error;
66 }, get<search_cfg::max_error_rate>(cfg).value);
76 auto internal_delegate = [&internal_hits, &max_error] (
auto const & it)
82 if constexpr (cfg_t::template exists<search_cfg::mode<detail::search_mode_best>>())
84 detail::search_param max_error2{max_error};
86 while (internal_hits.
empty() && max_error2.total <= max_error.total)
88 detail::search_algo<true>(index, query, max_error2, internal_delegate);
92 else if constexpr (cfg_t::template exists<search_cfg::mode<detail::search_mode_all_best>>())
94 detail::search_param max_error2{max_error};
96 while (internal_hits.
empty() && max_error2.total <= max_error.total)
98 detail::search_algo<false>(index, query, max_error2, internal_delegate);
102 else if constexpr (cfg_t::template exists<search_cfg::mode<search_cfg::strata>>())
104 detail::search_param max_error2{max_error};
105 max_error2.total = 0;
106 while (internal_hits.
empty() && max_error2.total <= max_error.total)
108 detail::search_algo<true>(index, query, max_error2, internal_delegate);
111 if (!internal_hits.
empty())
113 internal_hits.
clear();
114 uint8_t
const s = get<search_cfg::mode>(cfg).value;
115 max_error2.total += s - 1;
116 detail::search_algo<false>(index, query, max_error2, internal_delegate);
121 detail::search_algo<false>(index, query, max_error, internal_delegate);
127 if constexpr (cfg_t::template exists<search_cfg::output<detail::search_output_index_cursor>>())
129 return internal_hits;
135 typename index_t::size_type>;
138 if constexpr (cfg_t::template exists<search_cfg::mode<detail::search_mode_best>>())
141 if (!internal_hits.
empty())
143 auto text_pos = internal_hits[0].lazy_locate();
149 for (
auto const & cur : internal_hits)
151 for (
auto const & text_pos : cur.locate())
179 template <
typename index_t,
typename queries_t,
typename configuration_t>
180 inline auto search_all(index_t
const & index, queries_t & queries, configuration_t
const & cfg)
182 using cfg_t = remove_cvref_t<configuration_t>;
188 std::pair<typename index_t::size_type, typename index_t::size_type>,
189 typename index_t::size_type>;
191 typename index_t::cursor_type,
199 for (
auto const query : queries)
201 hits.
push_back(search_single(index, query, cfg));
208 return search_single(index, queries, cfg);
Provides the algorithm to search in an index using search schemes.
Provides various transformation trait base templates and shortcuts.
Provides the concepts for seqan3::fm_index and seqan3::bi_fm_index and its traits and cursors...
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
Specifies requirements of a Range type for which begin returns a type that models std::RandomAccessIt...
Provides an approximate string matching algorithm based on simple backtracking. This should only be u...
Specifies requirements of a Range type for which begin returns a type that models std::ForwardIterato...
Definition: aligned_sequence_concept.hpp:35
Meta-header for the search configuration module .