Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set m_seed in build_from_hashes instead of build_from_keys #53

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading