Skip to content

Commit 25bf19e

Browse files
committed
fix: histogram
1 parent 3bfce80 commit 25bf19e

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

include/kmtricks/cmd.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#ifdef WITH_HOWDE
5050
#include <cmd_cluster.h>
5151
#include <cmd_build_sbt.h>
52-
#include <cmd_query_km.h>
52+
#include <cmd_query.h>
5353
#endif
5454

5555
namespace km {
@@ -178,14 +178,14 @@ struct main_count
178178
spdlog::debug("[push] - CountTask - S={}, P={}", opt->id, i);
179179
pool.add_task(std::make_shared<CountTask<MAX_K, DMAX_C, SuperKStorageReader>>(
180180
path, config, superk_storage, pinfo, i, KmDir::get().m_fof.get_i(opt->id),
181-
config._kmerSize, opt->c_ab_min, opt->lz4, hist->clone(), opt->clear));
181+
config._kmerSize, opt->c_ab_min, opt->lz4, get_hist_clone(hist), opt->clear));
182182
}
183183
else if (opt->format == "kff")
184184
{
185185
spdlog::debug("[push] - KffCountTask - S={}, P={}", opt->id, i);
186186
pool.add_task(std::make_shared<KffCountTask<MAX_K, DMAX_C, SuperKStorageReader>>(
187187
path, config, superk_storage, pinfo, i, KmDir::get().m_fof.get_i(opt->id),
188-
config._kmerSize, opt->c_ab_min, hist->clone(), opt->clear));
188+
config._kmerSize, opt->c_ab_min, get_hist_clone(hist), opt->clear));
189189
}
190190
}
191191
else if (opt->format == "hash" || opt->format == "vector")
@@ -199,14 +199,14 @@ struct main_count
199199
pool.add_task(std::make_shared<HashCountTask<MAX_K, DMAX_C, SuperKStorageReader>>(
200200
path, config, superk_storage, pinfo, i, KmDir::get().m_fof.get_i(opt->id),
201201
hw.get_window_size_bits(), config._kmerSize, opt->c_ab_min, opt->lz4,
202-
hist->clone(), opt->clear));
202+
get_hist_clone(hist), opt->clear));
203203
}
204204
else
205205
{
206206
spdlog::debug("[push] - HashVecCountTask - S={}, P={}", opt->id, i);
207207
pool.add_task(std::make_shared<HashVecCountTask<MAX_K, DMAX_C, SuperKStorageReader>>(
208208
path, config, superk_storage, pinfo, i, KmDir::get().m_fof.get_i(opt->id),
209-
hw.get_window_size_bits(), config._kmerSize, opt->c_ab_min, opt->lz4, hist->clone(), opt->clear));
209+
hw.get_window_size_bits(), config._kmerSize, opt->c_ab_min, opt->lz4, get_hist_clone(hist), opt->clear));
210210
}
211211
}
212212
}
@@ -700,7 +700,7 @@ struct main_query
700700
for (size_t i=0; i<howde_query.size(); i++)
701701
arr[i] = strdup(howde_query.at(i).c_str());
702702

703-
QueryCommandKm query_cmd("queryKm");
703+
QueryCommand query_cmd("queryKm");
704704
query_cmd.parse(howde_query.size(), arr);
705705
auto path = fs::current_path();
706706

include/kmtricks/histogram.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ class KHist
208208

209209
using hist_t = std::shared_ptr<KHist>;
210210

211+
inline hist_t get_hist_clone(hist_t hist)
212+
{
213+
if (hist)
214+
return hist->clone();
215+
return nullptr;
216+
}
217+
211218
inline std::vector<uint32_t> compute_merge_thresholds(std::vector<hist_t>& histograms,
212219
double p,
213220
const std::string& path)

