Skip to content

Commit

Permalink
Buffer manager trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Codetector1374 committed Aug 1, 2024
1 parent d1d3a47 commit 5a17198
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/innodb/buffer_manager/heap_buffer_manager.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use super::BufferManager;

pub struct HeapBufferManager {}

impl BufferManager for HeapBufferManager {
fn open_page<'a>(&'a mut self, space_id: u64, offset: u64) -> crate::innodb::page::Page<'a> {
todo!()
}

fn close_page(&mut self, page: &crate::innodb::page::Page) {
todo!()
}
}
8 changes: 8 additions & 0 deletions src/innodb/buffer_manager/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use super::page::Page;

pub mod heap_buffer_manager;

pub trait BufferManager {
fn open_page<'a>(&'a mut self, space_id: u64, offset: u64) -> Page<'a>;
fn close_page(&mut self, page: &Page);
}
1 change: 1 addition & 0 deletions src/innodb/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod charset;
pub mod buffer_manager;
pub mod page;
pub mod table;

Expand Down
2 changes: 2 additions & 0 deletions src/innodb/page/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn fold_bytes(buf: &[u8]) -> u32 {

#[derive(Default, Clone, PartialEq)]
pub struct Page<'a> {
pub space_id: Option<u64>,
pub header: FILHeader,
pub trailer: FILTrailer,
pub raw_data: &'a [u8],
Expand All @@ -64,6 +65,7 @@ impl<'a> Page<'a> {
}

Ok(Page {
space_id: None,
header: FILHeader::from_bytes(&buf[0..38])?,
trailer: FILTrailer::from_bytes(&buf[(FIL_PAGE_SIZE - FIL_TRAILER_SIZE)..])?,
raw_data: buf,
Expand Down

0 comments on commit 5a17198

Please sign in to comment.