Skip to content

Commit 5628cc2

Browse files
committed
btree: move allocate_overflow_page to Pager impl
1 parent bf26e62 commit 5628cc2

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

core/storage/btree.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -4567,7 +4567,7 @@ fn fill_cell_payload(
45674567
}
45684568

45694569
// we still have bytes to add, we will need to allocate new overflow page
4570-
let overflow_page = allocate_overflow_page(pager.clone());
4570+
let overflow_page = pager.allocate_overflow_page();
45714571
overflow_pages.push(overflow_page.clone());
45724572
{
45734573
let id = overflow_page.get().id as u32;
@@ -4590,20 +4590,6 @@ fn fill_cell_payload(
45904590
assert_eq!(cell_size, cell_payload.len());
45914591
}
45924592

4593-
/// Allocate a new overflow page.
4594-
/// This is done when a cell overflows and new space is needed.
4595-
fn allocate_overflow_page(pager: Rc<Pager>) -> PageRef {
4596-
let page = pager.allocate_page().unwrap();
4597-
tracing::debug!("allocate_overflow_page(id={})", page.get().id);
4598-
4599-
// setup overflow page
4600-
let contents = page.get().contents.as_mut().unwrap();
4601-
let buf = contents.as_ptr();
4602-
buf.fill(0);
4603-
4604-
page
4605-
}
4606-
46074593
/// Returns the maximum payload size (X) that can be stored directly on a b-tree page without spilling to overflow pages.
46084594
///
46094595
/// For table leaf pages: X = usable_size - 35

core/storage/pager.rs

+14
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@ impl Pager {
217217
id as u32
218218
}
219219

220+
/// Allocate a new overflow page.
221+
/// This is done when a cell overflows and new space is needed.
222+
pub fn allocate_overflow_page(&self) -> PageRef {
223+
let page = self.allocate_page().unwrap();
224+
tracing::debug!("Pager::allocate_overflow_page(id={})", page.get().id);
225+
226+
// setup overflow page
227+
let contents = page.get().contents.as_mut().unwrap();
228+
let buf = contents.as_ptr();
229+
buf.fill(0);
230+
231+
page
232+
}
233+
220234
/// Allocate a new page to the btree via the pager.
221235
/// This marks the page as dirty and writes the page header.
222236
pub fn do_allocate_page(&self, page_type: PageType, offset: usize) -> PageRef {

0 commit comments

Comments
 (0)