diff --git a/bindings/javascript/src/lib.rs b/bindings/javascript/src/lib.rs index eaa2fc3a6..2e0054358 100644 --- a/bindings/javascript/src/lib.rs +++ b/bindings/javascript/src/lib.rs @@ -177,7 +177,7 @@ impl limbo_core::IO for IO { todo!(); } - fn get_memory_io(&self) -> Option> { - todo!() + fn get_memory_io(&self) -> Arc { + Arc::new(limbo_core::MemoryIO::new()) } } diff --git a/bindings/wasm/lib.rs b/bindings/wasm/lib.rs index 6b4173c90..a704706be 100644 --- a/bindings/wasm/lib.rs +++ b/bindings/wasm/lib.rs @@ -306,8 +306,8 @@ impl limbo_core::IO for PlatformIO { (random_f64 * i64::MAX as f64) as i64 } - fn get_memory_io(&self) -> Option> { - None // TODO: Make sure if memory isn't needed here + fn get_memory_io(&self) -> Arc { + Arc::new(limbo_core::MemoryIO::new()) } } diff --git a/core/io/generic.rs b/core/io/generic.rs index 03d5fdd3d..d67a93dd7 100644 --- a/core/io/generic.rs +++ b/core/io/generic.rs @@ -6,14 +6,12 @@ use tracing::{debug, trace}; use super::MemoryIO; pub struct GenericIO { - memory_io: Arc, } impl GenericIO { pub fn new() -> Result { debug!("Using IO backend 'generic'"); Ok(Self { - memory_io: Arc::new(MemoryIO::new()), }) } } @@ -55,9 +53,9 @@ impl Clock for GenericIO { } } - fn get_memory_io(&self) -> Option> { - Some(self.memory_io.clone()) - } + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) + } } pub struct GenericFile { diff --git a/core/io/io_uring.rs b/core/io/io_uring.rs index 7d73461a0..6e2fc1e7e 100644 --- a/core/io/io_uring.rs +++ b/core/io/io_uring.rs @@ -35,7 +35,6 @@ impl fmt::Display for UringIOError { pub struct UringIO { inner: Rc>, - memory_io: Arc, } unsafe impl Send for UringIO {} @@ -79,7 +78,6 @@ impl UringIO { debug!("Using IO backend 'io-uring'"); Ok(Self { inner: Rc::new(RefCell::new(inner)), - memory_io: Arc::new(MemoryIO::new()), }) } } @@ -210,8 +208,8 @@ impl Clock for UringIO { } } - fn get_memory_io(&self) -> Option> { - Some(self.memory_io.clone()) + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) } } diff --git a/core/io/memory.rs b/core/io/memory.rs index d573c443a..9cc56a5e3 100644 --- a/core/io/memory.rs +++ b/core/io/memory.rs @@ -59,8 +59,8 @@ impl IO for MemoryIO { i64::from_ne_bytes(buf) } - fn get_memory_io(&self) -> Option> { - None + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) } } diff --git a/core/io/mod.rs b/core/io/mod.rs index 36c39e013..6f161d114 100644 --- a/core/io/mod.rs +++ b/core/io/mod.rs @@ -41,7 +41,7 @@ pub trait IO: Clock + Send + Sync { fn generate_random_number(&self) -> i64; - fn get_memory_io(&self) -> Option>; + fn get_memory_io(&self) -> Arc; } pub type Complete = dyn Fn(Arc>); diff --git a/core/io/unix.rs b/core/io/unix.rs index 9c8ac6fed..c232ed3ad 100644 --- a/core/io/unix.rs +++ b/core/io/unix.rs @@ -167,7 +167,6 @@ pub struct UnixIO { poller: PollHandler, events: EventsHandler, callbacks: OwnedCallbacks, - memory_io: Arc, } unsafe impl Send for UnixIO {} @@ -181,7 +180,6 @@ impl UnixIO { poller: PollHandler::new(), events: EventsHandler::new(), callbacks: OwnedCallbacks::new(), - memory_io: Arc::new(MemoryIO::new()), }) } } @@ -261,8 +259,8 @@ impl IO for UnixIO { i64::from_ne_bytes(buf) } - fn get_memory_io(&self) -> Option> { - Some(self.memory_io.clone()) + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) } } diff --git a/core/io/vfs.rs b/core/io/vfs.rs index ede08c7cf..6af47b176 100644 --- a/core/io/vfs.rs +++ b/core/io/vfs.rs @@ -70,8 +70,8 @@ impl VfsMod { } } - fn get_memory_io(&self) -> Option> { - None + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) } } diff --git a/core/io/windows.rs b/core/io/windows.rs index af36119d0..f970ef02d 100644 --- a/core/io/windows.rs +++ b/core/io/windows.rs @@ -5,14 +5,12 @@ use std::sync::Arc; use tracing::{debug, trace}; use super::MemoryIO; pub struct WindowsIO { - memory_io: Arc, } impl WindowsIO { pub fn new() -> Result { debug!("Using IO backend 'syscall'"); Ok(Self { - memory_io: Arc::new(MemoryIO::new()), }) } } @@ -53,8 +51,8 @@ impl Clock for WindowsIO { } } - fn get_memory_io(&self) -> Option> { - Some(self.memory_io.clone()) + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) } } diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index 3ad0a91f8..4f40f0d21 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -38,7 +38,9 @@ use crate::{ vector::{vector32, vector64, vector_distance_cos, vector_extract}, }; -use crate::{info, BufferPool, MvCursor, OpenFlags, RefValue, Row, StepResult, TransactionState}; +use crate::{ + info, BufferPool, MvCursor, OpenFlags, RefValue, Row, StepResult, TransactionState, IO, +}; use super::{ insn::{Cookie, RegisterOrLiteral}, @@ -4523,11 +4525,7 @@ pub fn op_open_ephemeral( }; let conn = program.connection.upgrade().unwrap(); - // Only memory and vfs IOs returns None, so cloning is safe - let io = match conn.pager.io.get_memory_io() { - Some(io) => io, - None => conn.pager.io.clone(), - }; + let io = conn.pager.io.get_memory_io(); let file = io.open_file("", OpenFlags::Create, true)?; let page_io = Arc::new(FileMemoryStorage::new(file)); diff --git a/simulator/runner/io.rs b/simulator/runner/io.rs index 0a7ff3b3a..c775b3f9e 100644 --- a/simulator/runner/io.rs +++ b/simulator/runner/io.rs @@ -98,7 +98,7 @@ impl IO for SimulatorIO { self.rng.borrow_mut().next_u64() as i64 } - fn get_memory_io(&self) -> Option> { + fn get_memory_io(&self) -> Arc { todo!() } }