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

Template helper for populating provenance mappings from SPI results. More...

#include "executor/spi.h"
#include "provsql_utils_cpp.h"
#include "CircuitFromMMap.h"
#include "Circuit.hpp"
Include dependency graph for provenance_evaluate_compiled.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
void initialize_provenance_mapping (const constants_t &constants, GenericCircuit &c, std::unordered_map< gate_t, T > &provenance_mapping, const std::function< T(const char *)> &charp_to_value, bool drop_table)
 Populate a provenance mapping from the current SPI result set.
 

Variables

const char * drop_temp_table
 DROP TABLE statement for the per-query temporary provenance mapping table.
 

Detailed Description

Template helper for populating provenance mappings from SPI results.

When evaluating a provenance circuit over a user-defined semiring, the first step is to build a provenance_mapping that maps each input gate to its semiring value. The values come from a database table or temporary view queried via SPI; this template handles the SPI-result iteration that is common to all semiring types.

After reading the SPI result set, the function optionally drops the temporary helper table (if drop_table is true) and closes the SPI connection.

Definition in file provenance_evaluate_compiled.hpp.

Function Documentation

◆ initialize_provenance_mapping()

template<typename T >
void initialize_provenance_mapping ( const constants_t constants,
GenericCircuit c,
std::unordered_map< gate_t, T > &  provenance_mapping,
const std::function< T(const char *)> &  charp_to_value,
bool  drop_table 
)

Populate a provenance mapping from the current SPI result set.

Iterates over the rows returned by the most recent SPI query. Each row is expected to have two columns:

  1. A value column (column 1) containing the semiring value as text.
  2. A UUID column (column 2) identifying the circuit input gate.

The charp_to_value converter is called on the text of column 1 to produce the corresponding T value.

Template Parameters
TSemiring value type.
Parameters
constantsCached OID constants (used to verify column types).
cThe GenericCircuit used to resolve gate IDs.
provenance_mappingOutput map from gate IDs to semiring values; entries are added by this function.
charp_to_valueConverter from the column-1 text to a T value.
drop_tableIf true, execute the drop_temp_table SQL statement after processing all rows.

Definition at line 50 of file provenance_evaluate_compiled.hpp.

Here is the call graph for this function:

Variable Documentation

◆ drop_temp_table

const char* drop_temp_table
extern

DROP TABLE statement for the per-query temporary provenance mapping table.

Definition at line 51 of file provenance_evaluate_compiled.cpp.