mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
m::QueryGraph Struct Reference

The query graph represents all data sources and joins in a graph structure. More...

#include <QueryGraph.hpp>

Collaboration diagram for m::QueryGraph:
[legend]

Public Types

using Subproblem = SmallBitset
 encode QueryGraph::Subproblems as SmallBitsets
 
using projection_type = std::pair< std::reference_wrapper< const ast::Expr >, ThreadSafePooledOptionalString >
 
using order_type = std::pair< std::reference_wrapper< const ast::Expr >, bool >
 true means ascending, false means descending
 
using group_type = std::pair< std::reference_wrapper< const ast::Expr >, ThreadSafePooledOptionalString >
 

Public Member Functions

 QueryGraph ()
 
 ~QueryGraph ()
 
 QueryGraph (const QueryGraph &)=delete
 
 QueryGraph (QueryGraph &&other)
 
QueryGraphoperator= (QueryGraph &&other)
 
std::size_t num_sources () const
 Returns the number of DataSources in this graph.
 
std::size_t num_joins () const
 Returns the number of Joins in this graph.
 
void add_source (std::unique_ptr< DataSource > source)
 
BaseTableadd_source (ThreadSafePooledOptionalString alias, const Table &table)
 
Queryadd_source (ThreadSafePooledOptionalString alias, std::unique_ptr< QueryGraph > query_graph)
 
std::unique_ptr< DataSourceremove_source (std::size_t id)
 
const auto & sources () const
 
const auto & joins () const
 
const auto & group_by () const
 
const auto & aggregates () const
 
const std::vector< projection_type > & projections () const
 
const auto & order_by () const
 
auto limit () const
 
const DataSourceoperator[] (uint64_t id) const
 Returns a data souce given its id.
 
bool grouping () const
 Returns true iff the graph contains a grouping.
 
bool is_correlated () const
 Returns true iff the graph is correlated, i.e.
 
AdjacencyMatrixadjacency_matrix ()
 
const AdjacencyMatrixadjacency_matrix () const
 
void dot (std::ostream &out) const
 Translates the query graph to dot.
 
void sql (std::ostream &out) const
 Translates the query graph to SQL.
 
void transaction (Scheduler::Transaction *t)
 Set the transaction ID.
 
Scheduler::Transactiontransaction () const
 Returns the transaction ID.
 
void add_custom_filter (std::unique_ptr< ast::Expr > filter_expr, DataSource &ds)
 Creates a cnf::CNF from filter_expr and adds it to the current filter of the given DataSource ds by logical conjunction.
 
void dump (std::ostream &out) const
 
void dump () const
 

Static Public Member Functions

static std::unique_ptr< QueryGraphBuild (const ast::Stmt &stmt)
 

Private Member Functions

void compute_adjacency_matrix () const
 
void dot_recursive (std::ostream &out) const
 
void remove_join (Join &join)
 

Private Attributes

std::vector< std::unique_ptr< DataSource > > sources_
 collection of all data sources in this query graph
 
std::vector< std::unique_ptr< Join > > joins_
 collection of all joins in this query graph
 
std::vector< group_typegroup_by_
 the grouping keys
 
std::vector< std::reference_wrapper< const ast::FnApplicationExpr > > aggregates_
 the aggregates to compute
 
std::vector< projection_typeprojections_
 the data to compute
 
std::vector< order_typeorder_by_
 the order
 
struct {
   uint64_t   limit = 0
 
