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

An index from names to ids, kept in a file of pages as a B+ tree: leaves of names in order, each with its id, and pages above them that say which page holds which names. More...

#include <name_index.h>

Public Member Functions

absl::Status Open (const std::string &path)
 Opens the index in the file at path, creating it when it isn't there.
 
absl::Status OpenTemporary ()
 Opens an index in a file with no name, which is deleted once it's closed.
 
void Flush ()
 Writes the changed pages to the file.
 
uint64_t page_reads () const
 
uint64_t page_writes () const
 
std::optional< uint32_t > Find (std::string_view name) const
 Returns the id kept for name, if there's one.
 
void Insert (std::string_view name, uint32_t id)
 Keeps id for name, which the index doesn't have yet.
 
std::vector< std::string > NamesStartingWith (std::string_view prefix, size_t limit) const
 Returns up to limit names that start with prefix, in order.
 

Static Public Attributes

static constexpr size_t kMaxName = 47
 The longest name it keeps, as long as a node's.
 

Detailed Description

An index from names to ids, kept in a file of pages as a B+ tree: leaves of names in order, each with its id, and pages above them that say which page holds which names.

Finding a name reads a page on each level.

Definition at line 20 of file name_index.h.

Member Function Documentation

◆ Find()

std::optional< uint32_t > smollergraph::NameIndex::Find ( std::string_view  name) const

Returns the id kept for name, if there's one.

Definition at line 30 of file name_index.cc.

◆ Flush()

void smollergraph::NameIndex::Flush ( )
inline

Writes the changed pages to the file.

Definition at line 30 of file name_index.h.

◆ Insert()

void smollergraph::NameIndex::Insert ( std::string_view  name,
uint32_t  id 
)

Keeps id for name, which the index doesn't have yet.

Definition at line 40 of file name_index.cc.

◆ NamesStartingWith()

std::vector< std::string > smollergraph::NameIndex::NamesStartingWith ( std::string_view  prefix,
size_t  limit 
) const

Returns up to limit names that start with prefix, in order.

Definition at line 107 of file name_index.cc.

◆ Open()

absl::Status smollergraph::NameIndex::Open ( const std::string &  path)

Opens the index in the file at path, creating it when it isn't there.

Definition at line 12 of file name_index.cc.

◆ OpenTemporary()

absl::Status smollergraph::NameIndex::OpenTemporary ( )

Opens an index in a file with no name, which is deleted once it's closed.

Definition at line 21 of file name_index.cc.

◆ page_reads()

uint64_t smollergraph::NameIndex::page_reads ( ) const
inline

Definition at line 31 of file name_index.h.

◆ page_writes()

uint64_t smollergraph::NameIndex::page_writes ( ) const
inline

Definition at line 32 of file name_index.h.

Member Data Documentation

◆ kMaxName

constexpr size_t smollergraph::NameIndex::kMaxName = 47
staticconstexpr

The longest name it keeps, as long as a node's.

Definition at line 23 of file name_index.h.


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