libdballe
7.19
|
Stack of summary in increasing order of selectivity. More...
#include <summary.h>
Public Member Functions | |
bool | empty () const |
Check if the stack is empty. | |
unsigned | size () const |
Return the stack size. Only really useful for tests. | |
Summary & | push (const Query &query) |
Add a new summary to the stack, and return a reference to it. | |
const Summary & | top () const |
Return the topmost summary. | |
Support | query (const Query &query, bool exact, std::function< bool(const Entry &)> match) |
If the current summary stack can support the given query, append the resulting summary to the stack, else, remove all entries from the stack except the most general one. More... | |
Protected Attributes | |
std::vector< Summary > | summaries |
Summaries for the current query. More... | |
Stack of summary in increasing order of selectivity.
This is used to keep enough context to refine a summary as a query is refined, and to go back to a wider summary if the query is relaxed.
Ideally, there could be several levels in the stack, so that each subquery takes the previous one as a starting point, and the process gets faster and faster; however, a summary may support a query (in the sense that it knows that that query selects no data at all) while a more general summary may support it and return data (e.g. ask first for rep_memo=synop, then change one's mind and ask for rep_memo=temp.
Supporting such scenarios would require implementing nontrivial logic for an optimization that it is still unclear to me if it would be required. At the moment, I simplify implementation by just supporting two levels, and having each query always start from the topmost summary.
Support dballe::db::summary::Stack::query | ( | const Query & | query, |
bool | exact, | ||
std::function< bool(const Entry &)> | match | ||
) |
If the current summary stack can support the given query, append the resulting summary to the stack, else, remove all entries from the stack except the most general one.
|
protected |
Summaries for the current query.
summaries[0] is always the summary for the whole database; further summaries are appended as the query is refined.