Files
scylla/utils/i_filter.hh
Avi Kivity 5937b1fa23 treewide: remove empty comments in top-of-files
After fcb8d040 ("treewide: use Software Package Data Exchange
(SPDX) license identifiers"), many dual-licensed files were
left with empty comments on top. Remove them to avoid visual
noise.

Closes #10562
2022-05-13 07:11:58 +02:00

58 lines
1.4 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*
* Modified by ScyllaDB
*/
/*
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
*/
#pragma once
#include "bytes.hh"
#include "bloom_calculations.hh"
namespace utils {
struct i_filter;
using filter_ptr = std::unique_ptr<i_filter>;
enum class filter_format {
k_l_format,
m_format,
};
class hashed_key {
private:
std::array<uint64_t, 2> _hash;
public:
hashed_key(std::array<uint64_t, 2> h) : _hash(h) {}
std::array<uint64_t, 2> hash() const { return _hash; };
};
hashed_key make_hashed_key(bytes_view key);
// FIXME: serialize() and serialized_size() not implemented. We should only be serializing to
// disk, not in the wire.
struct i_filter {
virtual ~i_filter() {}
virtual void add(const bytes_view& key) = 0;
virtual bool is_present(const bytes_view& key) = 0;
virtual bool is_present(hashed_key) = 0;
virtual void clear() = 0;
virtual void close() = 0;
virtual size_t memory_size() = 0;
/**
* @return The smallest bloom_filter that can provide the given false
* positive probability rate for the given number of elements.
*
* Asserts that the given probability can be satisfied using this
* filter.
*/
static filter_ptr get_filter(int64_t num_elements, double max_false_pos_prob, filter_format format);
};
}