souffle
2.0.2-371-g6315b36
|
#include <SymbolTable.h>
Public Member Functions | |
Lock::Lease | acquireLock () const |
bool | contains (const RamDomain index) const |
Check if the symbol table contains an index. More... | |
bool | contains (const std::string &symbol) const |
Check if the symbol table contains a string. More... | |
void | insert (const std::string &symbol) |
Insert a single symbol into the table, not that this operation should not be used if inserting symbols in bulk. More... | |
void | insert (const std::vector< std::string > &symbols) |
Bulk insert symbols into the table, note that this operation is more efficient than repeated inserts of single symbols. More... | |
RamDomain | lookup (const std::string &symbol) |
Find the index of a symbol in the table, inserting a new symbol if it does not exist there already. More... | |
RamDomain | lookupExisting (const std::string &symbol) const |
Finds the index of a symbol in the table, giving an error if it's not found. More... | |
SymbolTable & | operator= (const SymbolTable &other) |
Assignment operator, performs a deep copy and frees memory allocated for all strings. More... | |
SymbolTable & | operator= (SymbolTable &&other) noexcept |
Assignment operator for r-value references. More... | |
void | print (std::ostream &out) const |
Print the symbol table to the given stream. More... | |
const std::string & | resolve (const RamDomain index) const |
Find a symbol in the table by its index, note that this gives an error if the index is out of bounds. More... | |
size_t | size () const |
SymbolTable ()=default | |
Empty constructor. More... | |
SymbolTable (const SymbolTable &other) | |
Copy constructor, performs a deep copy. More... | |
SymbolTable (std::initializer_list< std::string > symbols) | |
SymbolTable (SymbolTable &&other) noexcept | |
Copy constructor for r-value reference. More... | |
RamDomain | unsafeLookup (const std::string &symbol) |
Find the index of a symbol in the table, inserting a new symbol if it does not exist there already. More... | |
const std::string & | unsafeResolve (const RamDomain index) const |
virtual | ~SymbolTable ()=default |
Destructor, frees memory allocated for all strings. More... | |
Private Member Functions | |
void | newSymbol (const std::string &symbol) |
Convenience method to place a new symbol in the table, if it does not exist. More... | |
size_t | newSymbolOfIndex (const std::string &symbol) |
Convenience method to place a new symbol in the table, if it does not exist, and return the index of it. More... | |
Private Attributes | |
Lock | access |
A lock to synchronize parallel accesses. More... | |
std::deque< std::string > | numToStr |
Map indices to strings. More... | |
std::unordered_map< std::string, size_t > | strToNum |
Map strings to indices. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const SymbolTable &table) |
Stream operator, used as a convenience for print. More... | |
Global pool of re-usable strings
SymbolTable stores Datalog symbols and converts them to numbers and vice versa.
Definition at line 48 of file SymbolTable.h.
|
default |
Empty constructor.
|
inline |
Copy constructor, performs a deep copy.
Definition at line 87 of file SymbolTable.h.
|
inlinenoexcept |
Copy constructor for r-value reference.
Definition at line 90 of file SymbolTable.h.
References newSymbol().
|
inline |
|
virtualdefault |
Destructor, frees memory allocated for all strings.
|
inline |
Definition at line 238 of file SymbolTable.h.
|
inline |
|
inline |
Check if the symbol table contains a string.
Definition at line 215 of file SymbolTable.h.
|
inline |
Insert a single symbol into the table, not that this operation should not be used if inserting symbols in bulk.
Definition at line 193 of file SymbolTable.h.
|
inline |
Bulk insert symbols into the table, note that this operation is more efficient than repeated inserts of single symbols.
Definition at line 179 of file SymbolTable.h.
|
inline |
Find the index of a symbol in the table, inserting a new symbol if it does not exist there already.
Definition at line 124 of file SymbolTable.h.
Referenced by souffle::tuple::rewind(), and souffle::interpreter::test::TEST().
|
inline |
Finds the index of a symbol in the table, giving an error if it's not found.
Definition at line 133 of file SymbolTable.h.
|
inlineprivate |
Convenience method to place a new symbol in the table, if it does not exist.
Definition at line 75 of file SymbolTable.h.
Referenced by SymbolTable().
|
inlineprivate |
Convenience method to place a new symbol in the table, if it does not exist, and return the index of it.
Definition at line 61 of file SymbolTable.h.
Referenced by operator=().
|
inline |
Assignment operator, performs a deep copy and frees memory allocated for all strings.
Definition at line 106 of file SymbolTable.h.
|
inlinenoexcept |
Assignment operator for r-value references.
Definition at line 116 of file SymbolTable.h.
References access, souffle::Lock::acquire(), and newSymbolOfIndex().
|
inline |
Print the symbol table to the given stream.
Definition at line 202 of file SymbolTable.h.
|
inline |
Find a symbol in the table by its index, note that this gives an error if the index is out of bounds.
Definition at line 154 of file SymbolTable.h.
Referenced by souffle::interpreter::RelInterface::iterator_base::operator++(), and souffle::tuple::operator<<().
|
inline |
Definition at line 172 of file SymbolTable.h.
References access, souffle::Lock::acquire(), and strToNum.
Referenced by unsafeLookup().
|
inline |
Find the index of a symbol in the table, inserting a new symbol if it does not exist there already.
Definition at line 147 of file SymbolTable.h.
References access, souffle::Lock::acquire(), and size().
|
inline |
Definition at line 167 of file SymbolTable.h.
|
friend |
Stream operator, used as a convenience for print.
Definition at line 243 of file SymbolTable.h.
|
mutableprivate |
A lock to synchronize parallel accesses.
Definition at line 51 of file SymbolTable.h.
Referenced by operator=(), size(), and unsafeLookup().
|
private |
|
private |
Map strings to indices.
Definition at line 57 of file SymbolTable.h.
Referenced by size(), and SymbolTable().