diff --git a/include/valik/search/search_distributed.hpp b/include/valik/search/search_distributed.hpp index 929c8c35..a8f27fdd 100644 --- a/include/valik/search/search_distributed.hpp +++ b/include/valik/search/search_distributed.hpp @@ -14,15 +14,24 @@ namespace valik::app /** * @brief Function that calls Valik prefiltering and launches parallel processes of Stellar search. * - * @tparam index_t Type of IBF. + * @tparam compressed IBF layout type. * @param arguments Command line arguments. * @param time_statistics Run-time statistics. - * @param index Interleaved Bloom Filter. * @return false if search failed. */ -template -bool search_distributed(search_arguments const & arguments, search_time_statistics & time_statistics, index_t const & index) +template +bool search_distributed(search_arguments const & arguments, search_time_statistics & time_statistics) { + using index_structure_t = std::conditional_t; + auto index = valik_index{}; + + { + auto start = std::chrono::high_resolution_clock::now(); + load_index(index, arguments.index_file); + auto end = std::chrono::high_resolution_clock::now(); + time_statistics.index_io_time += std::chrono::duration_cast>(end - start).count(); + } + std::optional ref_meta; if (!arguments.ref_meta_path.empty()) ref_meta = database_metadata(arguments.ref_meta_path, false); diff --git a/include/valik/search/search_local.hpp b/include/valik/search/search_local.hpp index f993c3ca..cd1d48d7 100644 --- a/include/valik/search/search_local.hpp +++ b/include/valik/search/search_local.hpp @@ -24,15 +24,25 @@ namespace valik::app /** * @brief Function that calls Valik prefiltering and launches parallel threads of Stellar search. * - * @tparam index_t Type of IBF. + * @tparam compressed IBF layout type. + * @tparam is_split Split query sequences. * @param arguments Command line arguments. * @param time_statistics Run-time statistics. - * @param index Interleaved Bloom Filter. * @return false if search failed. */ -template -bool search_local(search_arguments const & arguments, search_time_statistics & time_statistics, index_t const & index) +template +bool search_local(search_arguments const & arguments, search_time_statistics & time_statistics) { + using index_structure_t = std::conditional_t; + auto index = valik_index{}; + + { + auto start = std::chrono::high_resolution_clock::now(); + load_index(index, arguments.index_file); + auto end = std::chrono::high_resolution_clock::now(); + time_statistics.index_io_time += std::chrono::duration_cast>(end - start).count(); + } + std::optional ref_meta; if (!arguments.ref_meta_path.empty()) ref_meta = database_metadata(arguments.ref_meta_path, false); diff --git a/src/valik_search.cpp b/src/valik_search.cpp index 6d3eff34..5df4f879 100644 --- a/src/valik_search.cpp +++ b/src/valik_search.cpp @@ -6,34 +6,42 @@ namespace valik::app /** * @brief Function that loads the index and launches local or distributed search. * + * @tparam compressed Interleaved Bloom Filter layout type. * @param arguments Command line arguments. */ void valik_search(search_arguments const & arguments) { - search_time_statistics time_statistics{}; - //!TODO: this switch doesn't work, make is_compressed template parameter - using index_structure_t = index_structure::ibf; - if (arguments.compressed) - using index_structure_t = index_structure::ibf_compressed; - auto index = valik_index{}; + search_time_statistics time_statistics{}; + bool failed; + if (arguments.distribute) { - auto start = std::chrono::high_resolution_clock::now(); - load_index(index, arguments.index_file); - auto end = std::chrono::high_resolution_clock::now(); - time_statistics.index_io_time += std::chrono::duration_cast>(end - start).count(); + if (arguments.compressed) + failed = search_distributed(arguments, time_statistics); + else + failed = search_distributed(arguments, time_statistics); } - bool failed; - if (arguments.distribute) - failed = search_distributed(arguments, time_statistics, index); + // Shared memory execution else { - if (arguments.query_seg_path.empty()) - failed = search_local(arguments, time_statistics, index); + if (arguments.compressed) + { + if (arguments.query_seg_path.empty()) + failed = search_local(arguments, time_statistics); + // Split long query sequences + else + failed = search_local(arguments, time_statistics); + } else - failed = search_local(arguments, time_statistics, index); + { + if (arguments.query_seg_path.empty()) + failed = search_local(arguments, time_statistics); + // Split long query sequences + else + failed = search_local(arguments, time_statistics); + } } if (arguments.write_time)