ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
circuit_cache.h File Reference

C-linkage interface to the in-process provenance circuit cache. More...

#include "provsql_utils.h"
Include dependency graph for circuit_cache.h:
This graph shows which files directly or indirectly include this file:

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.
 

Detailed Description

C-linkage interface to the in-process provenance circuit cache.

The circuit cache is a bounded, LRU-evicting in-memory store that avoids repeated round-trips to the mmap-backed persistent circuit storage for recently accessed gates. It is implemented in C++ (see CircuitCache.h / CircuitCache.cpp) but exposed to the C parts of the extension through this header.

Gates evicted from the cache are flushed to the background mmap worker via the shared-memory pipe. Lookups that miss the cache fall back to reading the mmap files directly.

Definition in file circuit_cache.h.

Function Documentation

◆ circuit_cache_create_gate()

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 evicted (and flushed to persistent storage) to make room.

Parameters
tokenUUID identifying the new gate.
typeGate type (e.g. gate_input, gate_plus).
nb_childrenNumber of child gates.
childrenArray of nb_children child UUIDs.
Returns
true if the gate was inserted, false if it was already present in the cache.

Definition at line 55 of file CircuitCache.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ circuit_cache_get_children()

unsigned circuit_cache_get_children ( pg_uuid_t  token,
pg_uuid_t **  children 
)

Retrieve the children of a cached gate.

Looks up token in the cache and, on a hit, allocates an array of child UUIDs in the current memory context and writes its address to *children.

Parameters
tokenUUID of the gate to look up.
childrenOutput parameter: set to a freshly allocated array of child UUIDs on success; untouched on a cache miss.
Returns
Number of children found, or UINT_MAX on a cache miss.

Definition at line 60 of file CircuitCache.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ circuit_cache_get_type()

gate_type circuit_cache_get_type ( pg_uuid_t  token)

Retrieve the type of a cached gate.

Parameters
tokenUUID of the gate to look up.
Returns
The gate_type of the gate, or gate_invalid on a miss.

Definition at line 76 of file CircuitCache.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: