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

#include <QueryGraph.hpp>

Inheritance diagram for m::GraphBuilder:
[legend]
Collaboration diagram for m::GraphBuilder:
[legend]

Public Types

using clause_map = std::unordered_map< cnf::Clause, ClauseInfo >
 

‍maps a cnf::Clause to its ClauseInfo


 

Public Member Functions

 GraphBuilder ()
 
std::unique_ptr< QueryGraphget ()
 

‍returns the constructed QueryGraph


 
void operator() (Const< ast::Stmt > &s)
 
void operator() (Const< ast::ErrorStmt > &)
 
void operator() (Const< ast::EmptyStmt > &)
 
void operator() (Const< ast::CreateDatabaseStmt > &)
 
void operator() (Const< ast::DropDatabaseStmt > &)
 
void operator() (Const< ast::UseDatabaseStmt > &)
 
void operator() (Const< ast::CreateTableStmt > &)
 
void operator() (Const< ast::DropTableStmt > &)
 
void operator() (Const< ast::SelectStmt > &s)
 
void operator() (Const< ast::InsertStmt > &)
 
void operator() (Const< ast::UpdateStmt > &)
 
void operator() (Const< ast::DeleteStmt > &)
 
void operator() (Const< ast::DSVImportStmt > &)
 
void process_selection (cnf::Clause &clause)
 Computes correlation information of clause.
 

Private Attributes

std::vector< std::reference_wrapper< const ast::Expr > > existing_grouping_keys_
 

‍the grouping keys of the statement


 
std::unordered_set< std::reference_wrapper< const ast::Expr > > additional_grouping_keys_
 

‍additionally required grouping keys to perform decorrelation


 
clause_map bound_clauses_
 

‍to be handled by the current query


 
clause_map deferred_clauses_
 

‍to be handled by an outer query


 
std::unique_ptr< QueryGraphgraph_
 

‍the query graph that is being constructed


 
std::unordered_map< ThreadSafePooledString, std::reference_wrapper< DataSource > > named_sources_
 

‍maps DataSource names/aliases to the DataSource instance


 
bool needs_grouping_ = false
 

‍whether this graph needs grouping; either by explicily grouping or implicitly by using aggregations


 

Detailed Description

Definition at line 44 of file QueryGraph.hpp.

Member Typedef Documentation

◆ clause_map

using m::GraphBuilder::clause_map = std::unordered_map<cnf::Clause, ClauseInfo>

‍maps a cnf::Clause to its ClauseInfo

Definition at line 47 of file QueryGraph.hpp.

Constructor & Destructor Documentation

◆ GraphBuilder()

GraphBuilder::GraphBuilder ( )

Definition at line 410 of file QueryGraph.cpp.

Member Function Documentation

◆ get()

std::unique_ptr< QueryGraph > m::GraphBuilder::get ( )
inline

‍returns the constructed QueryGraph

Definition at line 72 of file QueryGraph.hpp.

References graph_.

Referenced by m::QueryGraph::Build().

◆ operator()() [1/13]

void m::GraphBuilder::operator() ( Const< ast::CreateDatabaseStmt > &  )
inline

Definition at line 79 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [2/13]

void m::GraphBuilder::operator() ( Const< ast::CreateTableStmt > &  )
inline

Definition at line 82 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [3/13]

void m::GraphBuilder::operator() ( Const< ast::DeleteStmt > &  )
inline

Definition at line 87 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [4/13]

void m::GraphBuilder::operator() ( Const< ast::DropDatabaseStmt > &  )
inline

Definition at line 80 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [5/13]

void m::GraphBuilder::operator() ( Const< ast::DropTableStmt > &  )
inline

Definition at line 83 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [6/13]

void m::GraphBuilder::operator() ( Const< ast::DSVImportStmt > &  )
inline

Definition at line 88 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [7/13]

void m::GraphBuilder::operator() ( Const< ast::EmptyStmt > &  )
inline

Definition at line 78 of file QueryGraph.hpp.

◆ operator()() [8/13]

void m::GraphBuilder::operator() ( Const< ast::ErrorStmt > &  )
inline

Definition at line 77 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [9/13]

void m::GraphBuilder::operator() ( Const< ast::InsertStmt > &  )
inline

Definition at line 85 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [10/13]

void m::GraphBuilder::operator() ( Const< ast::SelectStmt > &  s)

◆ operator()() [11/13]

void m::GraphBuilder::operator() ( Const< ast::Stmt > &  s)
inline

Definition at line 76 of file QueryGraph.hpp.

◆ operator()() [12/13]

void m::GraphBuilder::operator() ( Const< ast::UpdateStmt > &  )
inline

Definition at line 86 of file QueryGraph.hpp.

References M_unreachable.

◆ operator()() [13/13]

void m::GraphBuilder::operator() ( Const< ast::UseDatabaseStmt > &  )
inline

Definition at line 81 of file QueryGraph.hpp.

References M_unreachable.

◆ process_selection()

void GraphBuilder::process_selection ( cnf::Clause clause)

Computes correlation information of clause.

Analyzes the entire clause for how it can be decorrelated.

  1. If the query does not have any grouping, clauses can be trivially decorrelated by lifting the clause into the join condition of the dependent join.

If the query contains grouping, more in depth analysis is performed:

  1. If the clause contains only bound variables, it is an uncorrelated selection of the query.
  2. If the clause contains only free variables, it is an uncorrelated selection of an outer statement.
  3. If it contains both bound and free variables, it is correlated and is analyzed more closely. Correlated clauses can be decorrelated if all bound expressions are composable of the grouping keys specified in the query. If it is not possible to compose all bound expressions from grouping keys, the clause cannot be decorrelated.
  4. A special exception are clauses of a single equi-predicate, where one side of the equi-predicate contains only bound variables and the other contains only free variables. In that particular case, we can decorrelate the clause by introducing the bound expression as an additional grouping key to the query.

Definition at line 440 of file QueryGraph.cpp.

References additional_grouping_keys_, m::and, m::ClauseInfo::binding_depth, bound_clauses_, deferred_clauses_, existing_grouping_keys_, graph_, is_composable_of(), M_insist, named_sources_, needs_grouping_, and m::ClauseInfo::nested_queries.

Field Documentation

◆ additional_grouping_keys_

std::unordered_set<std::reference_wrapper<const ast::Expr> > m::GraphBuilder::additional_grouping_keys_
private

‍additionally required grouping keys to perform decorrelation

Definition at line 54 of file QueryGraph.hpp.

Referenced by process_selection().

◆ bound_clauses_

clause_map m::GraphBuilder::bound_clauses_
private

‍to be handled by the current query

Definition at line 57 of file QueryGraph.hpp.

Referenced by process_selection().

◆ deferred_clauses_

clause_map m::GraphBuilder::deferred_clauses_
private

‍to be handled by an outer query

Definition at line 59 of file QueryGraph.hpp.

Referenced by process_selection().

◆ existing_grouping_keys_

std::vector<std::reference_wrapper<const ast::Expr> > m::GraphBuilder::existing_grouping_keys_
private

‍the grouping keys of the statement

Definition at line 52 of file QueryGraph.hpp.

Referenced by process_selection().

◆ graph_

std::unique_ptr<QueryGraph> m::GraphBuilder::graph_
private

‍the query graph that is being constructed

Definition at line 62 of file QueryGraph.hpp.

Referenced by get(), and process_selection().

◆ named_sources_

std::unordered_map<ThreadSafePooledString, std::reference_wrapper<DataSource> > m::GraphBuilder::named_sources_
private

‍maps DataSource names/aliases to the DataSource instance

Definition at line 64 of file QueryGraph.hpp.

Referenced by process_selection().

◆ needs_grouping_

bool m::GraphBuilder::needs_grouping_ = false
private

‍whether this graph needs grouping; either by explicily grouping or implicitly by using aggregations

Definition at line 66 of file QueryGraph.hpp.

Referenced by process_selection().


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