Skip to content

Commit

Permalink
Merge pull request #53 from progval/set-seed
Browse files Browse the repository at this point in the history
Set m_seed in build_from_hashes instead of build_from_keys
  • Loading branch information
jermp authored Apr 30, 2024
2 parents 28aedcb + 937d1d2 commit 56132a9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/builders/internal_memory_builder_single_phf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ struct internal_memory_builder_single_phf {
template <typename RandomAccessIterator>
build_timings build_from_keys(RandomAccessIterator keys, uint64_t num_keys,
build_configuration const& config) {
build_configuration actual_config = config;
if (config.seed == constants::invalid_seed) {
for (auto attempt = 0; attempt < 10; ++attempt) {
m_seed = random_value();
actual_config.seed = random_value();
try {
return build_from_hashes(hash_generator<RandomAccessIterator>(keys, m_seed),
num_keys, config);
return build_from_hashes(hash_generator<RandomAccessIterator>(keys, actual_config.seed),
num_keys, actual_config);
} catch (seed_runtime_error const& error) {
std::cout << "attempt " << attempt + 1 << " failed" << std::endl;
}
}
throw seed_runtime_error();
}
m_seed = config.seed;
return build_from_hashes(hash_generator<RandomAccessIterator>(keys, m_seed), num_keys,
return build_from_hashes(hash_generator<RandomAccessIterator>(keys, config.seed), num_keys,
config);
}

Expand All @@ -54,6 +54,7 @@ struct internal_memory_builder_single_phf {
? (std::ceil((config.c * num_keys) / std::log2(num_keys)))
: config.num_buckets;

m_seed = config.seed;
m_num_keys = num_keys;
m_table_size = table_size;
m_num_buckets = num_buckets;
Expand Down

0 comments on commit 56132a9

Please sign in to comment.