diff --git a/core/incremental/cursor.rs b/core/incremental/cursor.rs index fcbab1b9c..9bf39f53d 100644 --- a/core/incremental/cursor.rs +++ b/core/incremental/cursor.rs @@ -313,7 +313,6 @@ mod tests { OpenFlags::default(), crate::DatabaseOpts { enable_mvcc: false, - mvcc_mode: crate::MvccMode::Noop, enable_indexes: false, enable_views: true, enable_strict: false, diff --git a/core/lib.rs b/core/lib.rs index 180068284..ae8fb31ab 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -103,7 +103,6 @@ pub use vdbe::{builder::QueryMode, explain::EXPLAIN_COLUMNS, explain::EXPLAIN_QU #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct DatabaseOpts { pub enable_mvcc: bool, - pub mvcc_mode: MvccMode, pub enable_indexes: bool, pub enable_views: bool, pub enable_strict: bool, @@ -113,7 +112,6 @@ impl Default for DatabaseOpts { fn default() -> Self { Self { enable_mvcc: false, - mvcc_mode: MvccMode::LogicalLog, enable_indexes: true, enable_views: false, enable_strict: false, @@ -175,12 +173,6 @@ pub enum SyncMode { Full = 2, } -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum MvccMode { - Noop, - LogicalLog, -} - pub(crate) type MvStore = mvcc::MvStore; pub(crate) type MvCursor = mvcc::cursor::MvccLazyCursor; @@ -401,12 +393,8 @@ impl Database { let shared_wal = WalFileShared::open_shared_if_exists(&io, wal_path)?; let mv_store = if opts.enable_mvcc { - let storage = match opts.mvcc_mode { - MvccMode::Noop => mvcc::persistent_storage::Storage::new_noop(), - MvccMode::LogicalLog => mvcc::persistent_storage::Storage::new_logical_log( - io.open_file(&format!("{path}-lg"), OpenFlags::default(), false)?, - ), - }; + let file = io.open_file(&format!("{path}-lg"), OpenFlags::default(), false)?; + let storage = mvcc::persistent_storage::Storage::new(file); Some(Arc::new(MvStore::new(mvcc::LocalClock::new(), storage))) } else { None diff --git a/core/mvcc/persistent_storage/logical_log.rs b/core/mvcc/persistent_storage/logical_log.rs index 0f2cf3fc2..0e8ad4918 100644 --- a/core/mvcc/persistent_storage/logical_log.rs +++ b/core/mvcc/persistent_storage/logical_log.rs @@ -54,10 +54,6 @@ impl LogicalLog { Ok(IOResult::IO(IOCompletions::Single(c))) } - pub fn read_tx_log(&self) -> Result> { - todo!() - } - pub fn sync(&mut self) -> Result> { let completion = Completion::new_sync(move |_| { tracing::debug!("logical_log_sync finish"); diff --git a/core/mvcc/persistent_storage/mod.rs b/core/mvcc/persistent_storage/mod.rs index 7008e5ae0..b92bf081e 100644 --- a/core/mvcc/persistent_storage/mod.rs +++ b/core/mvcc/persistent_storage/mod.rs @@ -6,20 +6,15 @@ mod logical_log; use crate::mvcc::database::LogRecord; use crate::mvcc::persistent_storage::logical_log::LogicalLog; use crate::types::IOResult; -use crate::{File, LimboError, Result}; +use crate::{File, Result}; -pub enum Storage { - Noop, - LogicalLog { logical_log: RefCell }, +pub struct Storage { + logical_log: RefCell, } impl Storage { - pub fn new_noop() -> Self { - Self::Noop - } - - pub fn new_logical_log(file: Arc) -> Self { - Self::LogicalLog { + pub fn new(file: Arc) -> Self { + Self { logical_log: RefCell::new(LogicalLog::new(file)), } } @@ -27,38 +22,24 @@ impl Storage { impl Storage { pub fn log_tx(&self, m: &LogRecord) -> Result> { - match self { - Self::Noop => Ok(IOResult::Done(())), - Self::LogicalLog { logical_log } => logical_log.borrow_mut().log_tx(m), - } + self.logical_log.borrow_mut().log_tx(m) } pub fn read_tx_log(&self) -> Result> { - match self { - Self::Noop => Err(LimboError::InternalError( - "cannot read from Noop storage".to_string(), - )), - Self::LogicalLog { logical_log: _ } => todo!(), - } + todo!() } pub fn is_logical_log(&self) -> bool { - matches!(self, Self::LogicalLog { .. }) + true } pub fn sync(&self) -> Result> { - match self { - Self::Noop => Ok(IOResult::Done(())), - Self::LogicalLog { logical_log } => logical_log.borrow_mut().sync(), - } + self.logical_log.borrow_mut().sync() } } impl Debug for Storage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Noop => write!(f, "Noop"), - Self::LogicalLog { logical_log: _ } => write!(f, "LogicalLog {{ logical_log }}"), - } + write!(f, "LogicalLog {{ logical_log }}") } }