Skip to main content

PageInner

Struct PageInner 

Source
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: AtomicUsize

If >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: AtomicU64

The 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

Source

pub fn new(buffer: Arc<Buffer>) -> Self

Creates a new PageInner from an Arc.

Source

pub fn from_buffer(buffer: Buffer) -> Self

Creates a new PageInner with an owned buffer.

Source

pub fn as_ptr(&self) -> &mut [u8]

Get the page buffer as a mutable slice. Panics if buffer not loaded.

Source

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.

Source

pub fn page_type(&self) -> Result<PageType>

Source

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).

Source

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).

Source

pub fn write_u16_no_offset(&self, pos: usize, value: u16)

Write a u16 at the given absolute offset (no db header offset).

Source

pub fn write_u32_no_offset(&self, pos: usize, value: u32)

Write a u32 at the given absolute offset (no db header offset).

Source

pub fn write_page_type(&self, value: u8)

Source

pub fn write_rightmost_ptr(&self, value: u32)

Source

pub fn write_first_freeblock(&self, value: u16)

Source

pub fn write_freeblock(&self, offset: u16, size: u16, next_block: Option<u16>)

Source

pub fn write_freeblock_size(&self, offset: u16, size: u16)

Source

pub fn write_freeblock_next_ptr(&self, offset: u16, next_block: u16)

Source

pub fn read_freeblock(&self, offset: u16) -> (u16, u16)

Source

pub fn write_cell_count(&self, value: u16)

Source

pub fn write_cell_content_area(&self, value: usize)

Source

pub fn write_fragmented_bytes_count(&self, value: u8)

Source

pub fn first_freeblock(&self) -> u16

Source

pub fn cell_count(&self) -> usize

Source

pub fn cell_pointer_array_size(&self) -> usize

Source

pub fn unallocated_region_start(&self) -> usize

Source

pub fn unallocated_region_size(&self) -> usize

Source

pub fn cell_content_area(&self) -> u32

Source

pub fn header_size(&self) -> usize

Source

pub fn num_frag_free_bytes(&self) -> u8

Source

pub fn rightmost_pointer(&self) -> Result<Option<u32>>

Source

pub fn rightmost_pointer_raw(&self) -> Result<Option<*mut u8>>

Source

pub fn cell_get(&self, idx: usize, usable_size: usize) -> Result<BTreeCell>

Source

pub fn cell_table_interior_read_rowid(&self, idx: usize) -> Result<i64>

Source

pub fn cell_interior_read_left_child_page(&self, idx: usize) -> Result<u32>

Source

pub fn cell_table_leaf_read_rowid(&self, idx: usize) -> Result<i64>

Source

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)

Source

pub fn cell_pointer_array_offset_and_size(&self) -> (usize, usize)

Source

pub fn cell_pointer_array_offset(&self) -> usize

Source

pub fn cell_get_raw_start_offset(&self, idx: usize) -> usize

Source

pub fn cell_get_raw_region( &self, idx: usize, usable_size: usize, ) -> Result<(usize, usize)>

Source

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)>

Source

pub fn is_leaf(&self) -> bool

Source

pub fn write_database_header(&self, header: &DatabaseHeader)

Source

pub fn debug_print_freelist(&self, usable_space: usize)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more