Skip to content

Commit

Permalink
avoid merge if num_files_to_merge is 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jermp committed May 25, 2022
1 parent 90cc9ff commit a5f26c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions include/builder/build_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ struct bucket_pairs {
}

std::string get_bucket_pairs_filename() const {
if (m_num_files_to_merge == 1) return get_tmp_output_filename(0);
std::stringstream filename;
filename << m_tmp_dirname << "/sshash.tmp.run_" << m_run_identifier << ".bucket_pairs.bin";
return filename.str();
}

void merge() {
if (m_num_files_to_merge == 0) return;

assert(m_num_files_to_merge > 0);
std::cout << "files to merge = " << m_num_files_to_merge << std::endl;
if (m_num_files_to_merge <= 1) return;

assert(m_num_files_to_merge > 1);

struct iterator_type {
iterator_type(bucket_pair const* b, bucket_pair const* e) : begin(b), end(e) {}
Expand Down Expand Up @@ -164,7 +165,7 @@ struct bucket_pairs {
std::string m_tmp_dirname;
std::vector<bucket_pair> m_buffer;

std::string get_tmp_output_filename(uint64_t id) {
std::string get_tmp_output_filename(uint64_t id) const {
std::stringstream filename;
filename << m_tmp_dirname << "/sshash.tmp.run_" << m_run_identifier << ".bucket_pairs."
<< id << ".bin";
Expand Down
4 changes: 2 additions & 2 deletions include/builder/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ struct minimizers_tuples {
}

void merge() {
std::cout << "files to merge = " << m_num_files_to_merge << std::endl;
if (m_num_files_to_merge == 0) return;

assert(m_num_files_to_merge > 0);
std::cout << "files to merge = " << m_num_files_to_merge << std::endl;

struct iterator_type {
iterator_type(minimizer_tuple const* b, minimizer_tuple const* e) : begin(b), end(e) {}
Expand Down Expand Up @@ -305,7 +305,7 @@ struct minimizers_tuples {
std::string m_tmp_dirname;
std::vector<minimizer_tuple> m_buffer;

std::string get_tmp_output_filename(uint64_t id) {
std::string get_tmp_output_filename(uint64_t id) const {
std::stringstream filename;
filename << m_tmp_dirname << "/sshash.tmp.run_" << m_run_identifier << ".minimizers." << id
<< ".bin";
Expand Down

0 comments on commit a5f26c1

Please sign in to comment.