1#ifndef SMOLLERGRAPH_TOKEN_STORE_H_
2#define SMOLLERGRAPH_TOKEN_STORE_H_
13#include "absl/status/status.h"
39 absl::Status
Open(
const std::string&
path);
42 uint64_t
page_reads()
const {
return file_.page_reads(); }
49 std::optional<TokenId>
Find(std::string_view name)
const;
52 return token ==
kNoToken ?
"" : names_[token];
61 std::vector<std::string> names_;
62 std::map<std::string, TokenId, std::less<>> tokens_;
A file of fixed-size records, packed into pages after a header page, which holds how many records the...
Names and the tokens that stand for them, kept in a file of records, and in memory both ways,...
std::string Name(TokenId token) const
Returns the name token stands for, or nothing for kNoToken.
uint64_t page_reads() const
uint64_t page_writes() const
TokenId Add(std::string_view name)
Returns the token for name, adding it the first time.
static constexpr size_t kMaxName
The longest name a token can stand for.
absl::Status OpenTemporary()
std::optional< TokenId > Find(std::string_view name) const
Returns the token for name, if the store has one.
absl::Status Open(const std::string &path)
Opens the store in the file at path, creating it when it isn't there.
constexpr TokenId kNoToken
The token for no name, such as the label of a node that hasn't got one.
uint32_t TokenId
A number that stands for a name many records share, such as the label Species, so a record keeps four...
A token's name on disk. Its id in the file is the token.