OmniSciDB  6686921089
 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 "RelAlgDagBuilder.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  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 RelNodeExplained = std::string
 
using RelNodeExplainedHash = size_t
 
using QueryPlan = std::string
 
using JoinColumnsInfo = std::string
 
using QueryPlanHash = size_t
 
using HashTableBuildDag = std::pair< JoinColumnsInfo, QueryPlan >
 
using HashTableBuildDagMap = std::unordered_map< JoinColumnsInfo, 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 constEMPTY_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.

Author
Alex Suhan alex@.nosp@m.mapd.nosp@m..com Copyright (c) 2016 MapD Technologies, Inc. All rights reserved.
Todd Mostak todd@.nosp@m.omni.nosp@m.sci.c.nosp@m.om Copyright (c) 2020 Omnisci, Inc. All rights reserved.

Definition in file RelAlgExecutionUnit.h.

Typedef Documentation

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

Definition at line 45 of file RelAlgExecutionUnit.h.

Definition at line 67 of file RelAlgExecutionUnit.h.

Definition at line 74 of file RelAlgExecutionUnit.h.

using JoinColumnsInfo = std::string

Definition at line 62 of file RelAlgExecutionUnit.h.

Definition at line 116 of file RelAlgExecutionUnit.h.

using QueryPlan = std::string

Definition at line 60 of file RelAlgExecutionUnit.h.

using QueryPlanHash = size_t

Definition at line 64 of file RelAlgExecutionUnit.h.

using RelNodeExplained = std::string

Definition at line 53 of file RelAlgExecutionUnit.h.

using RelNodeExplainedHash = size_t

Definition at line 55 of file RelAlgExecutionUnit.h.

using RelNodeId = size_t

Definition at line 51 of file RelAlgExecutionUnit.h.

using ResultSetPtr = std::shared_ptr<ResultSet>

Definition at line 162 of file RelAlgExecutionUnit.h.

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

Definition at line 82 of file RelAlgExecutionUnit.h.

Enumeration Type Documentation

Enumerator
kInner 
kOuter 
kQual 
kDirect 

Definition at line 84 of file RelAlgExecutionUnit.h.

84  {
85  kInner,
86  kOuter,
87  kQual, // INNER + OUTER
88  kDirect // set target directly (i.e., put Analyzer::Expr* instead of
89  // Analyzer::BinOper*)
90 };
enum SortAlgorithm
strong
Enumerator
Default 
SpeculativeTopN 
StreamingTopN 

Definition at line 94 of file RelAlgExecutionUnit.h.

Function Documentation

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

Definition at line 1295 of file Execute.cpp.

References EMPTY_QUERY_PLAN, RelAlgExecutionUnit::estimator, anonymous_namespace{Execute.cpp}::expr_container_to_string(), RelAlgExecutionUnit::groupby_exprs, i, RelAlgExecutionUnit::input_col_descs, join(), RelAlgExecutionUnit::join_quals, RelAlgExecutionUnit::quals, RelAlgExecutionUnit::query_plan_dag, 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.

