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

HAVING-clause provenance evaluation for all built-in semirings. More...

#include "postgres.h"
#include "utils/lsyscache.h"
#include <vector>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include "having_semantics.hpp"
#include "provsql_utils_cpp.h"
#include "subset.hpp"
#include "semiring/Boolean.h"
#include "semiring/BoolExpr.h"
#include "semiring/Counting.h"
#include "semiring/Formula.h"
#include "semiring/Why.h"
Include dependency graph for having_semantics.cpp:

Go to the source code of this file.

Functions

template<typename SemiringT , typename MapT >
static void try_having_impl (GenericCircuit &c, gate_t g, MapT &mapping, SemiringT S)
 Rewrite HAVING comparison gates in the circuit by enumerating possible worlds.
 
void provsql_try_having_formula (GenericCircuit &c, gate_t g, std::unordered_map< gate_t, std::string > &mapping)
 Evaluate the HAVING sub-circuit at g over the Formula semiring.
 
void provsql_try_having_counting (GenericCircuit &c, gate_t g, std::unordered_map< gate_t, unsigned > &mapping)
 Evaluate the HAVING sub-circuit at g over the Counting semiring.
 
void provsql_try_having_why (GenericCircuit &c, gate_t g, std::unordered_map< gate_t, semiring::why_provenance_t > &mapping)
 Evaluate the HAVING sub-circuit at g over the Why-provenance semiring.
 
void provsql_try_having_boolexpr (GenericCircuit &c, semiring::BoolExpr &be, gate_t g, std::unordered_map< gate_t, gate_t > &mapping)
 Evaluate the HAVING sub-circuit at g over the BoolExpr semiring.
 
void provsql_try_having_boolean (GenericCircuit &c, gate_t g, std::unordered_map< gate_t, bool > &mapping)
 Evaluate the HAVING sub-circuit at g over the Boolean semiring.
 

Detailed Description

HAVING-clause provenance evaluation for all built-in semirings.

Implements the five provsql_try_having_*() functions declared in having_semantics.hpp, one per supported semiring:

Each function evaluates the sub-circuit rooted at the given gate_agg / gate_semimod gate using enumerate_valid_worlds() (for exact predicate testing) and populates the provenance mapping.

An anonymous-namespace helper provsql_try_having_internal() provides the shared logic; the five public functions are thin wrappers that instantiate it for the appropriate semiring type.

Definition in file having_semantics.cpp.

Function Documentation

◆ provsql_try_having_boolean()

void provsql_try_having_boolean ( GenericCircuit c,
gate_t  g,
std::unordered_map< gate_t, bool > &  mapping 
)

Evaluate the HAVING sub-circuit at g over the Boolean semiring.

Parameters
cThe generic circuit containing gate g.
gRoot gate of the HAVING sub-circuit.
mappingMap from input gates to their Boolean values; populated on successful evaluation.

Definition at line 363 of file having_semantics.cpp.

Here is the caller graph for this function:

◆ provsql_try_having_boolexpr()

void provsql_try_having_boolexpr ( GenericCircuit c,
semiring::BoolExpr be,
gate_t  g,
std::unordered_map< gate_t, gate_t > &  mapping 
)

Evaluate the HAVING sub-circuit at g over the BoolExpr semiring.

Parameters
cThe generic circuit containing gate g.
beThe BoolExpr semiring instance (shared circuit).
gRoot gate of the HAVING sub-circuit.
mappingMap from input gates to their gate_t values in be; populated on successful evaluation.

Definition at line 354 of file having_semantics.cpp.

Here is the caller graph for this function:

◆ provsql_try_having_counting()

void provsql_try_having_counting ( GenericCircuit c,
gate_t  g,
std::unordered_map< gate_t, unsigned > &  mapping 
)

Evaluate the HAVING sub-circuit at g over the Counting semiring.

Parameters
cThe generic circuit containing gate g.
gRoot gate of the HAVING sub-circuit.
mappingMap from input gates to their count values; populated on successful evaluation.

Definition at line 338 of file having_semantics.cpp.

Here is the caller graph for this function:

◆ provsql_try_having_formula()

void provsql_try_having_formula ( GenericCircuit c,
gate_t  g,
std::unordered_map< gate_t, std::string > &  mapping 
)

Evaluate the HAVING sub-circuit at g over the Formula semiring.

Parameters
cThe generic circuit containing gate g.
gRoot gate of the HAVING sub-circuit.
mappingMap from input gates to their formula string values; populated on successful evaluation.

Definition at line 330 of file having_semantics.cpp.

Here is the caller graph for this function:

◆ provsql_try_having_why()

void provsql_try_having_why ( GenericCircuit c,
gate_t  g,
std::unordered_map< gate_t, semiring::why_provenance_t > &  mapping 
)

Evaluate the HAVING sub-circuit at g over the Why-provenance semiring.

Parameters
cThe generic circuit containing gate g.
gRoot gate of the HAVING sub-circuit.
mappingMap from input gates to their why-provenance values; populated on successful evaluation.

Definition at line 346 of file having_semantics.cpp.

Here is the caller graph for this function:

◆ try_having_impl()

template<typename SemiringT , typename MapT >
static void try_having_impl ( GenericCircuit c,
gate_t  g,
MapT &  mapping,
SemiringT  S 
)
static

Rewrite HAVING comparison gates in the circuit by enumerating possible worlds.

Template Parameters
SemiringTThe semiring type used for evaluation.
MapTThe provenance mapping type (gate_t → semiring value).
Parameters
cCircuit to rewrite.
gRoot gate of the sub-circuit to inspect.
mappingProvenance mapping updated in place.
SSemiring instance.

Definition at line 192 of file having_semantics.cpp.

Here is the call graph for this function: