Skip to content

Commit

Permalink
significant speedup for PHMAP loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-eyes committed Mar 17, 2020
1 parent 937e511 commit 351802a
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/kDataFrames/kDataFramePHMAP.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "kDataFrame.hpp"
#include <cereal/types/unordered_map.hpp>
#include <cereal/types/memory.hpp>
#include <cereal/archives/binary.hpp>
#include "parallel_hashmap/phmap_dump.h"
#include <iostream>
#include <fstream>
#include "Utils/kmer.h"
Expand Down Expand Up @@ -197,11 +195,12 @@ void kDataFramePHMAP::save(string filePath) {
// Write the kmerSize
ofstream file(filePath + ".extra");
file << kSize << endl;

std::ofstream os(filePath + ".phmap", std::ios::binary);
cereal::BinaryOutputArchive archive(os);
archive(this->MAP);

filePath += ".phmap";
{
phmap::BinaryOutputArchive ar_out(filePath.c_str());
this->MAP.dump(ar_out);
}

}

kDataFrame *kDataFramePHMAP::load(string filePath) {
Expand All @@ -211,13 +210,13 @@ kDataFrame *kDataFramePHMAP::load(string filePath) {
uint64_t kSize;
file >> kSize;

// Initialize kDataFramePHMAP
kDataFramePHMAP *KMAP = new kDataFramePHMAP(kSize);
filePath += ".phmap";

// Load the hashMap into the kDataFramePHMAP
std::ifstream os(filePath + ".phmap", std::ios::binary);
cereal::BinaryInputArchive iarchive(os);
iarchive(KMAP->MAP);
kDataFramePHMAP *KMAP = new kDataFramePHMAP(kSize);
{
phmap::BinaryInputArchive ar_in(filePath.c_str());
KMAP->MAP.load(ar_in);
}

return KMAP;
}
Expand Down

1 comment on commit 351802a

@mr-eyes
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes: #42

Please sign in to comment.