Instead of lengthy blurbs, switch to single-line, machine-readable standardized (https://spdx.dev) license identifiers. The Linux kernel switched long ago, so there is strong precedent. Three cases are handled: AGPL-only, Apache-only, and dual licensed. For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0), reasoning that our changes are extensive enough to apply our license. The changes we applied mechanically with a script, except to licenses/README.md. Closes #9937
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
|
|
/*
|
|
* Copyright (C) 2015-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include "log.hh"
|
|
#include "bloom_filter.hh"
|
|
#include "bloom_calculations.hh"
|
|
#include <seastar/core/thread.hh>
|
|
|
|
namespace utils {
|
|
static logging::logger filterlog("bloom_filter");
|
|
|
|
filter_ptr i_filter::get_filter(int64_t num_elements, double max_false_pos_probability, filter_format fformat) {
|
|
assert(seastar::thread::running_in_thread());
|
|
|
|
if (max_false_pos_probability > 1.0) {
|
|
throw std::invalid_argument(format("Invalid probability {:f}: must be lower than 1.0", max_false_pos_probability));
|
|
}
|
|
|
|
if (max_false_pos_probability == 1.0) {
|
|
return std::make_unique<filter::always_present_filter>();
|
|
}
|
|
|
|
int buckets_per_element = bloom_calculations::max_buckets_per_element(num_elements);
|
|
auto spec = bloom_calculations::compute_bloom_spec(buckets_per_element, max_false_pos_probability);
|
|
return filter::create_filter(spec.K, num_elements, spec.buckets_per_element, fformat);
|
|
}
|
|
|
|
hashed_key make_hashed_key(bytes_view b) {
|
|
std::array<uint64_t, 2> h;
|
|
utils::murmur_hash::hash3_x64_128(b, 0, h);
|
|
return { h };
|
|
}
|
|
|
|
}
|