![]() |
mutable
A Database System for Research and Fast Prototyping
|
InjectionCardinalityEstimator that estimates cardinalities based on a table that contains sizes for the given subproblems Table is initialized in the constructor by using an external json-file If no entry is found, uses the DummyEstimator to return an estimate. More...
#include <CardinalityEstimator.hpp>
Data Structures | |
struct | InjectionCardinalityDataModel |
Public Types | |
using | Subproblem = SmallBitset |
Public Member Functions | |
InjectionCardinalityEstimator (ThreadSafePooledString name_of_database) | |
Create an InjectionCardinalityEstimator for the database name_of_database from file that was passed by the user via commandline, saved in Options::Get().injected_cardinalities_file | |
InjectionCardinalityEstimator (Diagnostic &diag, ThreadSafePooledString name_of_database, std::istream &in) | |
Create an InjectionCardinalityEstimator for the database name_of_database from the inputstream in | |
~InjectionCardinalityEstimator ()=default | |
InjectionCardinalityEstimator (const InjectionCardinalityEstimator &)=delete | |
InjectionCardinalityEstimator (InjectionCardinalityEstimator &&)=default | |
InjectionCardinalityEstimator & | operator= (InjectionCardinalityEstimator &&)=default |
std::unique_ptr< DataModel > | empty_model () const override |
std::unique_ptr< DataModel > | estimate_scan (const QueryGraph &G, Subproblem P) const override |
std::unique_ptr< DataModel > | estimate_filter (const QueryGraph &G, const DataModel &data, const cnf::CNF &filter) const override |
std::unique_ptr< DataModel > | estimate_limit (const QueryGraph &G, const DataModel &data, std::size_t limit, std::size_t offset) const override |
std::unique_ptr< DataModel > | estimate_grouping (const QueryGraph &G, const DataModel &data, const std::vector< group_type > &groups) const override |
std::unique_ptr< DataModel > | estimate_join (const QueryGraph &G, const DataModel &left, const DataModel &right, const cnf::CNF &condition) const override |
template<typename PlanTable > | |
std::unique_ptr< DataModel > | operator() (estimate_join_all_tag, PlanTable &&PT, const QueryGraph &G, Subproblem to_join, const cnf::CNF &condition) const |
std::size_t | predict_cardinality (const DataModel &data) const override |
Private Member Functions | |
void | read_json (Diagnostic &diag, std::istream &in, const ThreadSafePooledString &name_of_database) |
void | print (std::ostream &out) const override |
void | buf_append (const char *s) const |
void | buf_append (const std::string &s) const |
const char * | buf_view () const |
ThreadSafePooledString | make_identifier (const QueryGraph &G, const Subproblem S) const |
Private Attributes | |
std::vector< char > | buf_ |
| |
std::ostringstream | oss_ |
| |
std::unordered_map< ThreadSafePooledString, std::size_t > | cardinality_table_ |
CartesianProductEstimator | fallback_ |
InjectionCardinalityEstimator that estimates cardinalities based on a table that contains sizes for the given subproblems Table is initialized in the constructor by using an external json-file If no entry is found, uses the DummyEstimator to return an estimate.
Definition at line 227 of file CardinalityEstimator.hpp.
Definition at line 229 of file CardinalityEstimator.hpp.
M_LCOV_EXCL_STOP InjectionCardinalityEstimator::InjectionCardinalityEstimator | ( | ThreadSafePooledString | name_of_database | ) |
Create an InjectionCardinalityEstimator
for the database name_of_database
from file that was passed by the user via commandline, saved in Options::Get().injected_cardinalities_file
name_of_database | the name of the database to create the InjectionCardinalityEstimator for |
Definition at line 161 of file CardinalityEstimator.cpp.
References m::Options::Get(), read_json(), and m::Diagnostic::w().
InjectionCardinalityEstimator::InjectionCardinalityEstimator | ( | Diagnostic & | diag, |
ThreadSafePooledString | name_of_database, | ||
std::istream & | in | ||
) |
Create an InjectionCardinalityEstimator
for the database name_of_database
from the inputstream in
name_of_database | the name of the database to create the InjectionCardinalityEstimator for |
in | inputstream containing the injected cardinalities in JSON format |
Definition at line 180 of file CardinalityEstimator.cpp.
References read_json().
|
default |
|
delete |
|
default |
|
inlineprivate |
Definition at line 311 of file CardinalityEstimator.hpp.
Referenced by make_identifier(), and read_json().
|
inlineprivate |
Definition at line 312 of file CardinalityEstimator.hpp.
|
inlineprivate |
Definition at line 316 of file CardinalityEstimator.hpp.
Referenced by make_identifier(), and read_json().
|
override |
Definition at line 247 of file CardinalityEstimator.cpp.
|
override |
Definition at line 268 of file CardinalityEstimator.cpp.
|
override |
Definition at line 285 of file CardinalityEstimator.cpp.
References cardinality_table_, m::Catalog::Get(), oss_, and m::Catalog::pool().
|
override |
Definition at line 316 of file CardinalityEstimator.cpp.
References cardinality_table_, m::CartesianProductEstimator::estimate_join(), fallback_, m::Options::Get(), make_identifier(), max_cardinality, and m::CartesianProductEstimator::predict_cardinality().
|
override |
Definition at line 276 of file CardinalityEstimator.cpp.
|
override |
Definition at line 252 of file CardinalityEstimator.cpp.
References m::SmallBitset::begin(), cardinality_table_, m::CartesianProductEstimator::estimate_scan(), fallback_, M_insist, m::CartesianProductEstimator::predict_cardinality(), m::SmallBitset::size(), and m::QueryGraph::sources().
|
private |
Definition at line 407 of file CardinalityEstimator.cpp.
References buf_, buf_append(), buf_view(), m::Catalog::Get(), and m::QueryGraph::sources().
Referenced by estimate_join(), and operator()().
template std::unique_ptr< DataModel > InjectionCardinalityEstimator::operator() | ( | estimate_join_all_tag | , |
PlanTable && | PT, | ||
const QueryGraph & | G, | ||
Subproblem | to_join, | ||
const cnf::CNF & | condition | ||
) | const |
Definition at line 348 of file CardinalityEstimator.cpp.
References m::SmallBitset::begin(), cardinality_table_, m::SmallBitset::end(), m::Options::Get(), make_identifier(), and max_cardinality.
|
default |
|
override |
Definition at line 381 of file CardinalityEstimator.cpp.
|
overrideprivate |
Number of rows of the cardinality_table printed
Length of Subproblem column
Definition at line 387 of file CardinalityEstimator.cpp.
References cardinality_table_.
|
private |
Definition at line 187 of file CardinalityEstimator.cpp.
References buf_, buf_append(), buf_view(), cardinality_table_, m::Catalog::Get(), M_insist, m::Catalog::pool(), and m::Diagnostic::w().
Referenced by InjectionCardinalityEstimator().
|
mutableprivate |
buffer used to construct identifiers
Definition at line 251 of file CardinalityEstimator.hpp.
Referenced by make_identifier(), and read_json().
|
private |
Definition at line 255 of file CardinalityEstimator.hpp.
Referenced by estimate_grouping(), estimate_join(), estimate_scan(), operator()(), print(), and read_json().
|
private |
Definition at line 256 of file CardinalityEstimator.hpp.
Referenced by estimate_join(), and estimate_scan().
|
mutableprivate |
buffer used to construct identifiers
Definition at line 253 of file CardinalityEstimator.hpp.
Referenced by estimate_grouping().