OmniSciDB  8a228a1076
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 "../Shared/sqldefs.h"
#include "Descriptors/InputDescriptors.h"
#include "ThriftHandler/QueryState.h"
#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 JoinQualsPerNestingLevel = std::vector< JoinCondition >
 
using ResultSetPtr = std::shared_ptr< ResultSet >
 

Enumerations

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)
 

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.

Definition in file RelAlgExecutionUnit.h.

Typedef Documentation

◆ JoinQualsPerNestingLevel

Definition at line 60 of file RelAlgExecutionUnit.h.

◆ ResultSetPtr

using ResultSetPtr = std::shared_ptr<ResultSet>

Definition at line 93 of file RelAlgExecutionUnit.h.

Enumeration Type Documentation

◆ SortAlgorithm

enum SortAlgorithm
strong
Enumerator
Default 
SpeculativeTopN 
StreamingTopN 

Definition at line 38 of file RelAlgExecutionUnit.h.

Function Documentation

◆ operator<<()

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

Definition at line 1241 of file Execute.cpp.

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

1241  {
1242  os << "\n\tTable/Col/Levels: ";
1243  for (const auto& input_col_desc : ra_exe_unit.input_col_descs) {
1244  const auto& scan_desc = input_col_desc->getScanDesc();
1245  os << "(" << scan_desc.getTableId() << ", " << input_col_desc->getColId() << ", "
1246  << scan_desc.getNestLevel() << ") ";
1247  }
1248  if (!ra_exe_unit.simple_quals.empty()) {
1249  os << "\n\tSimple Quals: "
1251  ", ");
1252  }
1253  if (!ra_exe_unit.quals.empty()) {
1254  os << "\n\tQuals: "
1255  << boost::algorithm::join(expr_container_to_string(ra_exe_unit.quals), ", ");
1256  }
1257  if (!ra_exe_unit.join_quals.empty()) {
1258  os << "\n\tJoin Quals: ";
1259  for (size_t i = 0; i < ra_exe_unit.join_quals.size(); i++) {
1260  const auto& join_condition = ra_exe_unit.join_quals[i];
1261  os << "\t\t" << std::to_string(i) << " "
1262  << join_type_to_string(join_condition.type);
1263  os << boost::algorithm::join(expr_container_to_string(join_condition.quals), ", ");
1264  }
1265  }
1266  if (!ra_exe_unit.groupby_exprs.empty()) {
1267  os << "\n\tGroup By: "
1269  ", ");
1270  }
1271  os << "\n\tProjected targets: "
1273  os << "\n\tHas Estimator: " << bool_to_string(ra_exe_unit.estimator == nullptr);
1274  os << "\n\tSort Info: ";
1275  const auto& sort_info = ra_exe_unit.sort_info;
1276  os << "\n\t Order Entries: "
1277  << boost::algorithm::join(expr_container_to_string(sort_info.order_entries), ", ");
1278  os << "\n\t Algorithm: " << sort_algorithm_to_string(sort_info.algorithm);
1279  os << "\n\t Limit: " << std::to_string(sort_info.limit);
1280  os << "\n\t Offset: " << std::to_string(sort_info.offset);
1281  os << "\n\tScan Limit: " << std::to_string(ra_exe_unit.scan_limit);
1282  os << "\n\tBump Allocator: " << bool_to_string(ra_exe_unit.use_bump_allocator);
1283  if (ra_exe_unit.union_all) {
1284  os << "\n\tUnion: " << std::string(*ra_exe_unit.union_all ? "UNION ALL" : "UNION");
1285  }
1286  return os;
1287 }
std::vector< Analyzer::Expr * > target_exprs
const std::optional< bool > union_all
std::string join(T const &container, std::string const &delim)
std::string join_type_to_string(const JoinType type)
Definition: Execute.cpp:1162
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
std::string to_string(char const *&&v)
const SortInfo sort_info
const JoinQualsPerNestingLevel join_quals
std::string bool_to_string(const bool val)
const std::shared_ptr< Analyzer::Estimator > estimator
std::string sort_algorithm_to_string(const SortAlgorithm algorithm)
Definition: Execute.cpp:1175
std::vector< std::string > expr_container_to_string(const std::list< Analyzer::OrderEntry > &expr_container)
Definition: Execute.cpp:1153
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:

◆ ra_exec_unit_desc_for_caching()

std::string ra_exec_unit_desc_for_caching ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 1190 of file Execute.cpp.

References bool_to_string(), RelAlgExecutionUnit::estimator, RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::input_col_descs, RelAlgExecutionUnit::join_quals, anonymous_namespace{Execute.cpp}::join_type_to_string(), RelAlgExecutionUnit::quals, RelAlgExecutionUnit::scan_limit, RelAlgExecutionUnit::simple_quals, RelAlgExecutionUnit::target_exprs, and to_string().

Referenced by RelAlgExecutor::executeWorkUnit().

1190  {
1191  // todo(yoonmin): replace a cache key as a DAG representation of a query plan
1192  // instead of ra_exec_unit description if possible
1193  std::ostringstream os;
1194  for (const auto& input_col_desc : ra_exe_unit.input_col_descs) {
1195  const auto& scan_desc = input_col_desc->getScanDesc();
1196  os << scan_desc.getTableId() << "," << input_col_desc->getColId() << ","
1197  << scan_desc.getNestLevel();
1198  }
1199  if (!ra_exe_unit.simple_quals.empty()) {
1200  for (const auto& qual : ra_exe_unit.simple_quals) {
1201  if (qual) {
1202  os << qual->toString() << ",";
1203  }
1204  }
1205  }
1206  if (!ra_exe_unit.quals.empty()) {
1207  for (const auto& qual : ra_exe_unit.quals) {
1208  if (qual) {
1209  os << qual->toString() << ",";
1210  }
1211  }
1212  }
1213  if (!ra_exe_unit.join_quals.empty()) {
1214  for (size_t i = 0; i < ra_exe_unit.join_quals.size(); i++) {
1215  const auto& join_condition = ra_exe_unit.join_quals[i];
1216  os << std::to_string(i) << join_type_to_string(join_condition.type);
1217  for (const auto& qual : join_condition.quals) {
1218  if (qual) {
1219  os << qual->toString() << ",";
1220  }
1221  }
1222  }
1223  }
1224  if (!ra_exe_unit.groupby_exprs.empty()) {
1225  for (const auto& qual : ra_exe_unit.groupby_exprs) {
1226  if (qual) {
1227  os << qual->toString() << ",";
1228  }
1229  }
1230  }
1231  for (const auto& expr : ra_exe_unit.target_exprs) {
1232  if (expr) {
1233  os << expr->toString() << ",";
1234  }
1235  }
1236  os << bool_to_string(ra_exe_unit.estimator == nullptr);
1237  os << std::to_string(ra_exe_unit.scan_limit);
1238  return os.str();
1239 }
std::vector< Analyzer::Expr * > target_exprs
std::string join_type_to_string(const JoinType type)
Definition: Execute.cpp:1162
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
std::string to_string(char const *&&v)
const JoinQualsPerNestingLevel join_quals
std::string bool_to_string(const bool val)
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: