smollerGraph 0.20.2
A small graph database, from scratch
Loading...
Searching...
No Matches
smollergraph::BufferPool Class Reference

Keeps some of a file's pages in memory, in frames, so reading or changing a page there needs no system call. More...

#include <buffer_pool.h>

Public Member Functions

 BufferPool (Pager &pager, size_t frames)
 A pool of up to frames pages of the file pager has open.
 
 ~BufferPool ()
 Writes the changed pages back.
 
 BufferPool (const BufferPool &)=delete
 
BufferPool & operator= (const BufferPool &)=delete
 
PageHandle Fetch (PageId id)
 Pins page id, reading it from the file when it isn't in a frame.
 
void Flush ()
 Writes the changed pages back to the file, and keeps them.
 
void Clear ()
 Writes the changed pages back, and forgets them all, before the pager opens another file.
 

Friends

class PageHandle
 

Detailed Description

Keeps some of a file's pages in memory, in frames, so reading or changing a page there needs no system call.

The file is read when a page comes into a frame, and written when a changed page leaves one, or when it's flushed.

Definition at line 37 of file buffer_pool.h.

Constructor & Destructor Documentation

◆ BufferPool() [1/2]

smollergraph::BufferPool::BufferPool ( Pager &  pager,
size_t  frames 
)

A pool of up to frames pages of the file pager has open.

Definition at line 19 of file buffer_pool.cc.

◆ ~BufferPool()

smollergraph::BufferPool::~BufferPool ( )

Writes the changed pages back.

Definition at line 26 of file buffer_pool.cc.

◆ BufferPool() [2/2]

smollergraph::BufferPool::BufferPool ( const BufferPool &  )
delete

Member Function Documentation

◆ Clear()

void smollergraph::BufferPool::Clear ( )

Writes the changed pages back, and forgets them all, before the pager opens another file.

Definition at line 97 of file buffer_pool.cc.

◆ Fetch()

PageHandle smollergraph::BufferPool::Fetch ( PageId  id)

Pins page id, reading it from the file when it isn't in a frame.

A page past the end of the file starts out as zeros.

Definition at line 28 of file buffer_pool.cc.

◆ Flush()

void smollergraph::BufferPool::Flush ( )

Writes the changed pages back to the file, and keeps them.

Definition at line 88 of file buffer_pool.cc.

◆ operator=()

BufferPool & smollergraph::BufferPool::operator= ( const BufferPool &  )
delete

Friends And Related Symbol Documentation

◆ PageHandle

friend class PageHandle
friend

Definition at line 56 of file buffer_pool.h.


The documentation for this class was generated from the following files: