From 3fbf00d3abedb8f1dbf72e9753a68e37bef024aa Mon Sep 17 00:00:00 2001 From: Teo Lemane Date: Fri, 15 Nov 2024 17:59:07 +0000 Subject: [PATCH] logan --- app/kmindex/cli.cpp | 3 +++ app/kmindex/common.hpp | 3 ++- app/kmindex/main.cpp | 3 +++ app/kmindex/query-blob.cpp | 27 +++++++++++++++------------ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/kmindex/cli.cpp b/app/kmindex/cli.cpp index e11a4aa..75e6ae4 100644 --- a/app/kmindex/cli.cpp +++ b/app/kmindex/cli.cpp @@ -13,6 +13,7 @@ namespace kmq { m_kmq_build_opt = std::make_shared(kmq_build_options{}); m_kmq_infos_opt = std::make_shared(kmq_infos_options{}); m_kmq_merge_opt = std::make_shared(kmq_merge_options{}); + m_kmq_queryb_opt = std::make_shared(kmq_queryb_options{}); kmq_build_cli(m_cli_parser, m_kmq_build_opt); kmq_register_cli(m_cli_parser, m_kmq_register_opt); @@ -43,6 +44,8 @@ namespace kmq { return std::make_tuple(kmq_commands::kmq_register, m_kmq_register_opt); else if (m_cli_parser->is("query")) return std::make_tuple(kmq_commands::kmq_query, m_kmq_query_opt); + else if (m_cli_parser->is("query-blob")) + return std::make_tuple(kmq_commands::kmq_query_blob, m_kmq_queryb_opt); else if (m_cli_parser->is("index-infos")) return std::make_tuple(kmq_commands::kmq_index_infos, m_kmq_infos_opt); else if (m_cli_parser->is("merge")) diff --git a/app/kmindex/common.hpp b/app/kmindex/common.hpp index 123e60e..ff0f979 100644 --- a/app/kmindex/common.hpp +++ b/app/kmindex/common.hpp @@ -16,7 +16,8 @@ namespace kmq { kmq_query, kmq_register, kmq_merge, - kmq_index_infos + kmq_index_infos, + kmq_query_blob }; struct kmq_options diff --git a/app/kmindex/main.cpp b/app/kmindex/main.cpp index 21fcada..f865edb 100644 --- a/app/kmindex/main.cpp +++ b/app/kmindex/main.cpp @@ -42,6 +42,9 @@ int main(int argc, char* argv[]) case kmq::kmq_commands::kmq_merge: kmq::main_merge(options); break; + case kmq::kmq_commands::kmq_query_blob: + kmq::main_queryblob(options); + break; } } catch (const bc::ex::BCliError& e) { diff --git a/app/kmindex/query-blob.cpp b/app/kmindex/query-blob.cpp index 25a3364..1d5ddf0 100644 --- a/app/kmindex/query-blob.cpp +++ b/app/kmindex/query-blob.cpp @@ -153,8 +153,6 @@ namespace kmq { { kmq_queryb_options_t o = std::static_pointer_cast(opt); - Timer gtime; - index global(o->global_index_path); spdlog::info( @@ -165,12 +163,16 @@ namespace kmq { o->index_names = global.all(); } else - - spdlog::info("Sub-indexes to query: [{}]", fmt::join(o->index_names, ",")); + spdlog::info("Sub-indexes to query: [{}]", fmt::join(o->index_names, ",")); if (!o->single.empty()) spdlog::warn("--single-query: all query results are kept in memory"); + ThreadPool poolL(opt->nb_threads); + + + poolL.add_task([&o, &global](int i){ + for (auto& index_name : o->index_names) { Timer timer; @@ -194,7 +196,7 @@ namespace kmq { std::size_t n = record.seq.size() - infos.smer_size() + 1; std::vector> m_partitions; auto r = std::make_unique(record.name, n, infos.nb_samples(), infos.bw()); - std::vector m_smers; + std::vector m_smers (infos.nb_partitions()); auto repart = infos.get_repartition(); auto hw = infos.get_hash_w(); @@ -206,28 +208,29 @@ namespace kmq { m_partitions.push_back(std::make_unique(s, infos.nb_samples(), infos.bw(), &itp_client)); } - ThreadPool pool(opt->nb_threads); + //ThreadPool pool(opt->nb_threads); for (std::size_t p = 0; p < infos.nb_partitions(); ++p) { - pool.add_task([&m_smers, &m_partitions, &r, p](int i) { + // pool.add_task([&m_smers, &m_partitions, &r, p](int i) { auto& smers = m_smers[p]; std::sort(std::begin(smers), std::end(smers)); for (auto& [mer, qid] : smers) { m_partitions[p]->query(mer.h, r->get(mer.i)); } - }); + // }); } - pool.join_all(); + //pool.join_all(); query_result_agg aggs; aggs.add(query_result(std::move(r), o->z, infos, false)); aggs.output(infos, o->output, o->format, o->single, o->sk_threshold); - spdlog::info("Done ({}).", gtime.formatted()); + } + }); + poolL.join_all(); } -} -} \ No newline at end of file +}