![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
LRU circuit-gate cache implementation and C-linkage wrappers. More...

Go to the source code of this file.
Functions | |
| bool | circuit_cache_create_gate (pg_uuid_t token, gate_type type, unsigned nb_children, pg_uuid_t *children) |
| Insert a new gate into the circuit cache. | |
| unsigned | circuit_cache_get_children (pg_uuid_t token, pg_uuid_t **children) |
| Retrieve the children of a cached gate. | |
| gate_type | circuit_cache_get_type (pg_uuid_t token) |
| Retrieve the type of a cached gate. | |
Variables | |
| constexpr unsigned | MAX_CIRCUIT_CACHE_SIZE = 1 << 20 |
| Maximum total byte size of the in-process circuit gate cache (1 MiB). | |
| static CircuitCache | cache |
| Process-local singleton circuit gate cache. | |
LRU circuit-gate cache implementation and C-linkage wrappers.
Implements CircuitCache::insert() and CircuitCache::get(), and the three C-linkage wrapper functions declared in circuit_cache.h:
The cache is a process-local Boost multi-index container bounded by MAX_CIRCUIT_CACHE_SIZE bytes. On overflow, the oldest (FIFO) entry is evicted. The C wrappers manage a singleton CircuitCache instance and translate between pg_uuid_t / gate_type (C types) and the C++ CircuitCacheInfos structure.
Definition in file CircuitCache.cpp.
| bool circuit_cache_create_gate | ( | pg_uuid_t | token, |
| gate_type | type, | ||
| unsigned | nb_children, | ||
| pg_uuid_t * | children ) |
Insert a new gate into the circuit cache.
Records the gate identified by token with the given type and nb_children children. If the cache is full the oldest entry is dropped from memory to make room (the worker already holds it under the write-through invariant, so no flush is performed). If an entry for token is already present, its type and children are overwritten when the incoming call carries strictly more information (a real gate_type replacing a previously stored gate_invalid, or a non-empty children list replacing an empty one); otherwise the entry is left untouched and just refreshed in LRU order.
| token | UUID identifying the new gate. |
| type | Gate type (e.g. gate_input, gate_plus). |
| nb_children | Number of child gates. |
| children | Array of nb_children child UUIDs. |
true if the gate was newly inserted, false if it was already present in the cache (regardless of whether its contents were upgraded). Definition at line 74 of file CircuitCache.cpp.

Retrieve the children of a cached gate.
Looks up token in the cache and, on a hit with at least one child, allocates an array of child UUIDs (via calloc) and writes its address to *children.
| token | UUID of the gate to look up. |
| children | Output parameter: set to a freshly calloc'd array of child UUIDs on a hit with children; set to NULL on a miss or on a hit for a zero-child entry (the two are deliberately indistinguishable to callers, see the file-level note). |
0 on a miss or zero-child hit. Callers should detect a miss via *children==NULL, not via the return value. Definition at line 79 of file CircuitCache.cpp.

Retrieve the type of a cached gate.
| token | UUID of the gate to look up. |
gate_type of the gate, or gate_invalid on a miss. Definition at line 102 of file CircuitCache.cpp.

|
static |
Process-local singleton circuit gate cache.
Definition at line 72 of file CircuitCache.cpp.
|
constexpr |
Maximum total byte size of the in-process circuit gate cache (1 MiB).
Definition at line 24 of file CircuitCache.cpp.