15#if PG_VERSION_NUM >= 160000
18#include "catalog/pg_type.h"
19#include "utils/jsonb.h"
20#include "utils/fmgrprotos.h"
21#include "utils/uuid.h"
59 pg_uuid_t token = *DatumGetUUIDP(PG_GETARG_DATUM(0));
65 text *result =
reinterpret_cast<text*
>(
66 palloc(f.
form.size() + VARHDRSZ));
67 SET_VARSIZE(result, f.
form.size() + VARHDRSZ);
68 memcpy(VARDATA(result), f.
form.data(), f.
form.size());
69 PG_RETURN_TEXT_P(result);
70 }
catch(
const std::exception &e) {
83 pg_uuid_t token = *DatumGetUUIDP(PG_GETARG_DATUM(0));
89 std::ostringstream out;
91 for(
size_t i = 0; i < key.
islands.size(); ++i)
92 out <<
"\nisland " << (i + 1) <<
": " << key.
islands[i].form;
93 const std::string s = out.str();
95 text *result =
reinterpret_cast<text*
>(palloc(s.size() + VARHDRSZ));
96 SET_VARSIZE(result, s.size() + VARHDRSZ);
97 memcpy(VARDATA(result), s.data(), s.size());
98 PG_RETURN_TEXT_P(result);
99 }
catch(
const std::exception &e) {
112 std::ostringstream out;
114 <<
"\"hits\":" << s.
hits
115 <<
",\"misses\":" << s.
misses
116 <<
",\"inserts\":" << s.
inserts
119 <<
",\"entries\":" << s.
entries
120 <<
",\"bytes\":" << s.
bytes
121 <<
",\"budget\":" << s.
budget
123 Datum json_datum = DirectFunctionCall1(
124 jsonb_in, CStringGetDatum(pstrdup(out.str().c_str())));
125 PG_RETURN_DATUM(json_datum);
126 }
catch(
const std::exception &e) {
Boolean provenance circuit with support for knowledge compilation.
BooleanCircuit getBooleanCircuit(GenericCircuit &gc, pg_uuid_t token, gate_t &gate, std::unordered_map< gate_t, gate_t > &gc_to_bc)
Build a BooleanCircuit from an already-loaded GenericCircuit.
Build in-memory circuits from the mmap-backed persistent store.
gate_t
Strongly-typed gate identifier.
Cache of compiled d-DNNFs, and folding of independent parts.
Fix macro conflicts between PostgreSQL headers and the C++ STL/Boost.
Boolean circuit for provenance formula evaluation.
void rewriteMultivaluedGates()
Rewrite all MULVAR/MULIN gate clusters into standard AND/OR/NOT circuits.
static ProbCache & instance()
The cache of this backend.
void reset()
Empties the cache and its counters.
ProbCacheStats stats() const
The counters, with the current number and size of entries.
IslandKey computeIslandKey(const BooleanCircuit &c, gate_t root)
Splits the circuit below root into its outermost islands and the residual.
CanonicalForm computeCanonicalForm(const BooleanCircuit &c, gate_t root, const GateSet *abstract_leaves)
Canonical form of the circuit below root.
#define provsql_error(fmt,...)
Report a fatal ProvSQL error and abort the current transaction.
Shared-memory segment and inter-process pipe management.
Core types, constants, and utilities shared across ProvSQL.
C++ utility functions for UUID manipulation.
A circuit split into its outermost islands and what remains.
CanonicalForm residual
Form of the circuit, each island read as an input.
std::vector< CanonicalForm > islands
Form of each island, in the same order.
Counters of the cache since it was last emptied.
uint64_t evictions
Entries dropped to stay under the size limit.
uint64_t inserts
Entries stored.
uint64_t hits
Lookups served from an entry.
size_t bytes
Estimated size of the entries held now.
uint64_t misses
Lookups that found no usable entry.
size_t budget
Size the entries may reach before some are dropped.
size_t entries
Entries held now.
uint64_t rejections
d-DNNFs too large to be stored