Skip to main content

BlockPageStg

Struct BlockPageStg 

Source
pub struct BlockPageStg {
    pub ds: DividedStg,
    /* private fields */
}
Expand description

Implementation of PageStorage.

BlockPageStorage first divides the file into a small number of variable size files ( each built out of fixed size blocks ), and then allocates pages from these files, with each file being used to store pages of a particular size. So this is implemented as three structs: BlockStg which managed fixed size blocks, DividedStg which implements multiple files out of fixed size blocks and finally BlockPageStorage which uses the files to manage variable size pages. Since blocks are fixed size, when there is a free block, the last block in the file can be relocated to fill the gap. Similarly, when there is a free page, the last page in the subfile can be relocated to fill the gap. Thus the amount of unused file storage is minimal.

The choice of block size and page sizes is not fixed and can be configured. There is some advantage in choosing a block size which can be divided exactly by a range of integers – this means that when a page is read, the read does not cross a block boundary, so there is a single read to the underlying file system (disregarding “small” reads which are required to establish the page location, which can be buffered). For example, a block size of 27,720 ( = 5 x 7 x 8 x 9 x 11 ) can be divided evenly by integers in the range 6 to 12.

Fields§

§ds: DividedStg

Underlying Divided Storage.

Implementations§

Source§

impl BlockPageStg

Source

pub fn new(stg: Box<dyn Storage>, lim: &Limits) -> Box<Self>

Construct from specified Storage and limits.

Trait Implementations§

Source§

impl PageStorage for BlockPageStg

Source§

fn is_new(&self) -> bool

Is the underlying storage new?
Source§

fn new_page(&mut self) -> u64

Make a new page, result is page number.
Source§

fn drop_page(&mut self, pn: u64)

Drop page number.
Source§

fn info(&self) -> Box<dyn PageStorageInfo>

Information about page sizes.
Source§

fn set_page(&mut self, pn: u64, data: Data)

Set contents of page.
Source§

fn get_page(&self, pn: u64) -> Data

Get contents of page.
Source§

fn size(&self, pn: u64) -> usize

Get page size (for repacking).
Source§

fn save(&mut self)

Save pages to underlying storage.
Source§

fn rollback(&mut self)

Undo changes since last save ( but set_page/renumber cannot be undone, only new_page and drop_page can be undone ).
Source§

fn wait_complete(&self)

Wait until save is complete.
Source§

fn get_free(&mut self) -> (HashSet<u64>, u64)

Get set of free pages and number of pages ever allocated ( for VERIFY builtin function ).
Source§

fn load_free_pages(&mut self) -> Option<u64>

Load free pages in preparation for page renumbering. Returns number of used pages or None if there are no free pages.
Source§

fn renumber(&mut self, pn: u64) -> u64

Renumber page.
Source§

fn set_alloc_pn(&mut self, target: u64)

Final part of page renumber operation.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.