pub struct PageInner {
pub flags: AtomicUsize,
pub id: usize,
pub pin_count: AtomicUsize,
pub wal_tag: AtomicU64,
pub buffer: Option<Arc<Buffer>>,
pub overflow_cells: Vec<OverflowCell>,
}Fields§
§flags: AtomicUsize§id: usize§pin_count: AtomicUsizeIf >0, the page is pinned and not eligible for eviction from the page cache. The reason this is a counter is that multiple nested code paths may signal that a page must not be evicted from the page cache, so even if an inner code path requests unpinning via Page::unpin, the pin count will still be >0 if the outer code path has not yet requested to unpin the page as well.
Note that [PageCache::clear] evicts the pages even if pinned, so as long as we clear the page cache on errors, pins will not ‘leak’.
wal_tag: AtomicU64The WAL frame number this page was loaded from (0 if loaded from main DB file) This tracks which version of the page we have in memory
buffer: Option<Arc<Buffer>>The actual page data buffer. None if not loaded.
overflow_cells: Vec<OverflowCell>Overflow cells during btree operations
Implementations§
Source§impl PageInner
impl PageInner
Sourcepub fn from_buffer(buffer: Buffer) -> Self
pub fn from_buffer(buffer: Buffer) -> Self
Creates a new PageInner with an owned buffer.
Sourcepub fn as_ptr(&self) -> &mut [u8] ⓘ
pub fn as_ptr(&self) -> &mut [u8] ⓘ
Get the page buffer as a mutable slice. Panics if buffer not loaded.
Sourcepub fn offset(&self) -> usize
pub fn offset(&self) -> usize
The position where page content starts. It’s 100 for page 1 (database file header is 100 bytes), 0 for all other pages.
pub fn page_type(&self) -> Result<PageType>
Sourcepub fn read_u16_no_offset(&self, pos: usize) -> u16
pub fn read_u16_no_offset(&self, pos: usize) -> u16
Read a u16 from the page content at the given absolute offset (no db header offset).
Sourcepub fn read_u32_no_offset(&self, pos: usize) -> u32
pub fn read_u32_no_offset(&self, pos: usize) -> u32
Read a u32 from the page content at the given absolute offset (no db header offset).
Sourcepub fn write_u16_no_offset(&self, pos: usize, value: u16)
pub fn write_u16_no_offset(&self, pos: usize, value: u16)
Write a u16 at the given absolute offset (no db header offset).
Sourcepub fn write_u32_no_offset(&self, pos: usize, value: u32)
pub fn write_u32_no_offset(&self, pos: usize, value: u32)
Write a u32 at the given absolute offset (no db header offset).
pub fn write_page_type(&self, value: u8)
pub fn write_rightmost_ptr(&self, value: u32)
pub fn write_first_freeblock(&self, value: u16)
pub fn write_freeblock(&self, offset: u16, size: u16, next_block: Option<u16>)
pub fn write_freeblock_size(&self, offset: u16, size: u16)
pub fn write_freeblock_next_ptr(&self, offset: u16, next_block: u16)
pub fn read_freeblock(&self, offset: u16) -> (u16, u16)
pub fn write_cell_count(&self, value: u16)
pub fn write_cell_content_area(&self, value: usize)
pub fn write_fragmented_bytes_count(&self, value: u8)
pub fn first_freeblock(&self) -> u16
pub fn cell_count(&self) -> usize
pub fn cell_pointer_array_size(&self) -> usize
pub fn unallocated_region_start(&self) -> usize
pub fn unallocated_region_size(&self) -> usize
pub fn cell_content_area(&self) -> u32
pub fn header_size(&self) -> usize
pub fn num_frag_free_bytes(&self) -> u8
pub fn rightmost_pointer(&self) -> Result<Option<u32>>
pub fn rightmost_pointer_raw(&self) -> Result<Option<*mut u8>>
pub fn cell_get(&self, idx: usize, usable_size: usize) -> Result<BTreeCell>
pub fn cell_table_interior_read_rowid(&self, idx: usize) -> Result<i64>
pub fn cell_interior_read_left_child_page(&self, idx: usize) -> Result<u32>
pub fn cell_table_leaf_read_rowid(&self, idx: usize) -> Result<i64>
Sourcepub fn cell_index_read_payload_ptr(
&self,
idx: usize,
usable_size: usize,
) -> Result<(&'static [u8], u64, Option<u32>)>
pub fn cell_index_read_payload_ptr( &self, idx: usize, usable_size: usize, ) -> Result<(&'static [u8], u64, Option<u32>)>
Fast path for index cells: returns payload slice and overflow info without constructing BTreeCell.
This bypasses the full cell_get() to read_btree_cell() path for binary search hot loops.
The returned slice is valid as long as the page is alive.
Returns: (payload_slice, payload_size, first_overflow_page)
pub fn cell_pointer_array_offset_and_size(&self) -> (usize, usize)
pub fn cell_pointer_array_offset(&self) -> usize
pub fn cell_get_raw_start_offset(&self, idx: usize) -> usize
pub fn cell_get_raw_region( &self, idx: usize, usable_size: usize, ) -> Result<(usize, usize)>
pub fn _cell_get_raw_region_faster( &self, idx: usize, usable_size: usize, cell_count: usize, max_local: usize, min_local: usize, page_type: PageType, ) -> Result<(usize, usize)>
pub fn is_leaf(&self) -> bool
pub fn write_database_header(&self, header: &DatabaseHeader)
pub fn debug_print_freelist(&self, usable_space: usize)
Auto Trait Implementations§
impl !Freeze for PageInner
impl RefUnwindSafe for PageInner
impl Send for PageInner
impl Sync for PageInner
impl Unpin for PageInner
impl UnsafeUnpin for PageInner
impl UnwindSafe for PageInner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more