mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 10:08:20 +00:00
core: Rename PageIO to DatabaseStorage
This commit is contained in:
parent
4349b946e5
commit
8a54e31803
5 changed files with 16 additions and 14 deletions
|
@ -7,7 +7,7 @@ pub(crate) mod wal;
|
|||
use crate::{error::LimboError, io::Completion, Buffer, Result};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub trait PageIO {
|
||||
pub trait DatabaseStorage {
|
||||
fn get(&self, page_idx: usize, c: Rc<Completion>) -> Result<()>;
|
||||
fn write(&self, page_idx: usize, buffer: Rc<RefCell<Buffer>>, c: Rc<Completion>) -> Result<()>;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ pub struct FileStorage {
|
|||
}
|
||||
|
||||
#[cfg(feature = "fs")]
|
||||
impl PageIO for FileStorage {
|
||||
impl DatabaseStorage for FileStorage {
|
||||
fn get(&self, page_idx: usize, c: Rc<Completion>) -> Result<()> {
|
||||
let r = match &(*c) {
|
||||
Completion::Read(r) => r,
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::rc::Rc;
|
|||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use super::PageIO;
|
||||
use super::DatabaseStorage;
|
||||
|
||||
pub struct Page {
|
||||
pub flags: AtomicUsize,
|
||||
|
@ -264,7 +264,7 @@ impl<K: Eq + Hash + Clone, V> PageCache<K, V> {
|
|||
/// transaction management.
|
||||
pub struct Pager {
|
||||
/// Source of the database pages.
|
||||
pub page_io: Rc<dyn PageIO>,
|
||||
pub page_io: Rc<dyn DatabaseStorage>,
|
||||
/// The write-ahead log (WAL) for the database.
|
||||
wal: Option<Wal>,
|
||||
/// A page cache for the database.
|
||||
|
@ -279,14 +279,14 @@ pub struct Pager {
|
|||
|
||||
impl Pager {
|
||||
/// Begins opening a database by reading the database header.
|
||||
pub fn begin_open(page_io: Rc<dyn PageIO>) -> Result<Rc<RefCell<DatabaseHeader>>> {
|
||||
pub fn begin_open(page_io: Rc<dyn DatabaseStorage>) -> Result<Rc<RefCell<DatabaseHeader>>> {
|
||||
sqlite3_ondisk::begin_read_database_header(page_io)
|
||||
}
|
||||
|
||||
/// Completes opening a database by initializing the Pager with the database header.
|
||||
pub fn finish_open(
|
||||
db_header_ref: Rc<RefCell<DatabaseHeader>>,
|
||||
page_io: Rc<dyn PageIO>,
|
||||
page_io: Rc<dyn DatabaseStorage>,
|
||||
io: Arc<dyn crate::io::IO>,
|
||||
) -> Result<Self> {
|
||||
let db_header = RefCell::borrow(&db_header_ref);
|
||||
|
|
|
@ -51,7 +51,7 @@ use log::trace;
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use super::PageIO;
|
||||
use super::DatabaseStorage;
|
||||
|
||||
/// The size of the database header in bytes.
|
||||
pub const DATABASE_HEADER_SIZE: usize = 100;
|
||||
|
@ -110,7 +110,9 @@ pub struct WalFrameHeader {
|
|||
checksum_2: u32,
|
||||
}
|
||||
|
||||
pub fn begin_read_database_header(page_io: Rc<dyn PageIO>) -> Result<Rc<RefCell<DatabaseHeader>>> {
|
||||
pub fn begin_read_database_header(
|
||||
page_io: Rc<dyn DatabaseStorage>,
|
||||
) -> Result<Rc<RefCell<DatabaseHeader>>> {
|
||||
let drop_fn = Rc::new(|_buf| {});
|
||||
let buf = Rc::new(RefCell::new(Buffer::allocate(512, drop_fn)));
|
||||
let result = Rc::new(RefCell::new(DatabaseHeader::default()));
|
||||
|
@ -442,7 +444,7 @@ impl PageContent {
|
|||
}
|
||||
|
||||
pub fn begin_read_page(
|
||||
page_io: Rc<dyn PageIO>,
|
||||
page_io: Rc<dyn DatabaseStorage>,
|
||||
buffer_pool: Rc<BufferPool>,
|
||||
page: Rc<RefCell<Page>>,
|
||||
page_idx: usize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue