mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 12:04:21 +01:00
Merge 'core/mvcc: Kill noop storage' from Pekka Enberg
We don't need it for anything. Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #3213
This commit is contained in:
@@ -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,
|
||||
|
||||
16
core/lib.rs
16
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<mvcc::LocalClock>;
|
||||
|
||||
pub(crate) type MvCursor = mvcc::cursor::MvccLazyCursor<mvcc::LocalClock>;
|
||||
@@ -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
|
||||
|
||||
@@ -54,10 +54,6 @@ impl LogicalLog {
|
||||
Ok(IOResult::IO(IOCompletions::Single(c)))
|
||||
}
|
||||
|
||||
pub fn read_tx_log(&self) -> Result<Vec<LogRecord>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn sync(&mut self) -> Result<IOResult<()>> {
|
||||
let completion = Completion::new_sync(move |_| {
|
||||
tracing::debug!("logical_log_sync finish");
|
||||
|
||||
@@ -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<LogicalLog> },
|
||||
pub struct Storage {
|
||||
logical_log: RefCell<LogicalLog>,
|
||||
}
|
||||
|
||||
impl Storage {
|
||||
pub fn new_noop() -> Self {
|
||||
Self::Noop
|
||||
}
|
||||
|
||||
pub fn new_logical_log(file: Arc<dyn File>) -> Self {
|
||||
Self::LogicalLog {
|
||||
pub fn new(file: Arc<dyn File>) -> 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<IOResult<()>> {
|
||||
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<Vec<LogRecord>> {
|
||||
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<IOResult<()>> {
|
||||
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 }}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user