Skip to content

Commit

Permalink
logan
Browse files Browse the repository at this point in the history
  • Loading branch information
tlemane committed Nov 15, 2024
1 parent dec5056 commit 3fbf00d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
3 changes: 3 additions & 0 deletions app/kmindex/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace kmq {
m_kmq_build_opt = std::make_shared<struct kmq_build_options>(kmq_build_options{});
m_kmq_infos_opt = std::make_shared<struct kmq_infos_options>(kmq_infos_options{});
m_kmq_merge_opt = std::make_shared<struct kmq_merge_options>(kmq_merge_options{});
m_kmq_queryb_opt = std::make_shared<struct kmq_queryb_options>(kmq_queryb_options{});

kmq_build_cli(m_cli_parser, m_kmq_build_opt);
kmq_register_cli(m_cli_parser, m_kmq_register_opt);
Expand Down Expand Up @@ -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"))
Expand Down
3 changes: 2 additions & 1 deletion app/kmindex/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace kmq {
kmq_query,
kmq_register,
kmq_merge,
kmq_index_infos
kmq_index_infos,
kmq_query_blob
};

struct kmq_options
Expand Down
3 changes: 3 additions & 0 deletions app/kmindex/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 15 additions & 12 deletions app/kmindex/query-blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ namespace kmq {
{
kmq_queryb_options_t o = std::static_pointer_cast<struct kmq_queryb_options>(opt);

Timer gtime;

index global(o->global_index_path);

spdlog::info(
Expand All @@ -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;
Expand All @@ -194,7 +196,7 @@ namespace kmq {
std::size_t n = record.seq.size() - infos.smer_size() + 1;
std::vector<std::unique_ptr<blob_partition>> m_partitions;
auto r = std::make_unique<query_response>(record.name, n, infos.nb_samples(), infos.bw());
std::vector<qpart_type> m_smers;
std::vector<qpart_type> m_smers (infos.nb_partitions());

auto repart = infos.get_repartition();
auto hw = infos.get_hash_w();
Expand All @@ -206,28 +208,29 @@ namespace kmq {
m_partitions.push_back(std::make_unique<blob_partition>(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();
}
}

}
}

0 comments on commit 3fbf00d

Please sign in to comment.