pub struct Pager { /* private fields */ }Expand description
Native host adapter for the shared pager.
Implementations§
Source§impl Pager
impl Pager
Sourcepub fn open<P: AsRef<Path>>(
path: P,
config: PagerConfig,
) -> Result<Self, PagerError>
pub fn open<P: AsRef<Path>>( path: P, config: PagerConfig, ) -> Result<Self, PagerError>
Open or create a database file
Sourcepub fn open_default<P: AsRef<Path>>(path: P) -> Result<Self, PagerError>
pub fn open_default<P: AsRef<Path>>(path: P) -> Result<Self, PagerError>
Open with default configuration
Sourcepub fn read_page_decrypted(&self, page_id: u32) -> Result<Page, PagerError>
pub fn read_page_decrypted(&self, page_id: u32) -> Result<Page, PagerError>
Read a page through the configured encryptor if any. Page 0 is always returned plaintext (it carries the encryption marker
- header). Callers that want raw cipher bytes can use
read_page_no_checksumdirectly.
Sourcepub fn write_page_encrypted(
&self,
page_id: u32,
page: Page,
) -> Result<(), PagerError>
pub fn write_page_encrypted( &self, page_id: u32, page: Page, ) -> Result<(), PagerError>
Write a page through the configured encryptor if any. Page 0 bypasses encryption and goes through the normal checksummed path. Encrypted pages skip the checksum update because AES-GCM’s authentication tag is the integrity guarantee.
Sourcepub fn set_wal_writer(&self, wal: Arc<Mutex<WalWriter>>)
pub fn set_wal_writer(&self, wal: Arc<Mutex<WalWriter>>)
Attach a WAL writer to enforce WAL-first flush ordering.
After this call, [Pager::flush] computes the maximum
header.lsn over all dirty pages and calls
WalWriter::flush_until(max_lsn) before any page is written
to the data file. This is the postgres rule: a page on disk
implies its WAL record is already durable on disk.
Cold checksummed reads with a nonzero page LSN beyond the completed checkpoint also require this durable WAL authority. LSN-zero pages remain protected by DWB and do not need an attached writer.
Sourcepub fn clear_wal_writer(&self)
pub fn clear_wal_writer(&self)
Detach the WAL writer (test / shutdown path).
Sourcepub fn has_wal_writer(&self) -> bool
pub fn has_wal_writer(&self) -> bool
Has a WAL writer been attached?
Sourcepub fn prefetch_hint(&self, page_id: u32)
pub fn prefetch_hint(&self, page_id: u32)
Issue a best-effort OS read-ahead hint under the page-I/O lock.
Methods from Deref<Target = SharedPager<NativePagerFile, NativeWalBarrier>>§
Trait Implementations§
Source§impl PageStore for Pager
impl PageStore for Pager
fn read_page(&self, id: u32) -> Result<Page, PagerError>
fn write_page(&self, id: u32, page: Page) -> Result<(), PagerError>
Source§fn try_read_page(&self, id: u32) -> Result<Option<Page>, PagerError>
fn try_read_page(&self, id: u32) -> Result<Option<Page>, PagerError>
Self::read_page that never waits: None only while a dirty image
another thread’s ownership epoch evicted is on its way to the file.
A store without such an epoch always answers.Source§fn wait_to_retry_read(&self)
fn wait_to_retry_read(&self)
Self::try_read_page calls that declined. The caller
holds nothing the store’s writers need.Source§fn ownership_guard(&self) -> Option<ReentrantMutexGuard<'_, ()>>
fn ownership_guard(&self) -> Option<ReentrantMutexGuard<'_, ()>>
fn allocate_page(&self, kind: PageType) -> Result<Page, PagerError>
fn free_page(&self, id: u32) -> Result<(), PagerError>
fn page_count(&self) -> Result<u32, PagerError>
Source§fn enable_deferred_reclamation(&self) -> Result<(), PagerError>
fn enable_deferred_reclamation(&self) -> Result<(), PagerError>
fn prefetch_hint(&self, id: u32)
Auto Trait Implementations§
impl !Freeze for Pager
impl !RefUnwindSafe for Pager
impl Forget for Pager
impl Move for Pager
impl Send for Pagerwhere
RawVecInner: Send,
Mutex<NativePagerFile>: Send,
Mutex<Option<StagedPageBatch>>: Send,
Atomic<bool>: Send,
BoxRaw<[PageCacheShard]>: Send,
RwLock<HashMap<u32, Page>>: Send,
RwLock<FreeList>: Send,
Mutex<DeferredPageReclamation>: Send,
Atomic<u64>: Send,
ReentrantMutex<RawMutex, RawThreadId, ()>: Send,
RwLock<DatabaseHeader>: Send,
Mutex<()>: Send,
Mutex<bool>: Send,
RwLock<Option<Arc<Mutex<WalWriter>>>>: Send,
RwLock<Option<Arc<dyn PageOwnershipRecorder>>>: Send,
BoxRaw<[u8]>: Send,
impl Sync for Pagerwhere
RawVecInner: Sync,
Mutex<NativePagerFile>: Sync,
Mutex<Option<StagedPageBatch>>: Sync,
Atomic<bool>: Sync,
BoxRaw<[PageCacheShard]>: Sync,
RwLock<HashMap<u32, Page>>: Sync,
RwLock<FreeList>: Sync,
Mutex<DeferredPageReclamation>: Sync,
Atomic<u64>: Sync,
ReentrantMutex<RawMutex, RawThreadId, ()>: Sync,
RwLock<DatabaseHeader>: Sync,
Mutex<()>: Sync,
Mutex<bool>: Sync,
RwLock<Option<Arc<Mutex<WalWriter>>>>: Sync,
RwLock<Option<Arc<dyn PageOwnershipRecorder>>>: Sync,
BoxRaw<[u8]>: Sync,
impl Unpin for Pagerwhere
*const u8 is !null: Unpin,
Align4<u32>: Unpin,
Align1<u8>: Unpin,
I32NotAllOnes: Unpin,
Box<[PageCacheShard]>: Unpin,
*const LeafNode<u32, SetValZST> is !null: Unpin,
Box<(u32, SetValZST)>: Unpin,
Align8<u64>: Unpin,
Align8<usize>: Unpin,
Arc<Mutex<WalWriter>>: Unpin,
Arc<dyn PageOwnershipRecorder>: Unpin,
Box<[u8]>: Unpin,
impl UnsafeUnpin for Pagerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
I32NotAllOnes: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
*const [PageCacheShard] is !null: UnsafeUnpin,
PhantomData<[PageCacheShard]>: UnsafeUnpin,
PhantomData<(u32, Page)>: UnsafeUnpin,
*const LeafNode<u32, SetValZST> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(u32, SetValZST)>>: UnsafeUnpin,
Align8<u64>: UnsafeUnpin,
Align8<usize>: UnsafeUnpin,
*const ArcInner<Mutex<WalWriter>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<WalWriter>>>: UnsafeUnpin,
*const ArcInner<dyn PageOwnershipRecorder> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn PageOwnershipRecorder>>: UnsafeUnpin,
*const [u8] is !null: UnsafeUnpin,
PhantomData<[u8]>: UnsafeUnpin,
impl UnwindSafe for Pagerwhere
RawVecInner: UnwindSafe,
Mutex<NativePagerFile>: UnwindSafe,
Mutex<Option<StagedPageBatch>>: UnwindSafe,
Align1<u8>: UnwindSafe,
BoxRaw<[PageCacheShard]>: UnwindSafe,
RwLock<HashMap<u32, Page>>: UnwindSafe,
RwLock<FreeList>: UnwindSafe,
Mutex<DeferredPageReclamation>: UnwindSafe,
Align8<u64>: UnwindSafe,
Align8<usize>: UnwindSafe,
RwLock<DatabaseHeader>: UnwindSafe,
Mutex<()>: UnwindSafe,
Mutex<bool>: UnwindSafe,
RwLock<Option<Arc<Mutex<WalWriter>>>>: UnwindSafe,
RwLock<Option<Arc<dyn PageOwnershipRecorder>>>: UnwindSafe,
BoxRaw<[u8]>: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request