libdballe  7.21
Public Member Functions | Protected Attributes | List of all members
dballe::db::summary::Stack Class Reference

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.
 
Summarypush (const Query &query)
 Add a new summary to the stack, and return a reference to it.
 
const Summarytop () 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< Summarysummaries
 Summaries for the current query. More...
 

Detailed Description

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.

Member Function Documentation

◆ query()

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.

Returns
how the resulting stack supports the query.

Member Data Documentation

◆ summaries

std::vector<Summary> dballe::db::summary::Stack::summaries
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.


The documentation for this class was generated from the following file: