![]() |
mutable
A Database System for Research and Fast Prototyping
|
A wrapper class for an Spn to be used in the context of databases. More...
#include <SpnWrapper.hpp>
Public Types | |
using | Filter = std::unordered_map< unsigned, std::pair< Spn::SpnOperator, float > > |
using | AttrFilter = std::unordered_map< ThreadSafePooledString, std::pair< Spn::SpnOperator, float > > |
Public Member Functions | |
SpnWrapper (const SpnWrapper &)=delete | |
SpnWrapper (SpnWrapper &&)=default | |
const std::unordered_map< ThreadSafePooledString, unsigned > & | get_attribute_to_id () const |
Get the reference to the attribute to spn internal id mapping. | |
std::size_t | num_rows () const |
returns the number of rows in the SPN. | |
float | likelihood (const AttrFilter &attr_filter) const |
Compute the likelihood of the given filter predicates given by a map from attribute to the respective operator and value. | |
float | likelihood (const Filter &filter) const |
Compute the likelihood of the given filter predicates given by a map from spn internal id to the respective operator and value. | |
float | upper_bound (const AttrFilter &attr_filter) const |
Compute the upper bound probability for continuous domains. | |
float | upper_bound (const Filter &filter) const |
Compute the upper bound probability for continuous domains. | |
float | lower_bound (const AttrFilter &attr_filter) const |
Compute the lower bound probability for continuous domains. | |
float | lower_bound (const Filter &filter) const |
Compute the lower bound probability for continuous domains. | |
float | expectation (const ThreadSafePooledString &attribute, const AttrFilter &attr_filter) const |
Compute the expectation of the given attribute. | |
float | expectation (unsigned attribute_id, const Filter &filter) const |
Compute the expectation of the given attribute. | |
void | update_row (Eigen::VectorXf &old_row, Eigen::VectorXf &updated_row) |
Update the SPN with the given row. | |
void | insert_row (Eigen::VectorXf &row) |
Insert the given row into the SPN. | |
void | delete_row (Eigen::VectorXf &row) |
Delete the given row from the SPN. | |
std::size_t | estimate_number_distinct_values (const ThreadSafePooledString &attribute) const |
Estimate the number of distinct values of the given attribute. | |
std::size_t | estimate_number_distinct_values (unsigned attribute_id) const |
Estimate the number of distinct values of the given attribute. | |
unsigned | height () const |
unsigned | breadth () const |
unsigned | degree () const |
std::size_t | memory_usage () const |
void | dump () const |
void | dump (std::ostream &out) const |
Static Public Member Functions | |
static SpnWrapper | learn_spn_table (const ThreadSafePooledString &name_of_database, const ThreadSafePooledString &name_of_table, std::vector< Spn::LeafType > leaf_types=decltype(leaf_types)()) |
Learn an SPN over the given table. | |
static std::unordered_map< ThreadSafePooledString, SpnWrapper * > | learn_spn_database (const ThreadSafePooledString &name_of_database, std::unordered_map< ThreadSafePooledString, std::vector< Spn::LeafType > > leaf_types=decltype(leaf_types)()) |
Learn SPNs over the tables in the given database. | |
Private Member Functions | |
SpnWrapper (Spn spn, std::unordered_map< ThreadSafePooledString, unsigned > attribute_to_id) | |
Filter | translate_filter (const AttrFilter &attr_filter) const |
unsigned | translate_attribute (const ThreadSafePooledString &attribute) const |
Private Attributes | |
Spn | spn_ |
std::unordered_map< ThreadSafePooledString, unsigned > | attribute_to_id_ |
a map from attribute to spn internal id | |
A wrapper class for an Spn to be used in the context of databases.
Definition at line 12 of file SpnWrapper.hpp.
using m::SpnWrapper::AttrFilter = std::unordered_map<ThreadSafePooledString, std::pair<Spn::SpnOperator, float> > |
Definition at line 15 of file SpnWrapper.hpp.
using m::SpnWrapper::Filter = std::unordered_map<unsigned, std::pair<Spn::SpnOperator, float> > |
Definition at line 14 of file SpnWrapper.hpp.
|
inlineprivate |
Definition at line 21 of file SpnWrapper.hpp.
|
delete |
|
default |
|
inline |
Definition at line 119 of file SpnWrapper.hpp.
References m::Spn::breadth(), and spn_.
|
inline |
Definition at line 120 of file SpnWrapper.hpp.
References m::Spn::degree(), and spn_.
|
inline |
Delete the given row from the SPN.
Definition at line 107 of file SpnWrapper.hpp.
References m::Spn::delete_row(), and spn_.
|
inline |
Definition at line 122 of file SpnWrapper.hpp.
References m::Spn::dump(), and spn_.
|
inline |
Definition at line 123 of file SpnWrapper.hpp.
References m::Spn::dump(), and spn_.
|
inline |
Estimate the number of distinct values of the given attribute.
Definition at line 110 of file SpnWrapper.hpp.
References m::Spn::estimate_number_distinct_values(), spn_, and translate_attribute().
Referenced by m::SpnEstimator::max_frequency().
|
inline |
Estimate the number of distinct values of the given attribute.
Definition at line 114 of file SpnWrapper.hpp.
References m::Spn::estimate_number_distinct_values(), and spn_.
|
inline |
Compute the expectation of the given attribute.
Definition at line 92 of file SpnWrapper.hpp.
References m::Spn::expectation(), spn_, translate_attribute(), and translate_filter().
|
inline |
Compute the expectation of the given attribute.
Definition at line 96 of file SpnWrapper.hpp.
References m::Spn::expectation(), and spn_.
|
inline |
Get the reference to the attribute to spn internal id mapping.
Definition at line 45 of file SpnWrapper.hpp.
References attribute_to_id_.
Referenced by m::SpnEstimator::max_frequency().
|
inline |
Definition at line 118 of file SpnWrapper.hpp.
References m::Spn::height(), and spn_.
|
inline |
Insert the given row into the SPN.
Definition at line 104 of file SpnWrapper.hpp.
References m::Spn::insert_row(), and spn_.
|
static |
Learn SPNs over the tables in the given database.
name_of_database | the database |
leaf_types | the type of a leaf for a non-primary key attribute in the respective table |
Definition at line 133 of file SpnWrapper.cpp.
References m::Catalog::Get(), and learn_spn_table().
Referenced by m::SpnEstimator::learn_spns().
|
static |
Learn an SPN over the given table.
name_of_database | the database |
name_of_table | the table in the database |
leaf_types | the types of a leaf for a non-primary key attribute |
Definition at line 11 of file SpnWrapper.cpp.
References m::Spn::AUTO, m::Spn::CONTINUOUS, m::Spn::DISCRETE, m::execute_query(), m::Catalog::Get(), lower_bound(), num_rows(), m::statement_from_string(), and m::T().
Referenced by m::SpnEstimator::learn_new_spn(), and learn_spn_database().
|
inline |
Compute the likelihood of the given filter predicates given by a map from attribute to the respective operator and value.
The predicates in the map are seen as conjunctions.
Definition at line 76 of file SpnWrapper.hpp.
References m::Spn::likelihood(), spn_, and translate_filter().
|
inline |
Compute the likelihood of the given filter predicates given by a map from spn internal id to the respective operator and value.
The predicates in the map are seen as conjunctions.
Definition at line 79 of file SpnWrapper.hpp.
References m::Spn::likelihood(), and spn_.
|
inline |
Compute the lower bound probability for continuous domains.
Definition at line 87 of file SpnWrapper.hpp.
References m::Spn::lower_bound(), spn_, and translate_filter().
Referenced by learn_spn_table().
|
inline |
Compute the lower bound probability for continuous domains.
Definition at line 89 of file SpnWrapper.hpp.
References m::Spn::lower_bound(), and spn_.
|
inline |
Definition at line 121 of file SpnWrapper.hpp.
References m::Spn::memory_usage(), and spn_.
|
inline |
returns the number of rows in the SPN.
Definition at line 72 of file SpnWrapper.hpp.
References m::Spn::num_rows(), and spn_.
Referenced by m::SpnEstimator::estimate_scan(), and learn_spn_table().
|
inlineprivate |
Definition at line 32 of file SpnWrapper.hpp.
References attribute_to_id_.
Referenced by estimate_number_distinct_values(), expectation(), and translate_filter().
|
inlineprivate |
Definition at line 26 of file SpnWrapper.hpp.
References translate_attribute().
Referenced by expectation(), likelihood(), lower_bound(), and upper_bound().
|
inline |
Update the SPN with the given row.
Definition at line 101 of file SpnWrapper.hpp.
References spn_, and m::Spn::update_row().
|
inline |
Compute the upper bound probability for continuous domains.
Definition at line 82 of file SpnWrapper.hpp.
References spn_, translate_filter(), and m::Spn::upper_bound().
|
inline |
Compute the upper bound probability for continuous domains.
Definition at line 84 of file SpnWrapper.hpp.
References spn_, and m::Spn::upper_bound().
|
private |
a map from attribute to spn internal id
Definition at line 19 of file SpnWrapper.hpp.
Referenced by get_attribute_to_id(), and translate_attribute().
|
private |
Definition at line 18 of file SpnWrapper.hpp.
Referenced by breadth(), degree(), delete_row(), dump(), estimate_number_distinct_values(), expectation(), height(), insert_row(), likelihood(), lower_bound(), memory_usage(), num_rows(), update_row(), and upper_bound().