![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Persistent open-addressing hash table mapping UUIDs to integers. More...
#include "MMappedUUIDHashTable.h"

Classes | |
| struct | value_t |
| One slot in the hash table: a UUID key and its associated integer value. More... | |
| struct | table_t |
| On-disk layout of the hash table stored in the mmap file. More... | |
Public Member Functions | |
| MMappedUUIDHashTable (const char *filename, bool read_only, uint64_t magic) | |
| Open (or create) the mmap-backed hash table. | |
| ~MMappedUUIDHashTable () | |
| Sync and unmap the file. | |
| unsigned long | operator[] (pg_uuid_t u) const |
Look up the integer index for UUID u. | |
| std::pair< unsigned long, bool > | add (pg_uuid_t u) |
Insert UUID u, assigning it the next available integer. | |
| unsigned long | nbElements () const |
| Return the number of UUID→integer pairs currently stored. | |
| void | sync () |
Flush the backing region to its file (MappedRegion::sync()). | |
Static Public Attributes | |
| static constexpr unsigned long | NOTHING =static_cast<unsigned long>(-1) |
Sentinel returned by operator[]() when the UUID is not present. | |
Private Member Functions | |
| unsigned long | hash (pg_uuid_t u) const |
Compute the starting slot index for UUID u. | |
| unsigned long | find (pg_uuid_t u) const |
Find the slot index of u, or NOTHING if absent. | |
| void | grow () |
| Double the table capacity and rehash all existing entries. | |
| void | set (pg_uuid_t u, unsigned long i) |
Store the mapping u → i in the table. | |
Private Attributes | |
| MappedRegion | region |
| Backing storage (shared mmap, or heap buffer). | |
| table_t * | table |
Typed view of region.base(). | |
Static Private Attributes | |
| static constexpr unsigned | STARTING_LOG_SIZE =16 |
| Initial log2 capacity (65 536 slots). | |
| static constexpr double | MAXIMUM_LOAD_FACTOR =.5 |
| Rehash when this fraction of slots is occupied. | |
Persistent open-addressing hash table mapping UUIDs to integers.
Definition at line 40 of file MMappedUUIDHashTable.h.
| MMappedUUIDHashTable::MMappedUUIDHashTable | ( | const char * | filename, |
| bool | read_only, | ||
| uint64_t | magic ) |
Open (or create) the mmap-backed hash table.
| filename | Path to the backing file (created if absent). |
| read_only | If true, map the file read-only (no new entries can be inserted). |
| magic | Expected magic value for format validation. |
Definition at line 34 of file MMappedUUIDHashTable.cpp.

| MMappedUUIDHashTable::~MMappedUUIDHashTable | ( | ) |
Sync and unmap the file.
Definition at line 89 of file MMappedUUIDHashTable.cpp.
| std::pair< unsigned long, bool > MMappedUUIDHashTable::add | ( | pg_uuid_t | u | ) |
Insert UUID u, assigning it the next available integer.
If u is already present the existing value is returned without modification.
| u | UUID to insert. |
{value, inserted} where inserted is true if a new entry was created. Definition at line 112 of file MMappedUUIDHashTable.cpp.

|
private |
Find the slot index of u, or NOTHING if absent.
| u | UUID to look up. |
NOTHING if u is not in the table. Definition at line 94 of file MMappedUUIDHashTable.cpp.


|
private |
Double the table capacity and rehash all existing entries.
Definition at line 69 of file MMappedUUIDHashTable.cpp.


|
inlineprivate |
Compute the starting slot index for UUID u.
Reinterprets the first 8 bytes of u as a 64-bit integer and takes it modulo the current capacity.
| u | UUID to hash. |
Definition at line 112 of file MMappedUUIDHashTable.h.

|
inline |
Return the number of UUID→integer pairs currently stored.
Definition at line 171 of file MMappedUUIDHashTable.h.
| unsigned long MMappedUUIDHashTable::operator[] | ( | pg_uuid_t | u | ) | const |
Look up the integer index for UUID u.
| u | The UUID to look up. |
NOTHING if u is absent. Definition at line 105 of file MMappedUUIDHashTable.cpp.

|
private |
Store the mapping u → i in the table.
| u | UUID key to store. |
| i | Integer value to associate with u. |
Definition at line 129 of file MMappedUUIDHashTable.cpp.


| void MMappedUUIDHashTable::sync | ( | ) |
Flush the backing region to its file (MappedRegion::sync()).
Definition at line 134 of file MMappedUUIDHashTable.cpp.
|
staticconstexprprivate |
Rehash when this fraction of slots is occupied.
Definition at line 102 of file MMappedUUIDHashTable.h.
|
staticconstexpr |
Sentinel returned by operator[]() when the UUID is not present.
Definition at line 133 of file MMappedUUIDHashTable.h.
|
private |
Backing storage (shared mmap, or heap buffer).
Definition at line 96 of file MMappedUUIDHashTable.h.
|
staticconstexprprivate |
Initial log2 capacity (65 536 slots).
Definition at line 100 of file MMappedUUIDHashTable.h.
|
private |
Typed view of region.base().
Definition at line 97 of file MMappedUUIDHashTable.h.