Skip to content

Commit

Permalink
Some unnecessary stuff removed from the database.
Browse files Browse the repository at this point in the history
  • Loading branch information
agudys committed Jun 19, 2024
1 parent 392991a commit 47fbe62
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
22 changes: 12 additions & 10 deletions src/prefix_kmer_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void PrefixKmerDb::initialize(uint32_t kmerLength, double fraction) {

size_t binsCount = 1 << prefixBits;

prefixHistogram.resize(binsCount + 1);
//prefixHistogram.resize(binsCount + 1);
hashtables.resize(binsCount);
}

Expand Down Expand Up @@ -112,10 +112,10 @@ void PrefixKmerDb::hashtableJob() {
for (uint32_t i = lo + 1; i < hi; ++i) {
kmer_t prefix = GET_PREFIX_SHIFTED(kmers[i]);
if (prefix != prevPrefix) {
prefixHistogram[prevPrefix] = i - begin;
//prefixHistogram[prevPrefix] = i - begin;

// ---
reallocsCount += hashtables[prevPrefix].reserve_for_additional(prefixHistogram[prevPrefix]);
reallocsCount += hashtables[prevPrefix].reserve_for_additional(i - begin);
htBytes += hashtables[prevPrefix].get_bytes();
// ---

Expand All @@ -126,9 +126,9 @@ void PrefixKmerDb::hashtableJob() {
}

// add remanining
prefixHistogram[hi_prefix] = hi - begin;
//prefixHistogram[hi_prefix] = hi - begin;

reallocsCount += hashtables[hi_prefix].reserve_for_additional(prefixHistogram[hi_prefix]);
reallocsCount += hashtables[hi_prefix].reserve_for_additional(hi - begin);
htBytes += hashtables[hi_prefix].get_bytes();


Expand Down Expand Up @@ -539,10 +539,12 @@ sample_id_t PrefixKmerDb::addKmers(
times.hashtableProcess += std::chrono::high_resolution_clock::now() - start;

#ifdef _DEBUG
/*
uint32_t histoSum = std::accumulate(prefixHistogram.begin(), prefixHistogram.end(), 0);
if (histoSum != n_kmers) {
throw std::runtime_error("PrefixKmerDb::addKmers() - invalid histogram sum");
}
*/
#endif

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -821,8 +823,8 @@ void PrefixKmerDb::serialize(std::ofstream& file, bool rawHashtables) const {
LOG_NORMAL << endl;

// save prefix histogram
save(file, prefixHistogram.size());
file.write(reinterpret_cast<const char*>(prefixHistogram.data()), prefixHistogram.size() * sizeof(uint32_t));
//save(file, prefixHistogram.size());
//file.write(reinterpret_cast<const char*>(prefixHistogram.data()), prefixHistogram.size() * sizeof(uint32_t));
}

// *****************************************************************************************
Expand Down Expand Up @@ -997,9 +999,9 @@ bool PrefixKmerDb::deserialize(std::ifstream& file, DeserializationMode mode) {
}

// load prefix histogram
load(file, temp);
prefixHistogram.resize(temp);
file.read(reinterpret_cast<char*>(prefixHistogram.data()), prefixHistogram.size() * sizeof(uint32_t));
//load(file, temp);
//prefixHistogram.resize(temp);
//file.read(reinterpret_cast<char*>(prefixHistogram.data()), prefixHistogram.size() * sizeof(uint32_t));

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/prefix_kmer_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PrefixKmerDb : public AbstractKmerDb {
std::ostringstream oss;

size_t otherBytes =
prefixHistogram.capacity() * sizeof(uint32_t) +
//prefixHistogram.capacity() * sizeof(uint32_t) +
hashtables.capacity() * sizeof(hash_map_lp<suffix_t, pattern_id_t>) +
samplePatterns.get_bytes();

Expand Down Expand Up @@ -126,7 +126,7 @@ class PrefixKmerDb : public AbstractKmerDb {

std::atomic<size_t> kmersCount{ 0 };

std::vector<uint32_t> prefixHistogram;
//std::vector<uint32_t> prefixHistogram;

std::vector<hash_map_lp<suffix_t, pattern_id_t>> hashtables;
std::vector<std::vector<pair<suffix_t, pattern_id_t>>> suffix_kmers;
Expand Down
7 changes: 5 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#pragma once

#define VERSION "2.0.1"
#define VERSION "2.0.2"
#define DATE "19.06.2024"

/*
Version history
2.0.1 (19.06.2024)
2.0.2 (19.06.2024)
- Some unneccessary stuff removed from the database.
2.0.1 (18.06.2024)
- Improved parallelization scheme.
Expand Down

0 comments on commit 47fbe62

Please sign in to comment.