|
smollerGraph 0.20.2
A small graph database, from scratch
|
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. | |
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.
| 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.
|
inline |
Writes the changed pages to the file.
Definition at line 30 of file name_index.h.
| 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.
| 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.
| 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.
| 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.
|
inline |
Definition at line 31 of file name_index.h.
|
inline |
Definition at line 32 of file name_index.h.
|
staticconstexpr |
The longest name it keeps, as long as a node's.
Definition at line 23 of file name_index.h.