OmniSciDB  b28c0d5765
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelAlgExecutionUnit.h File Reference

Execution unit for relational algebra. It's a low-level description of any relational algebra operation in a format understood by our VM. More...

#include "Descriptors/InputDescriptors.h"
#include "QueryHint.h"
#include "RelAlgDag.h"
#include "Shared/sqldefs.h"
#include "Shared/toString.h"
#include "TableFunctions/TableFunctionOutputBufferSizeType.h"
#include "TableFunctions/TableFunctionsFactory.h"
#include "ThriftHandler/QueryState.h"
#include <boost/graph/adjacency_list.hpp>
#include <list>
#include <memory>
#include <optional>
#include <vector>
+ Include dependency graph for RelAlgExecutionUnit.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HashTableBuildDag
 
struct  SortInfo
 
struct  JoinCondition
 
struct  RelAlgExecutionUnit
 
struct  TableFunctionExecutionUnit
 

Namespaces

 Analyzer
 

Typedefs

using AdjacentList = boost::adjacency_list< boost::setS, boost::vecS, boost::directedS >
 
using RelNodeId = size_t
 
using RelNodeExplainedHash = size_t
 
using QueryPlanDAG = std::string
 
using QueryPlanHash = size_t
 
using HashTableBuildDagMap = std::unordered_map< size_t, HashTableBuildDag >
 
using TableIdToNodeMap = std::unordered_map< int, const RelAlgNode * >
 
using JoinQualsPerNestingLevel = std::vector< JoinCondition >
 
using ResultSetPtr = std::shared_ptr< ResultSet >
 

Enumerations

enum  JoinColumnSide { kInner, kOuter, kQual, kDirect }
 
enum  SortAlgorithm { SortAlgorithm::Default, SortAlgorithm::SpeculativeTopN, SortAlgorithm::StreamingTopN }
 

Functions

std::ostream & operator<< (std::ostream &os, const RelAlgExecutionUnit &ra_exe_unit)
 
std::string ra_exec_unit_desc_for_caching (const RelAlgExecutionUnit &ra_exe_unit)
 

Variables

constexpr char const * EMPTY_QUERY_PLAN = ""
 
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY = 0
 

Detailed Description

Execution unit for relational algebra. It's a low-level description of any relational algebra operation in a format understood by our VM.

Definition in file RelAlgExecutionUnit.h.

Typedef Documentation

using AdjacentList = boost::adjacency_list<boost::setS, boost::vecS, boost::directedS>

Definition at line 43 of file RelAlgExecutionUnit.h.

using HashTableBuildDagMap = std::unordered_map<size_t, HashTableBuildDag>

Definition at line 86 of file RelAlgExecutionUnit.h.

Definition at line 129 of file RelAlgExecutionUnit.h.

using QueryPlanDAG = std::string

Definition at line 56 of file RelAlgExecutionUnit.h.

using QueryPlanHash = size_t

Definition at line 58 of file RelAlgExecutionUnit.h.

using RelNodeExplainedHash = size_t

Definition at line 51 of file RelAlgExecutionUnit.h.

using RelNodeId = size_t

Definition at line 49 of file RelAlgExecutionUnit.h.

using ResultSetPtr = std::shared_ptr<ResultSet>

Definition at line 183 of file RelAlgExecutionUnit.h.

using TableIdToNodeMap = std::unordered_map<int, const RelAlgNode*>

Definition at line 94 of file RelAlgExecutionUnit.h.

Enumeration Type Documentation

Enumerator
kInner 
kOuter 
kQual 
kDirect 

Definition at line 96 of file RelAlgExecutionUnit.h.

96  {
97  kInner,
98  kOuter,
99  kQual, // INNER + OUTER
100  kDirect // set target directly (i.e., put Analyzer::Expr* instead of
101  // Analyzer::BinOper*)
102 };
enum SortAlgorithm
strong
Enumerator
Default 
SpeculativeTopN 
StreamingTopN 

Definition at line 106 of file RelAlgExecutionUnit.h.

Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const RelAlgExecutionUnit ra_exe_unit 
)

Definition at line 1685 of file Execute.cpp.

References RelAlgExecutionUnit::estimator, anonymous_namespace{Execute.cpp}::expr_container_to_string(), RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::input_col_descs, join(), RelAlgExecutionUnit::join_quals, RelAlgExecutionUnit::quals, RelAlgExecutionUnit::query_plan_dag_hash, RelAlgExecutionUnit::scan_limit, RelAlgExecutionUnit::simple_quals, anonymous_namespace{Execute.cpp}::sort_algorithm_to_string(), RelAlgExecutionUnit::sort_info, RelAlgExecutionUnit::target_exprs, to_string(), toString(), RelAlgExecutionUnit::union_all, and RelAlgExecutionUnit::use_bump_allocator.

