1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use super::*;
#[async_trait::async_trait]
pub trait BloomDataProvider: Send + Sync {
async fn read_byte(&self, index: u64) -> Result<u8>;
}
#[async_trait::async_trait]
pub trait BloomProvider<Key: Send + Sync>: Sync + Send {
type Filter: FilterTrait<Key>;
async fn check_filter(&self, item: &Key) -> FilterResult;
fn check_filter_fast(&self, item: &Key) -> FilterResult;
async fn offload_buffer(&mut self, needed_memory: usize, level: usize) -> usize;
async fn get_filter(&self) -> Option<Self::Filter>;
fn get_filter_fast(&self) -> Option<&Self::Filter>;
async fn filter_memory_allocated(&self) -> usize;
}
#[async_trait::async_trait]
pub trait FilterTrait<Key: Send + Sync>: Clone + Sync + Send {
fn add(&mut self, key: &Key);
fn contains_fast(&self, key: &Key) -> FilterResult;
async fn contains<P: BloomDataProvider>(&self, _provider: &P, key: &Key) -> FilterResult {
self.contains_fast(key)
}
fn offload_filter(&mut self) -> usize {
0
}
#[must_use]
fn checked_add_assign(&mut self, other: &Self) -> bool;
fn memory_allocated(&self) -> usize {
0
}
}