Skip to content

Commit f03ab8b

Browse files
committed
introduce frame count base strategy
1 parent a04c71c commit f03ab8b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use super::SwapStrategy;
2+
3+
/// A swap strategy that swaps if the count of frames in the wal exceed some threshold
4+
pub struct FrameCountSwapStrategy {
5+
max_frames_in_wal: usize,
6+
}
7+
8+
impl FrameCountSwapStrategy {
9+
pub fn new(max_frames_in_wal: usize) -> Self {
10+
Self { max_frames_in_wal }
11+
}
12+
}
13+
14+
impl SwapStrategy for FrameCountSwapStrategy {
15+
#[inline(always)]
16+
fn should_swap(&self, frames_in_wal: usize) -> bool {
17+
frames_in_wal >= self.max_frames_in_wal
18+
}
19+
20+
#[inline(always)]
21+
fn swapped(&self) { }
22+
}

0 commit comments

Comments
 (0)