Skip to content

Commit 3ee7ee2

Browse files
committed
rename swap_strategy to segment_swap_strategy
1 parent 276ef5b commit 3ee7ee2

6 files changed

Lines changed: 19 additions & 19 deletions

File tree

libsql-wal/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod shared_wal;
1010
pub mod storage;
1111
pub mod transaction;
1212
pub mod wal;
13-
mod swap_strategy;
13+
mod segment_swap_strategy;
1414

1515
const LIBSQL_MAGIC: u64 = u64::from_be_bytes(*b"LIBSQL\0\0");
1616
const LIBSQL_PAGE_SIZE: u16 = 4096;

libsql-wal/src/registry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ use crate::segment::Segment;
2727
use crate::segment::{current::CurrentSegment, sealed::SealedSegment};
2828
use crate::shared_wal::{SharedWal, SwapLog};
2929
use crate::storage::{OnStoreCallback, Storage};
30-
use crate::swap_strategy::duration::DurationSwapStrategy;
31-
use crate::swap_strategy::frame_count::FrameCountSwapStrategy;
32-
use crate::swap_strategy::SwapStrategy;
3330
use crate::transaction::TxGuard;
31+
use crate::segment_swap_strategy::duration::DurationSwapStrategy;
32+
use crate::segment_swap_strategy::frame_count::FrameCountSwapStrategy;
33+
use crate::segment_swap_strategy::SegmentSwapStrategy;
3434
use crate::{LibsqlFooter, LIBSQL_PAGE_SIZE};
3535
use libsql_sys::name::NamespaceName;
3636

libsql-wal/src/swap_strategy/duration.rs renamed to libsql-wal/src/segment_swap_strategy/duration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::time::{Duration, Instant};
22

33
use parking_lot::Mutex;
44

5-
use super::SwapStrategy;
5+
use super::SegmentSwapStrategy;
66

77
/// A wal swap strategy that swaps the current wal if it's older that some duration
88
pub struct DurationSwapStrategy {
@@ -16,7 +16,7 @@ impl DurationSwapStrategy {
1616
}
1717
}
1818

19-
impl SwapStrategy for DurationSwapStrategy {
19+
impl SegmentSwapStrategy for DurationSwapStrategy {
2020
#[inline(always)]
2121
fn should_swap(&self, _frames_in_wal: usize) -> bool {
2222
let last_swapped_at = self.last_swapped_at.lock();

libsql-wal/src/swap_strategy/frame_count.rs renamed to libsql-wal/src/segment_swap_strategy/frame_count.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::SwapStrategy;
1+
use super::SegmentSwapStrategy;
22

33
/// A swap strategy that swaps if the count of frames in the wal exceed some threshold
44
pub struct FrameCountSwapStrategy {
@@ -11,7 +11,7 @@ impl FrameCountSwapStrategy {
1111
}
1212
}
1313

14-
impl SwapStrategy for FrameCountSwapStrategy {
14+
impl SegmentSwapStrategy for FrameCountSwapStrategy {
1515
#[inline(always)]
1616
fn should_swap(&self, frames_in_wal: usize) -> bool {
1717
frames_in_wal >= self.max_frames_in_wal

libsql-wal/src/swap_strategy/mod.rs renamed to libsql-wal/src/segment_swap_strategy/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
pub(crate) mod duration;
22
pub(crate) mod frame_count;
33

4-
pub(crate) trait SwapStrategy: Sync + Send + 'static {
4+
pub(crate) trait SegmentSwapStrategy: Sync + Send + 'static {
55
fn should_swap(&self, frames_in_wal: usize) -> bool;
66
fn swapped(&self);
77

8-
fn and<O: SwapStrategy>(self, other: O) -> And<Self, O>
8+
fn and<O: SegmentSwapStrategy>(self, other: O) -> And<Self, O>
99
where
1010
Self: Sized,
1111
{
1212
And(self, other)
1313
}
1414

15-
fn or<O: SwapStrategy>(self, other: O) -> Or<Self, O>
15+
fn or<O: SegmentSwapStrategy>(self, other: O) -> Or<Self, O>
1616
where
1717
Self: Sized,
1818
{
@@ -22,10 +22,10 @@ pub(crate) trait SwapStrategy: Sync + Send + 'static {
2222

2323
pub struct And<A, B>(A, B);
2424

25-
impl<A, B> SwapStrategy for And<A, B>
25+
impl<A, B> SegmentSwapStrategy for And<A, B>
2626
where
27-
A: SwapStrategy,
28-
B: SwapStrategy,
27+
A: SegmentSwapStrategy,
28+
B: SegmentSwapStrategy,
2929
{
3030
#[inline(always)]
3131
fn should_swap(&self, frames_in_wal: usize) -> bool {
@@ -41,10 +41,10 @@ where
4141

4242
pub struct Or<A, B>(A, B);
4343

44-
impl<A, B> SwapStrategy for Or<A, B>
44+
impl<A, B> SegmentSwapStrategy for Or<A, B>
4545
where
46-
A: SwapStrategy,
47-
B: SwapStrategy,
46+
A: SegmentSwapStrategy,
47+
B: SegmentSwapStrategy,
4848
{
4949
#[inline(always)]
5050
fn should_swap(&self, frames_in_wal: usize) -> bool {

libsql-wal/src/shared_wal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::io::file::FileExt;
1616
use crate::io::Io;
1717
use crate::replication::storage::ReplicateFromStorage;
1818
use crate::segment::current::CurrentSegment;
19-
use crate::swap_strategy::SwapStrategy;
2019
use crate::transaction::{ReadTransaction, Savepoint, Transaction, TxGuard, WriteTransaction};
20+
use crate::segment_swap_strategy::SegmentSwapStrategy;
2121
use libsql_sys::name::NamespaceName;
2222

2323
#[derive(Default)]
@@ -54,7 +54,7 @@ pub struct SharedWal<IO: Io> {
5454
pub(crate) shutdown: AtomicBool,
5555
pub(crate) checkpoint_notifier: mpsc::Sender<CheckpointMessage>,
5656
pub(crate) io: Arc<IO>,
57-
pub(crate) swap_strategy: Box<dyn SwapStrategy>,
57+
pub(crate) swap_strategy: Box<dyn SegmentSwapStrategy>,
5858
}
5959

6060
impl<IO: Io> SharedWal<IO> {

0 commit comments

Comments
 (0)