1685  {
1686  os << "\n\tExtracted Query Plan Dag Hash: " << ra_exe_unit.query_plan_dag_hash;
1687  os << "\n\tTable/Col/Levels: ";
1688  for (const auto& input_col_desc : ra_exe_unit.input_col_descs) {
1689  const auto& scan_desc = input_col_desc->getScanDesc();
1690  os << "(" << scan_desc.getTableId() << ", " << input_col_desc->getColId() << ", "
1691  << scan_desc.getNestLevel() << ") ";
1692  }
1693  if (!ra_exe_unit.simple_quals.empty()) {
1694  os << "\n\tSimple Quals: "
1696  ", ");
1697  }
1698  if (!ra_exe_unit.quals.empty()) {
1699  os << "\n\tQuals: "
1700  << boost::algorithm::join(expr_container_to_string(ra_exe_unit.quals), ", ");
1701  }
1702  if (!ra_exe_unit.join_quals.empty()) {
1703  os << "\n\tJoin Quals: ";
1704  for (size_t i = 0; i < ra_exe_unit.join_quals.size(); i++) {
1705  const auto& join_condition = ra_exe_unit.join_quals[i];
1706  os << "\t\t" << std::to_string(i) << " " << ::toString(join_condition.type);
1707  os << boost::algorithm::join(expr_container_to_string(join_condition.quals), ", ");
1708  }
1709  }
1710  if (!ra_exe_unit.groupby_exprs.empty()) {
1711  os << "\n\tGroup By: "
1713  ", ");
1714  }
1715  os << "\n\tProjected targets: "
1717  os << "\n\tHas Estimator: " << ::toString(ra_exe_unit.estimator == nullptr);
1718  os << "\n\tSort Info: ";
1719  const auto& sort_info = ra_exe_unit.sort_info;
1720  os << "\n\t Order Entries: "
1721  << boost::algorithm::join(expr_container_to_string(sort_info.order_entries), ", ");
1722  os << "\n\t Algorithm: " << sort_algorithm_to_string(sort_info.algorithm);
1723  os << "\n\t Limit: " << std::to_string(sort_info.limit);
1724  os << "\n\t Offset: " << std::to_string(sort_info.offset);
1725  os << "\n\tScan Limit: " << std::to_string(ra_exe_unit.scan_limit);
1726  os << "\n\tBump Allocator: " << ::toString(ra_exe_unit.use_bump_allocator);
1727  if (ra_exe_unit.union_all) {
1728  os << "\n\tUnion: " << std::string(*ra_exe_unit.union_all ? "UNION ALL" : "UNION");
1729  }
1730  return os;
1731 }
std::vector< Analyzer::Expr * > target_exprs
QueryPlanHash query_plan_dag_hash
const std::optional< bool > union_all
std::string join(T const &container, std::string const &delim)
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
std::string to_string(char const *&&v)
const JoinQualsPerNestingLevel join_quals
std::vector< std::string > expr_container_to_string(const T &expr_container)
Definition: Execute.cpp:1597
std::string toString(const ExecutorDeviceType &device_type)
const std::shared_ptr< Analyzer::Estimator > estimator
std::string sort_algorithm_to_string(const SortAlgorithm algorithm)
Definition: Execute.cpp:1619
std::list< std::shared_ptr< Analyzer::Expr > > quals
std::list< std::shared_ptr< const InputColDescriptor > > input_col_descs
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals

+ Here is the call graph for this function:

std::string ra_exec_unit_desc_for_caching ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 1634 of file Execute.cpp.

References RelAlgExecutionUnit::estimator, RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::input_col_descs, RelAlgExecutionUnit::join_quals, RelAlgExecutionUnit::quals, RelAlgExecutionUnit::scan_limit, RelAlgExecutionUnit::simple_quals, RelAlgExecutionUnit::target_exprs, to_string(), and toString().

Referenced by RelAlgExecutor::executeWorkUnit().

1634  {
1635  // todo(yoonmin): replace a cache key as a DAG representation of a query plan
1636  // instead of ra_exec_unit description if possible
1637  std::ostringstream os;
1638  for (const auto& input_col_desc : ra_exe_unit.input_col_descs) {
1639  const auto& scan_desc = input_col_desc->getScanDesc();
1640  os << scan_desc.getTableId() << "," << input_col_desc->getColId() << ","
1641  << scan_desc.getNestLevel();
1642  }
1643  if (!ra_exe_unit.simple_quals.empty()) {
1644  for (const auto& qual : ra_exe_unit.simple_quals) {
1645  if (qual) {
1646  os << qual->toString() << ",";
1647  }
1648  }
1649  }
1650  if (!ra_exe_unit.quals.empty()) {
1651  for (const auto& qual : ra_exe_unit.quals) {
1652  if (qual) {
1653  os << qual->toString() << ",";
1654  }
1655  }
1656  }
1657  if (!ra_exe_unit.join_quals.empty()) {
1658  for (size_t i = 0; i < ra_exe_unit.join_quals.size(); i++) {
1659  const auto& join_condition = ra_exe_unit.join_quals[i];
1660  os << std::to_string(i) << ::toString(join_condition.type);
1661  for (const auto& qual : join_condition.quals) {
1662  if (qual) {
1663  os << qual->toString() << ",";
1664  }
1665  }
1666  }
1667  }
1668  if (!ra_exe_unit.groupby_exprs.empty()) {
1669  for (const auto& qual : ra_exe_unit.groupby_exprs) {
1670  if (qual) {
1671  os << qual->toString() << ",";
1672  }
1673  }
1674  }
1675  for (const auto& expr : ra_exe_unit.target_exprs) {
1676  if (expr) {
1677  os << expr->toString() << ",";
1678  }
1679  }
1680  os << ::toString(ra_exe_unit.estimator == nullptr);
1681  os << std::to_string(ra_exe_unit.scan_limit);
1682  return os.str();
1683 }
std::vector< Analyzer::Expr * > target_exprs
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
std::string to_string(char const *&&v)
const JoinQualsPerNestingLevel join_quals
std::string toString(const ExecutorDeviceType &device_type)
const std::shared_ptr< Analyzer::Estimator > estimator
std::list< std::shared_ptr< Analyzer::Expr > > quals
std::list< std::shared_ptr< const InputColDescriptor > > input_col_descs
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

constexpr char const* EMPTY_QUERY_PLAN = ""