-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiangzhe
committed
Dec 14, 2024
1 parent
3d02dc4
commit 0c77a0a
Showing
17 changed files
with
2,919 additions
and
771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
use std::cell::{Cell, UnsafeCell}; | ||
use crate::buffer::page::{Page, PageID}; | ||
use crate::buffer::FixedBufferPool; | ||
use crate::latch::HybridLatch; | ||
use crate::trx::undo::UndoMap; | ||
|
||
const _: () = assert!( | ||
{ std::mem::size_of::<BufferFrame>() % 64 == 0 }, | ||
"Size of BufferFrame must be multiply of 64" | ||
); | ||
|
||
const _: () = assert!( | ||
{ std::mem::align_of::<BufferFrame>() % 64 == 0 }, | ||
"Align of BufferFrame must be multiply of 64" | ||
); | ||
|
||
#[repr(C)] | ||
pub struct BufferFrame { | ||
pub page_id: Cell<PageID>, | ||
pub page_id: PageID, | ||
pub next_free: PageID, | ||
/// Undo Map is only maintained by RowPage. | ||
/// Once a RowPage is eliminated, the UndoMap is retained by BufferPool | ||
/// and when the page is reloaded, UndoMap is reattached to page. | ||
pub undo_map: Option<Box<UndoMap>>, | ||
pub latch: HybridLatch, // lock proctects free list and page. | ||
pub next_free: UnsafeCell<PageID>, | ||
pub page: UnsafeCell<Page>, | ||
} | ||
pub page: Page, | ||
} | ||
|
||
/// BufferFrameAware defines callbacks on lifecycle of buffer frame | ||
/// for initialization and de-initialization. | ||
pub trait BufferFrameAware { | ||
/// This callback is called when a page is just loaded into BufferFrame. | ||
fn init_bf(_pool: &FixedBufferPool, _bf: &mut BufferFrame) {} | ||
|
||
/// This callback is called when a page is cleaned and return to BufferPool. | ||
fn deinit_bf(_pool: &FixedBufferPool, _bf: &mut BufferFrame) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.