   uint64_t   offset = 0
 
limit_
 limit: limit and offset
 
std::unique_ptr< AdjacencyMatrixadjacency_matrix_
 
Scheduler::Transactiont_ = nullptr
 the transaction this query graph belongs to
 
std::vector< std::unique_ptr< ast::Expr > > custom_filter_exprs_
 

‍Stores the expressions of custom filters that have been added to the DataSources after semantic analysis.


 

Friends

struct GraphBuilder
 
struct Decorrelation
 
struct GetPrimaryKey
 
void swap (QueryGraph &first, QueryGraph &second)
 

Detailed Description

The query graph represents all data sources and joins in a graph structure.

It is used as an intermediate representation of a query.

Definition at line 171 of file QueryGraph.hpp.

Member Typedef Documentation

◆ group_type

using m::QueryGraph::group_type = std::pair<std::reference_wrapper<const ast::Expr>, ThreadSafePooledOptionalString>

Definition at line 180 of file QueryGraph.hpp.

◆ order_type

using m::QueryGraph::order_type = std::pair<std::reference_wrapper<const ast::Expr>, bool>

true means ascending, false means descending

Definition at line 179 of file QueryGraph.hpp.

◆ projection_type

using m::QueryGraph::projection_type = std::pair<std::reference_wrapper<const ast::Expr>, ThreadSafePooledOptionalString>

Definition at line 178 of file QueryGraph.hpp.

◆ Subproblem

encode QueryGraph::Subproblems as SmallBitsets

Definition at line 177 of file QueryGraph.hpp.

Constructor & Destructor Documentation

◆ QueryGraph() [1/3]

QueryGraph::QueryGraph ( )

Definition at line 1894 of file QueryGraph.cpp.

◆ ~QueryGraph()

QueryGraph::~QueryGraph ( )

Definition at line 1896 of file QueryGraph.cpp.

◆ QueryGraph() [2/3]

m::QueryGraph::QueryGraph ( const QueryGraph )
delete

◆ QueryGraph() [3/3]

m::QueryGraph::QueryGraph ( QueryGraph &&  other)
inline

Definition at line 217 of file QueryGraph.hpp.

References m::swap().

Member Function Documentation

◆ add_custom_filter()

void m::QueryGraph::add_custom_filter ( std::unique_ptr< ast::Expr filter_expr,
DataSource ds 
)
inline

Creates a cnf::CNF from filter_expr and adds it to the current filter of the given DataSource ds by logical conjunction.

Definition at line 308 of file QueryGraph.hpp.

References M_insist, and m::DataSource::update_filter().

Referenced by M_LCOV_EXCL_STOP::apply_timestamp_filter().

◆ add_source() [1/3]

void m::QueryGraph::add_source ( std::unique_ptr< DataSource source)
inline

Definition at line 229 of file QueryGraph.hpp.

◆ add_source() [2/3]

BaseTable & m::QueryGraph::add_source ( ThreadSafePooledOptionalString  alias,
const Table table 
)
inline

Definition at line 233 of file QueryGraph.hpp.

◆ add_source() [3/3]

Query & m::QueryGraph::add_source ( ThreadSafePooledOptionalString  alias,
std::unique_ptr< QueryGraph query_graph 
)
inline

Definition at line 238 of file QueryGraph.hpp.

◆ adjacency_matrix() [1/2]

AdjacencyMatrix & m::QueryGraph::adjacency_matrix ( )
inline

◆ adjacency_matrix() [2/2]

const AdjacencyMatrix & m::QueryGraph::adjacency_matrix ( ) const
inline

Definition at line 283 of file QueryGraph.hpp.

◆ aggregates()

const auto & m::QueryGraph::aggregates ( ) const
inline

Definition at line 260 of file QueryGraph.hpp.

Referenced by dump(), and m::Optimizer::optimize_plan().

◆ Build()

std::unique_ptr< QueryGraph > QueryGraph::Build ( const ast::Stmt stmt)
static

◆ compute_adjacency_matrix()

void QueryGraph::compute_adjacency_matrix ( ) const
private

Definition at line 1915 of file QueryGraph.cpp.

References adjacency_matrix_, joins(), and num_sources().

◆ dot()

void QueryGraph::dot ( std::ostream &  out) const

Translates the query graph to dot.

Definition at line 1930 of file QueryGraph.cpp.

References dot_recursive().

◆ dot_recursive()

void QueryGraph::dot_recursive ( std::ostream &  out) const
private

Definition at line 1946 of file QueryGraph.cpp.

References aggregates_, m::and, group_by_, m::html_escape(), id, joins(), limit_, order_by_, projections_, q, sources(), and m::to_string().

Referenced by dot().

◆ dump() [1/2]

void QueryGraph::dump ( ) const

Definition at line 2141 of file QueryGraph.cpp.

References dump().

Referenced by dump().

◆ dump() [2/2]

M_LCOV_EXCL_START void QueryGraph::dump ( std::ostream &  out) const

Definition at line 2050 of file QueryGraph.cpp.

References aggregates(), m::and, group_by(), joins(), order_by(), projections(), q, and sources().

◆ group_by()

const auto & m::QueryGraph::group_by ( ) const
inline

Definition at line 259 of file QueryGraph.hpp.

Referenced by dump(), m::Optimizer::optimize_plan(), and m::QueryGraph2SQL::translate().

◆ grouping()

bool m::QueryGraph::grouping ( ) const
inline

Returns true iff the graph contains a grouping.

Definition at line 273 of file QueryGraph.hpp.

◆ is_correlated()

bool QueryGraph::is_correlated ( ) const

Returns true iff the graph is correlated, i.e.

it contains a correlated source.

Definition at line 1905 of file QueryGraph.cpp.

◆ joins()

const auto & m::QueryGraph::joins ( ) const
inline

◆ limit()

auto m::QueryGraph::limit ( ) const
inline

Definition at line 263 of file QueryGraph.hpp.

◆ num_joins()

std::size_t m::QueryGraph::num_joins ( ) const
inline

Returns the number of Joins in this graph.

Definition at line 227 of file QueryGraph.hpp.

Referenced by generate_uncorrelated_cardinalities(), and m::pe::hs::expansions::BottomUpComplete::operator()().

◆ num_sources()

std::size_t m::QueryGraph::num_sources ( ) const
inline

Returns the number of DataSources in this graph.

Definition at line 224 of file QueryGraph.hpp.

Referenced by m::pe::hs::search_states::SubproblemsArray::Bottom(), compute_adjacency_matrix(), m::pe::hs::search_states::EdgesBottomUp::compute_datasource_to_subproblem_index(), m::pe::hs::search_states::EdgePtrBottomUp::compute_datasource_to_subproblem_index(), m::pe::hs::search_states::EdgesBottomUp::CreateInitial(), m::pe::TDGOO::for_each_join(), m::pe::hs::search_states::EdgesBottomUp::for_each_subproblem(), m::pe::hs::search_states::EdgePtrBottomUp::for_each_subproblem(), generate_correlated_cardinalities(), generate_uncorrelated_cardinalities(), m::pe::hs::goo_path_completion(), m::pe::hs::heuristic_search(), m::pe::hs::search_states::SubproblemsArray::is_bottom(), m::pe::hs::search_states::EdgePtrBottomUp::is_goal(), IKKBZ::linearize(), m::pe::hs::search_states::EdgePtrBottomUp::num_joins_remaining(), m::pe::hs::search_states::SubproblemsArray::num_partitions(), m::pe::hs::search_states::SubproblemTableBottomUp::num_partitions(), m::pe::hs::search_states::EdgesBottomUp::num_subproblems(), m::pe::hs::heuristics::avg_sel< PlanTable, State, BottomUp >::operator()(), m::pe::hs::heuristics::scaled_sum< PlanTable, State, BottomUp >::operator()(), m::pe::hs::heuristics::GOO< PlanTable, State, BottomUp >::operator()(), m::pe::hs::heuristics::GOO< PlanTable, State, TopDown >::operator()(), m::pe::hs::expansions::BottomUpComplete::operator()(), m::pe::hs::expansions::TopDownComplete::operator()(), m::pe::DPccp::operator()(), m::pe::GOO::operator()(), m::pe::TDGOO::operator()(), IKKBZ::operator()(), LinearizedDP::operator()(), TDMinCutAGaT::operator()(), m::Optimizer::optimize(), m::Optimizer::optimize_join_order(), m::pe::hs::expansions::TopDown::reset_marked(), m::pe::hs::search_states::SubproblemsArray::SubproblemsArray(), m::pe::hs::search_states::SubproblemTableBottomUp::SubproblemTableBottomUp(), and m::pe::hs::search_states::SubproblemsArray::Top().

◆ operator=()

QueryGraph & m::QueryGraph::operator= ( QueryGraph &&  other)
inline

Definition at line 219 of file QueryGraph.hpp.

References m::swap().

◆ operator[]()

const DataSource & m::QueryGraph::operator[] ( uint64_t  id) const
inline

Returns a data souce given its id.

Definition at line 266 of file QueryGraph.hpp.

References id, and M_insist.

◆ order_by()

const auto & m::QueryGraph::order_by ( ) const
inline

Definition at line 262 of file QueryGraph.hpp.

Referenced by dump(), m::Optimizer::optimize_plan(), and m::QueryGraph2SQL::translate().

◆ projections()

const std::vector< projection_type > & m::QueryGraph::projections ( ) const
inline

◆ remove_join()

void m::QueryGraph::remove_join ( Join join)
inlineprivate

Definition at line 326 of file QueryGraph.hpp.

◆ remove_source()

std::unique_ptr< DataSource > m::QueryGraph::remove_source ( std::size_t  id)
inline

Definition at line 244 of file QueryGraph.hpp.

References M_insist.

◆ sources()

const auto & m::QueryGraph::sources ( ) const
inline

◆ sql()

void QueryGraph::sql ( std::ostream &  out) const

Translates the query graph to SQL.

Definition at line 2042 of file QueryGraph.cpp.

◆ transaction() [1/2]

Scheduler::Transaction * m::QueryGraph::transaction ( ) const
inline

Returns the transaction ID.

Definition at line 305 of file QueryGraph.hpp.

◆ transaction() [2/2]

void m::QueryGraph::transaction ( Scheduler::Transaction t)
inline

Set the transaction ID.

Definition at line 296 of file QueryGraph.hpp.

References M_insist.

Referenced by M_LCOV_EXCL_STOP::apply_timestamp_filter().

Friends And Related Function Documentation

◆ Decorrelation

friend struct Decorrelation
friend

Definition at line 174 of file QueryGraph.hpp.

◆ GetPrimaryKey

friend struct GetPrimaryKey
friend

Definition at line 175 of file QueryGraph.hpp.

◆ GraphBuilder

friend struct GraphBuilder
friend

Definition at line 173 of file QueryGraph.hpp.

◆ swap

void swap ( QueryGraph first,
QueryGraph second 
)
friend

Definition at line 199 of file QueryGraph.hpp.

Field Documentation

◆ adjacency_matrix_

std::unique_ptr<AdjacencyMatrix> m::QueryGraph::adjacency_matrix_
mutableprivate

Definition at line 192 of file QueryGraph.hpp.

Referenced by compute_adjacency_matrix().

◆ aggregates_

std::vector<std::reference_wrapper<const ast::FnApplicationExpr> > m::QueryGraph::aggregates_
private

the aggregates to compute

Definition at line 187 of file QueryGraph.hpp.

Referenced by dot_recursive().

◆ custom_filter_exprs_

std::vector<std::unique_ptr<ast::Expr> > m::QueryGraph::custom_filter_exprs_
private

‍Stores the expressions of custom filters that have been added to the DataSources after semantic analysis.

Definition at line 196 of file QueryGraph.hpp.

◆ group_by_

std::vector<group_type> m::QueryGraph::group_by_
private

the grouping keys

Definition at line 186 of file QueryGraph.hpp.

Referenced by dot_recursive().

◆ joins_

std::vector<std::unique_ptr<Join> > m::QueryGraph::joins_
private

collection of all joins in this query graph

Definition at line 184 of file QueryGraph.hpp.

◆ limit

uint64_t m::QueryGraph::limit = 0

Definition at line 190 of file QueryGraph.hpp.

Referenced by m::Optimizer::optimize_plan(), and m::QueryGraph2SQL::translate().

◆ 

struct { ... } m::QueryGraph::limit_

limit: limit and offset

Referenced by dot_recursive().

◆ offset

uint64_t m::QueryGraph::offset = 0

Definition at line 190 of file QueryGraph.hpp.

◆ order_by_

std::vector<order_type> m::QueryGraph::order_by_
private

the order

Definition at line 189 of file QueryGraph.hpp.

Referenced by dot_recursive().

◆ projections_

std::vector<projection_type> m::QueryGraph::projections_
private

the data to compute

Definition at line 188 of file QueryGraph.hpp.

Referenced by dot_recursive().

◆ sources_

std::vector<std::unique_ptr<DataSource> > m::QueryGraph::sources_
private

collection of all data sources in this query graph

Definition at line 183 of file QueryGraph.hpp.

◆ t_

Scheduler::Transaction* m::QueryGraph::t_ = nullptr
private

the transaction this query graph belongs to

Definition at line 194 of file QueryGraph.hpp.


The documentation for this struct was generated from the following files: