diff --git a/include/builders/external_memory_builder_partitioned_phf.hpp b/include/builders/external_memory_builder_partitioned_phf.hpp index f56c319..ae2a5c0 100644 --- a/include/builders/external_memory_builder_partitioned_phf.hpp +++ b/include/builders/external_memory_builder_partitioned_phf.hpp @@ -281,7 +281,11 @@ struct external_memory_builder_partitioned_phf { struct meta_partition { meta_partition(std::string const& dir_name, uint64_t id) - : m_filename(dir_name + "/pthash.temp." + std::to_string(id)), m_size(0) {} + : m_filename(dir_name + "/pthash.temp." + std::to_string(id)), m_size(0) { + // Truncate the file if it exists from a previous run + std::ofstream truncate(m_filename.c_str(), std::ofstream::binary | std::ofstream::trunc); + truncate.close(); + } void push_back(hash_type hash) { m_hashes.push_back(hash); @@ -322,4 +326,4 @@ struct external_memory_builder_partitioned_phf { }; }; -} // namespace pthash \ No newline at end of file +} // namespace pthash