1295  {
1296  auto query_plan_dag =
1297  ra_exe_unit.query_plan_dag == EMPTY_QUERY_PLAN ? "N/A" : ra_exe_unit.query_plan_dag;
1298  os << "\n\tExtracted Query Plan Dag: " << query_plan_dag;
1299  os << "\n\tTable/Col/Levels: ";
1300  for (const auto& input_col_desc : ra_exe_unit.input_col_descs) {
1301  const auto& scan_desc = input_col_desc->getScanDesc();
1302  os << "(" << scan_desc.getTableId() << ", " << input_col_desc->getColId() << ", "
1303  << scan_desc.getNestLevel() << ") ";
1304  }
1305  if (!ra_exe_unit.simple_quals.empty()) {
1306  os << "\n\tSimple Quals: "
1308  ", ");
1309  }
1310  if (!ra_exe_unit.quals.empty()) {
1311  os << "\n\tQuals: "
1312  << boost::algorithm::join(expr_container_to_string(ra_exe_unit.quals), ", ");
1313  }
1314  if (!ra_exe_unit.join_quals.empty()) {
1315  os << "\n\tJoin Quals: ";
1316  for (size_t i = 0; i < ra_exe_unit.join_quals.size(); i++) {
1317  const auto& join_condition = ra_exe_unit.join_quals[i];
1318  os << "\t\t" << std::to_string(i) << " " << ::toString(join_condition.type);
1319  os << boost::algorithm::join(expr_container_to_string(join_condition.quals), ", ");
1320  }
1321  }
1322  if (!ra_exe_unit.groupby_exprs.empty()) {
1323  os << "\n\tGroup By: "
1325  ", ");
1326  }
1327  os << "\n\tProjected targets: "
1329  os << "\n\tHas Estimator: " << ::toString(ra_exe_unit.estimator == nullptr);
1330  os << "\n\tSort Info: ";
1331  const auto& sort_info = ra_exe_unit.sort_info;
1332  os << "\n\t Order Entries: "
1333  << boost::algorithm::join(expr_container_to_string(sort_info.order_entries), ", ");
1334  os << "\n\t Algorithm: " << sort_algorithm_to_string(sort_info.algorithm);
1335  os << "\n\t Limit: " << std::to_string(sort_info.limit);
1336  os << "\n\t Offset: " << std::to_string(sort_info.offset);
1337  os << "\n\tScan Limit: " << std::to_string(ra_exe_unit.scan_limit);
1338  os << "\n\tBump Allocator: " << ::toString(ra_exe_unit.use_bump_allocator);
1339  if (ra_exe_unit.union_all) {
1340  os << "\n\tUnion: " << std::string(*ra_exe_unit.union_all ? "UNION ALL" : "UNION");
1341  }
1342  return os;
1343 }
std::vector< Analyzer::Expr * > target_exprs
std::string toString(const ExtArgumentType &sig_type)
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:1207
const std::shared_ptr< Analyzer::Estimator > estimator
std::string sort_algorithm_to_string(const SortAlgorithm algorithm)
Definition: Execute.cpp:1229
std::list< std::shared_ptr< Analyzer::Expr > > quals
constexpr char const * EMPTY_QUERY_PLAN
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 1244 of file Execute.cpp.

References RelAlgExecutionUnit::estimator, RelAlgExecutionUnit::groupby_exprs, i, 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().

1244  {
1245  // todo(yoonmin): replace a cache key as a DAG representation of a query plan
1246  // instead of ra_exec_unit description if possible
1247  std::ostringstream os;
1248  for (const auto& input_col_desc : ra_exe_unit.input_col_descs) {
1249  const auto& scan_desc = input_col_desc->getScanDesc();
1250  os << scan_desc.getTableId() << "," << input_col_desc->getColId() << ","
1251  << scan_desc.getNestLevel();
1252  }
1253  if (!ra_exe_unit.simple_quals.empty()) {
1254  for (const auto& qual : ra_exe_unit.simple_quals) {
1255  if (qual) {
1256  os << qual->toString() << ",";
1257  }
1258  }
1259  }
1260  if (!ra_exe_unit.quals.empty()) {
1261  for (const auto& qual : ra_exe_unit.quals) {
1262  if (qual) {
1263  os << qual->toString() << ",";
1264  }
1265  }
1266  }
1267  if (!ra_exe_unit.join_quals.empty()) {
1268  for (size_t i = 0; i < ra_exe_unit.join_quals.size(); i++) {
1269  const auto& join_condition = ra_exe_unit.join_quals[i];
1270  os << std::to_string(i) << ::toString(join_condition.type);
1271  for (const auto& qual : join_condition.quals) {
1272  if (qual) {
1273  os << qual->toString() << ",";
1274  }
1275  }
1276  }
1277  }
1278  if (!ra_exe_unit.groupby_exprs.empty()) {
1279  for (const auto& qual : ra_exe_unit.groupby_exprs) {
1280  if (qual) {
1281  os << qual->toString() << ",";
1282  }
1283  }
1284  }
1285  for (const auto& expr : ra_exe_unit.target_exprs) {
1286  if (expr) {
1287  os << expr->toString() << ",";
1288  }
1289  }
1290  os << ::toString(ra_exe_unit.estimator == nullptr);
1291  os << std::to_string(ra_exe_unit.scan_limit);
1292  return os.str();
1293 }
std::vector< Analyzer::Expr * > target_exprs
std::string toString(const ExtArgumentType &sig_type)
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
std::string to_string(char const *&&v)
const JoinQualsPerNestingLevel join_quals
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