Page
source: bluebase/pf/page.py
- class PfPageView(page: PfPage, *, offset: int, limit: int)[source]
Bases:
ABCAn abstract base class that provides a memory view of page data.
- Variables:
- commit() None[source]
Commit the buffer to the view.
- Raises:
PfUnpinnedPageAccessError – if the page is not pinned
- class PfPageHeader(page: PfPage, *, offset: int, limit: int)[source]
Bases:
PfPageView,LayoutMixinA layout view for managing a page header.
Layout
Offset
Size
Name
Format
0
1
free'<B'1
4
next_free_pid'<i'- size: ClassVar[int] = 5
The total size of the layout, automatically calculated from
fields.
- class PfPage(pid: PfPageId, file: PfFile, data: PfPageData)[source]
Bases:
object- Variables:
pid (PfPageId) – the ID of the page
file (PfFile) – the file that contains the page
data (PfPageData) – the page data
dirty (bool) – whether the page is dirty
pin_count (int) – the pin count of the page
- property size: intread-only
The size of the page.
- property header_offset: intread-only
The offset of the page header.
- property header_size: intread-only
The size of the page header.
- property payload_offset: intread-only
The offset of the page payload.
- property payload_size: intread-only
The size of the page payload.
- property free: boolread-write
Whether the page is free.
- validate_pinned() None[source]
Validate whether the page is pinned.
- Raises:
PfUnpinnedPageAccessError – if the page is not pinned
- get_header() PfPageHeader[source]
Return the page header.
- assignmentunpin() None[source]
Unpin the page.
- Raises:
PfUnpinnedPageAccessError – if the page is not pinned
Hint
Always validate the page is pinned before unpinning. Then, decrease the pin count.
- assignmentget_data(offset: int, limit: int) PfPageData[source]
Return page data.
- Raises:
PfUnpinnedPageAccessError – if the page is not pinned
PfPageDataOutOfRangeError – if the data range is invalid
Hint
Always validate the page is pinned before getting data. Also, validate the data range. Then, touch the page to notify the page cache. Finally, return the sliced data.
- assignmentset_data(offset: int, data: PfPageData) None[source]
Set page data.
- Raises:
PfUnpinnedPageAccessError – if the page is not pinned
PfPageDataOutOfRangeError – if the data range is invalid
Hint
Always validate the page is pinned before setting data. Also, validate the data range. Then, set the sliced data and mark the page as dirty. Finally, touch the page to notify the page cache.