smollerGraph 0.20.2
A small graph database, from scratch
Loading...
Searching...
No Matches
smollergraph::RecordFile< Record > Class Template Reference

A file of fixed-size records, packed into pages after a header page, which holds how many records there are. More...

#include <record_file.h>

Public Member Functions

absl::Status Open (const std::string &path)
 Opening another file writes back the changes to the one that was open.
 
absl::Status OpenTemporary ()
 
void Flush ()
 Writes the changed pages to the file.
 
uint32_t count () const
 
uint64_t page_reads () const
 
uint64_t page_writes () const
 
Record Read (uint32_t id) const
 Reads record id, which has to be below count().
 
void Write (uint32_t id, const Record &record)
 
uint32_t Append (const Record &record)
 Adds a record after the last one, and returns its id.
 

Static Public Member Functions

static PageId PageOf (uint32_t id)
 Page 0 is the header, so the records start on page 1.
 
static size_t OffsetOf (uint32_t id)
 

Static Public Attributes

static constexpr uint32_t kPerPage = kPageSize / sizeof(Record)
 
static constexpr size_t kPoolPages = 16384
 The most pages the pool keeps in memory, 64 MiB of them, which holds the million relationships we benchmark.
 

Detailed Description

template<typename Record>
class smollergraph::RecordFile< Record >

A file of fixed-size records, packed into pages after a header page, which holds how many records there are.

A record's id says which page it's on and where, so finding one needs no search. Its pages go through a buffer pool, which writes the changed ones to the file when it needs their frames, or when it's flushed or closed.

Definition at line 22 of file record_file.h.

Member Function Documentation

◆ Append()

template<typename Record >
uint32_t smollergraph::RecordFile< Record >::Append ( const Record &  record)
inline

Adds a record after the last one, and returns its id.

Definition at line 76 of file record_file.h.

◆ count()

template<typename Record >
uint32_t smollergraph::RecordFile< Record >::count ( ) const
inline

Definition at line 52 of file record_file.h.

◆ Flush()

template<typename Record >
void smollergraph::RecordFile< Record >::Flush ( )
inline

Writes the changed pages to the file.

Definition at line 50 of file record_file.h.

◆ OffsetOf()

template<typename Record >
static size_t smollergraph::RecordFile< Record >::OffsetOf ( uint32_t  id)
inlinestatic

Definition at line 58 of file record_file.h.

◆ Open()

template<typename Record >
absl::Status smollergraph::RecordFile< Record >::Open ( const std::string &  path)
inline

Opening another file writes back the changes to the one that was open.

Definition at line 33 of file record_file.h.

◆ OpenTemporary()

template<typename Record >
absl::Status smollergraph::RecordFile< Record >::OpenTemporary ( )
inline

Definition at line 41 of file record_file.h.

◆ page_reads()

template<typename Record >
uint64_t smollergraph::RecordFile< Record >::page_reads ( ) const
inline

Definition at line 53 of file record_file.h.

◆ page_writes()

template<typename Record >
uint64_t smollergraph::RecordFile< Record >::page_writes ( ) const
inline

Definition at line 54 of file record_file.h.

◆ PageOf()

template<typename Record >
static PageId smollergraph::RecordFile< Record >::PageOf ( uint32_t  id)
inlinestatic

Page 0 is the header, so the records start on page 1.

Definition at line 57 of file record_file.h.

◆ Read()

template<typename Record >
Record smollergraph::RecordFile< Record >::Read ( uint32_t  id) const
inline

Reads record id, which has to be below count().

Definition at line 63 of file record_file.h.

◆ Write()

template<typename Record >
void smollergraph::RecordFile< Record >::Write ( uint32_t  id,
const Record &  record 
)
inline

Definition at line 70 of file record_file.h.

Member Data Documentation

◆ kPerPage

template<typename Record >
constexpr uint32_t smollergraph::RecordFile< Record >::kPerPage = kPageSize / sizeof(Record)
staticconstexpr

Definition at line 27 of file record_file.h.

◆ kPoolPages

template<typename Record >
constexpr size_t smollergraph::RecordFile< Record >::kPoolPages = 16384
staticconstexpr

The most pages the pool keeps in memory, 64 MiB of them, which holds the million relationships we benchmark.

Definition at line 30 of file record_file.h.


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