include/kmtricks/task_scheduler.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class TaskScheduler
202202
sid, p, m_opt->lz4, KM_FILE::KMER);
203203
task = std::make_shared<CountTask<MAX_K, MAX_C, SuperKStorageReader>>(
204204
path, m_config, sk_storage, pinfos, p, iid, m_config._kmerSize,
205-
a_min, m_opt->lz4, m_hists[iid]->clone(), !m_opt->keep_tmp);
205+
a_min, m_opt->lz4, get_hist_clone(m_hists[iid]), !m_opt->keep_tmp);
206206
}
207207
else if (m_opt->kff)
208208
{
@@ -211,7 +211,7 @@ class TaskScheduler
211211
sid, p, m_opt->lz4, KM_FILE::KFF);
212212
task = std::make_shared<KffCountTask<MAX_K, MAX_C, SuperKStorageReader>>(
213213
path, m_config, sk_storage, pinfos, p, iid,
214-
m_config._kmerSize, a_min, m_hists[iid]->clone(), !m_opt->keep_tmp);
214+
m_config._kmerSize, a_min, get_hist_clone(m_hists[iid]), !m_opt->keep_tmp);
215215
}
216216
}
217217
else
@@ -224,7 +224,7 @@ class TaskScheduler
224224
task = std::make_shared<HashCountTask<MAX_K, MAX_C, SuperKStorageReader>>(
225225
path, m_config, sk_storage, pinfos, p, iid,
226226
m_hw.get_window_size_bits(), m_config._kmerSize, a_min, m_opt->lz4,
227-
m_hists[iid]->clone(), !m_opt->keep_tmp);
227+
get_hist_clone(m_hists[iid]), !m_opt->keep_tmp);
228228
}
229229
else
230230
{
@@ -234,7 +234,7 @@ class TaskScheduler
234234
task = std::make_shared<HashVecCountTask<MAX_K, MAX_C, SuperKStorageReader>>(
235235
path, m_config, sk_storage, pinfos, p, iid,
236236
m_hw.get_window_size_bits(), m_config._kmerSize, a_min, m_opt->lz4,
237-
m_hists[iid]->clone(), !m_opt->keep_tmp);
237+
get_hist_clone(m_hists[iid]), !m_opt->keep_tmp);
238238
}
239239
}
240240
if (m_is_info) task->set_callback([this](){ this->m_dyn[1].tick(); });
@@ -290,7 +290,7 @@ class TaskScheduler
290290
sid, p, this->m_opt->lz4, KM_FILE::KMER);
291291
task = std::make_shared<CountTask<MAX_K, MAX_C, SuperKStorageReader>>(
292292
path, this->m_config, sk_storage, pinfos, p, iid,
293-
this->m_config._kmerSize, a_min, m_opt->lz4, this->m_hists[iid]->clone(),
293+
this->m_config._kmerSize, a_min, m_opt->lz4, get_hist_clone(this->m_hists[iid]),
294294
!this->m_opt->keep_tmp);
295295
}
296296
else if (m_opt->kff)
@@ -300,7 +300,7 @@ class TaskScheduler
300300
sid, p, this->m_opt->lz4, KM_FILE::KFF);
301301
task = std::make_shared<KffCountTask<MAX_K, MAX_C, SuperKStorageReader>>(
302302
path, this->m_config, sk_storage, pinfos, p, iid,
303-
this->m_config._kmerSize, a_min, this->m_hists[iid]->clone(), !this->m_opt->keep_tmp);
303+
this->m_config._kmerSize, a_min, get_hist_clone(this->m_hists[iid]), !this->m_opt->keep_tmp);
304304
}
305305
}
306306
else
@@ -313,7 +313,7 @@ class TaskScheduler
313313
task = std::make_shared<HashCountTask<MAX_K, MAX_C, SuperKStorageReader>>(
314314
path, m_config, sk_storage, pinfos, p, iid,
315315
m_hw.get_window_size_bits(), m_config._kmerSize, a_min, m_opt->lz4,
316-
m_hists[iid]->clone(), !this->m_opt->keep_tmp);
316+
get_hist_clone(this->m_hists[iid]), !this->m_opt->keep_tmp);
317317
}
318318
else
319319
{
@@ -323,7 +323,7 @@ class TaskScheduler
323323
task = std::make_shared<HashVecCountTask<MAX_K, MAX_C, SuperKStorageReader>>(
324324
path, this->m_config, sk_storage, pinfos, p, iid,
325325
this->m_hw.get_window_size_bits(), this->m_config._kmerSize, a_min, false,
326-
this->m_hists[iid]->clone(), !this->m_opt->keep_tmp);
326+
get_hist_clone(this->m_hists[iid]), !this->m_opt->keep_tmp);
327327
}
328328
}
329329
if (m_is_info)

0 commit comments

Comments
 (0)