![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
The cache of compiled d-DNNFs of one backend. More...
#include "ProbCache.h"

Classes | |
| struct | Entry |
| A compiled d-DNNF and how its inputs match the leaves of its form. More... | |
Public Member Functions | |
| const Entry * | find (const CanonicalForm &key, const std::string &builder=std::string()) |
Looks key up. | |
| bool | admits (size_t bytes) |
Whether an entry of bytes is small enough to be stored; counts a rejection otherwise. | |
| bool | insert (const CanonicalForm &key, Entry entry) |
Stores entry under key, replacing an entry already there. | |
| void | trim () |
| Drops the least recently used entries until the cache fits its budget (which the setting may have lowered since the last insertion). | |
| void | reset () |
| Empties the cache and its counters. | |
| ProbCacheStats | stats () const |
| The counters, with the current number and size of entries. | |
Static Public Member Functions | |
| static ProbCache & | instance () |
| The cache of this backend. | |
Private Member Functions | |
| ProbCache ()=default | |
Private Attributes | |
| std::list< Entry > | lru_ |
| std::unordered_map< std::string, std::list< Entry >::iterator > | map_ |
| size_t | bytes_ = 0 |
| ProbCacheStats | stats_ |
The cache of compiled d-DNNFs of one backend.
Entries are dropped least recently used first once their estimated total size passes the budget, and a d-DNNF larger than a quarter of the budget is not stored. The budget is provsql.prob_cache_size, lowered to a quarter of provsql.max_memory when that is smaller.
Definition at line 57 of file ProbCache.h.
|
privatedefault |

| bool provsql::ProbCache::admits | ( | size_t | bytes | ) |
Whether an entry of bytes is small enough to be stored; counts a rejection otherwise.
Definition at line 180 of file ProbCache.cpp.
| const ProbCache::Entry * provsql::ProbCache::find | ( | const CanonicalForm & | key, |
| const std::string & | builder = std::string() ) |
Looks key up.
A non-empty builder restricts the hit to an entry compiled by that method; an entry of another builder counts as a miss.
Definition at line 166 of file ProbCache.cpp.
| bool provsql::ProbCache::insert | ( | const CanonicalForm & | key, |
| Entry | entry ) |
Stores entry under key, replacing an entry already there.
Definition at line 188 of file ProbCache.cpp.

|
static |
The cache of this backend.
Definition at line 160 of file ProbCache.cpp.


| void provsql::ProbCache::reset | ( | ) |
Empties the cache and its counters.
Definition at line 214 of file ProbCache.cpp.

| ProbCacheStats provsql::ProbCache::stats | ( | ) | const |
The counters, with the current number and size of entries.
Definition at line 222 of file ProbCache.cpp.

| void provsql::ProbCache::trim | ( | ) |
Drops the least recently used entries until the cache fits its budget (which the setting may have lowered since the last insertion).
Definition at line 204 of file ProbCache.cpp.

|
private |
Definition at line 100 of file ProbCache.h.
|
private |
Definition at line 98 of file ProbCache.h.
|
private |
Definition at line 99 of file ProbCache.h.
|
mutableprivate |
Definition at line 101 of file ProbCache.h.