OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelAlgDag.cpp File Reference
#include "RelAlgDag.h"
#include "CalciteDeserializerUtils.h"
#include "Catalog/Catalog.h"
#include "Descriptors/RelAlgExecutionDescriptor.h"
#include "JsonAccessors.h"
#include "RelAlgOptimizer.h"
#include "RelLeftDeepInnerJoin.h"
#include "RexVisitor.h"
#include "Shared/sqldefs.h"
#include <rapidjson/error/en.h>
#include <rapidjson/error/error.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#include <string>
#include <unordered_set>
+ Include dependency graph for RelAlgDag.cpp:

Go to the source code of this file.

Classes

class  anonymous_namespace{RelAlgDag.cpp}::RexRebindInputsVisitor
 
class  anonymous_namespace{RelAlgDag.cpp}::RexRebindReindexInputsVisitor
 
class  anonymous_namespace{RelAlgDag.cpp}::PushDownGenericExpressionInWindowFunction
 
struct  std::hash< std::pair< const RelAlgNode *, int > >
 
class  anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::RexInputReplacementVisitor
 
class  anonymous_namespace{RelAlgDag.cpp}::RANodeIterator
 
class  anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::CoalesceSecondaryProjectVisitor
 
class  anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector
 
class  anonymous_namespace{RelAlgDag.cpp}::RexWindowFuncReplacementVisitor
 
class  anonymous_namespace{RelAlgDag.cpp}::RexInputCollector
 
class  details::RelAlgDispatcher
 

Namespaces

 anonymous_namespace{RelAlgDag.cpp}
 
 std
 
 anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}
 
 details
 

Typedefs

using anonymous_namespace{RelAlgDag.cpp}::RexInputSet = std::unordered_set< RexInput >
 

Functions

std::vector< RexInputanonymous_namespace{RelAlgDag.cpp}::n_outputs (const RelAlgNode *node, const size_t n)
 
RANodeOutput get_node_output (const RelAlgNode *ra_node)
 
bool anonymous_namespace{RelAlgDag.cpp}::isRenamedInput (const RelAlgNode *node, const size_t index, const std::string &new_name)
 
std::vector< std::unique_ptr
< const RexAgg > > 
anonymous_namespace{RelAlgDag.cpp}::copyAggExprs (std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs)
 
std::vector< std::unique_ptr
< const RexScalar > > 
anonymous_namespace{RelAlgDag.cpp}::copyRexScalars (std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources)
 
std::vector< const Rex * > anonymous_namespace{RelAlgDag.cpp}::remapTargetPointers (std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_new, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_new, std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_old, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_old, std::vector< const Rex * > const &target_exprs_old)
 
std::set< std::pair< const
RelAlgNode *, int > > 
anonymous_namespace{RelAlgDag.cpp}::get_equiv_cols (const RelAlgNode *node, const size_t which_col)
 
unsigned anonymous_namespace{RelAlgDag.cpp}::node_id (const rapidjson::Value &ra_node) noexcept
 
std::string anonymous_namespace{RelAlgDag.cpp}::json_node_to_string (const rapidjson::Value &node) noexcept
 
std::unique_ptr< RexAbstractInputanonymous_namespace{RelAlgDag.cpp}::parse_abstract_input (const rapidjson::Value &expr) noexcept
 
std::unique_ptr< RexLiteralanonymous_namespace{RelAlgDag.cpp}::parse_literal (const rapidjson::Value &expr)
 
std::unique_ptr< const RexScalaranonymous_namespace{RelAlgDag.cpp}::parse_scalar_expr (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
SQLTypeInfo anonymous_namespace{RelAlgDag.cpp}::parse_type (const rapidjson::Value &type_obj)
 
std::vector< std::unique_ptr
< const RexScalar > > 
anonymous_namespace{RelAlgDag.cpp}::parse_expr_array (const rapidjson::Value &arr, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
SqlWindowFunctionKind anonymous_namespace{RelAlgDag.cpp}::parse_window_function_kind (const std::string &name)
 
std::vector< std::unique_ptr
< const RexScalar > > 
anonymous_namespace{RelAlgDag.cpp}::parse_window_order_exprs (const rapidjson::Value &arr, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
SortDirection anonymous_namespace{RelAlgDag.cpp}::parse_sort_direction (const rapidjson::Value &collation)
 
NullSortedPosition anonymous_namespace{RelAlgDag.cpp}::parse_nulls_position (const rapidjson::Value &collation)
 
std::vector< SortFieldanonymous_namespace{RelAlgDag.cpp}::parse_window_order_collation (const rapidjson::Value &arr, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
RexWindowFunctionOperator::RexWindowBound anonymous_namespace{RelAlgDag.cpp}::parse_window_bound (const rapidjson::Value &window_bound_obj, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
std::unique_ptr< const
RexSubQuery
anonymous_namespace{RelAlgDag.cpp}::parse_subquery (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
std::unique_ptr< RexOperatoranonymous_namespace{RelAlgDag.cpp}::parse_operator (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
std::unique_ptr< RexCaseanonymous_namespace{RelAlgDag.cpp}::parse_case (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDag &root_dag)
 
std::vector< std::string > anonymous_namespace{RelAlgDag.cpp}::strings_from_json_array (const rapidjson::Value &json_str_arr) noexcept
 
std::vector< size_t > anonymous_namespace{RelAlgDag.cpp}::indices_from_json_array (const rapidjson::Value &json_idx_arr) noexcept
 
std::unique_ptr< const RexAgganonymous_namespace{RelAlgDag.cpp}::parse_aggregate_expr (const rapidjson::Value &expr)
 
JoinType anonymous_namespace{RelAlgDag.cpp}::to_join_type (const std::string &join_type_name)
 
std::unique_ptr< const RexScalaranonymous_namespace{RelAlgDag.cpp}::disambiguate_rex (const RexScalar *, const RANodeOutput &)
 
std::unique_ptr< const
RexOperator
anonymous_namespace{RelAlgDag.cpp}::disambiguate_operator (const RexOperator *rex_operator, const RANodeOutput &ra_output) noexcept
 
std::unique_ptr< const RexCaseanonymous_namespace{RelAlgDag.cpp}::disambiguate_case (const RexCase *rex_case, const RANodeOutput &ra_output)
 
void anonymous_namespace{RelAlgDag.cpp}::bind_project_to_input (RelProject *project_node, const RANodeOutput &input) noexcept
 
void anonymous_namespace{RelAlgDag.cpp}::bind_table_func_to_input (RelTableFunction *table_func_node, const RANodeOutput &input) noexcept
 
void anonymous_namespace{RelAlgDag.cpp}::bind_inputs (const std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
 
void anonymous_namespace{RelAlgDag.cpp}::handle_query_hint (const std::vector< std::shared_ptr< RelAlgNode >> &nodes, RelAlgDag &rel_alg_dag) noexcept
 
void anonymous_namespace{RelAlgDag.cpp}::compute_node_hash (const std::vector< std::shared_ptr< RelAlgNode >> &nodes)
 
void anonymous_namespace{RelAlgDag.cpp}::mark_nops (const std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
 
std::vector< const Rex * > anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::reproject_targets (const RelProject *simple_project, const std::vector< const Rex * > &target_exprs) noexcept
 
void anonymous_namespace{RelAlgDag.cpp}::create_compound (std::vector< std::shared_ptr< RelAlgNode >> &nodes, const std::vector< size_t > &pattern, std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint >> &query_hints) noexcept
 
bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::input_can_be_coalesced (const RelAlgNode *parent_node, const size_t index, const bool first_rex_is_input)
 
bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::is_window_function_sum (const RexScalar *rex)
 
bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::is_window_function_avg (const RexScalar *rex)
 
bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::is_window_function_operator (const RexScalar *rex)
 
void anonymous_namespace{RelAlgDag.cpp}::coalesce_nodes (std::vector< std::shared_ptr< RelAlgNode >> &nodes, const std::vector< const RelAlgNode * > &left_deep_joins, std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint >> &query_hints)
 
void anonymous_namespace{RelAlgDag.cpp}::propagate_hints_to_new_project (std::shared_ptr< RelProject > prev_node, std::shared_ptr< RelProject > new_node, std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint >> &query_hints)
 
void anonymous_namespace{RelAlgDag.cpp}::separate_window_function_expressions (std::vector< std::shared_ptr< RelAlgNode >> &nodes, std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint >> &query_hints)
 
void anonymous_namespace{RelAlgDag.cpp}::add_window_function_pre_project (std::vector< std::shared_ptr< RelAlgNode >> &nodes, const bool always_add_project_if_first_project_is_window_expr, std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint >> &query_hints)
 
int64_t anonymous_namespace{RelAlgDag.cpp}::get_int_literal_field (const rapidjson::Value &obj, const char field[], const int64_t default_val) noexcept
 
void anonymous_namespace{RelAlgDag.cpp}::check_empty_inputs_field (const rapidjson::Value &node) noexcept
 
const TableDescriptoranonymous_namespace{RelAlgDag.cpp}::getTableFromScanNode (const Catalog_Namespace::Catalog &cat, const rapidjson::Value &scan_ra)
 
std::vector< std::string > anonymous_namespace{RelAlgDag.cpp}::getFieldNamesFromScanNode (const rapidjson::Value &scan_ra)
 
std::string tree_string (const RelAlgNode *ra, const size_t depth)
 

Variables

bool g_cluster
 
bool g_enable_union
 
const unsigned anonymous_namespace{RelAlgDag.cpp}::FIRST_RA_NODE_ID = 1
 

Function Documentation

RANodeOutput get_node_output ( const RelAlgNode ra_node)

Definition at line 370 of file RelAlgDag.cpp.

References CHECK_EQ, logger::FATAL, get_node_output(), LOG, anonymous_namespace{RelAlgDag.cpp}::n_outputs(), and toString().

Referenced by anonymous_namespace{RelAlgDag.cpp}::bind_inputs(), anonymous_namespace{RelAlgDag.cpp}::create_compound(), anonymous_namespace{RelAlgExecutor.cpp}::get_left_deep_join_input_sizes(), get_node_output(), RelProject::isIdentity(), anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RexPhysicalInputsVisitor::visitInput(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RexPhysicalInputsVisitor::visitOperator().

370  {
371  const auto scan_node = dynamic_cast<const RelScan*>(ra_node);
372  if (scan_node) {
373  // Scan node has no inputs, output contains all columns in the table.
374  CHECK_EQ(size_t(0), scan_node->inputCount());
375  return n_outputs(scan_node, scan_node->size());
376  }
377  const auto project_node = dynamic_cast<const RelProject*>(ra_node);
378  if (project_node) {
379  // Project output count doesn't depend on the input
380  CHECK_EQ(size_t(1), project_node->inputCount());
381  return n_outputs(project_node, project_node->size());
382  }
383  const auto filter_node = dynamic_cast<const RelFilter*>(ra_node);
384  if (filter_node) {
385  // Filter preserves shape
386  CHECK_EQ(size_t(1), filter_node->inputCount());
387  const auto prev_out = get_node_output(filter_node->getInput(0));
388  return n_outputs(filter_node, prev_out.size());
389  }
390  const auto aggregate_node = dynamic_cast<const RelAggregate*>(ra_node);
391  if (aggregate_node) {
392  // Aggregate output count doesn't depend on the input
393  CHECK_EQ(size_t(1), aggregate_node->inputCount());
394  return n_outputs(aggregate_node, aggregate_node->size());
395  }
396  const auto compound_node = dynamic_cast<const RelCompound*>(ra_node);
397  if (compound_node) {
398  // Compound output count doesn't depend on the input
399  CHECK_EQ(size_t(1), compound_node->inputCount());
400  return n_outputs(compound_node, compound_node->size());
401  }
402  const auto join_node = dynamic_cast<const RelJoin*>(ra_node);
403  if (join_node) {
404  // Join concatenates the outputs from the inputs and the output
405  // directly references the nodes in the input.
406  CHECK_EQ(size_t(2), join_node->inputCount());
407  auto lhs_out =
408  n_outputs(join_node->getInput(0), get_node_output(join_node->getInput(0)).size());
409  const auto rhs_out =
410  n_outputs(join_node->getInput(1), get_node_output(join_node->getInput(1)).size());
411  lhs_out.insert(lhs_out.end(), rhs_out.begin(), rhs_out.end());
412  return lhs_out;
413  }
414  const auto table_func_node = dynamic_cast<const RelTableFunction*>(ra_node);
415  if (table_func_node) {
416  // Table Function output count doesn't depend on the input
417  return n_outputs(table_func_node, table_func_node->size());
418  }
419  const auto sort_node = dynamic_cast<const RelSort*>(ra_node);
420  if (sort_node) {
421  // Sort preserves shape
422  CHECK_EQ(size_t(1), sort_node->inputCount());
423  const auto prev_out = get_node_output(sort_node->getInput(0));
424  return n_outputs(sort_node, prev_out.size());
425  }
426  const auto logical_values_node = dynamic_cast<const RelLogicalValues*>(ra_node);
427  if (logical_values_node) {
428  CHECK_EQ(size_t(0), logical_values_node->inputCount());
429  return n_outputs(logical_values_node, logical_values_node->size());
430  }
431  const auto logical_union_node = dynamic_cast<const RelLogicalUnion*>(ra_node);
432  if (logical_union_node) {
433  return n_outputs(logical_union_node, logical_union_node->size());
434  }
435  LOG(FATAL) << "Unhandled ra_node type: " << ::toString(ra_node);
436  return {};
437 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
#define LOG(tag)
Definition: Logger.h:216
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64
std::vector< RexInput > n_outputs(const RelAlgNode *node, const size_t n)
Definition: RelAlgDag.cpp:95
RANodeOutput get_node_output(const RelAlgNode *ra_node)
Definition: RelAlgDag.cpp:370

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string tree_string ( const RelAlgNode ra,
const size_t  depth 
)

Definition at line 3226 of file RelAlgDag.cpp.

References RelAlgNode::getInput(), RelAlgNode::inputCount(), run_benchmark_import::result, toString(), and tree_string().

Referenced by tree_string().

3226  {
3227  std::string result = std::string(2 * depth, ' ') + ::toString(ra) + '\n';
3228  for (size_t i = 0; i < ra->inputCount(); ++i) {
3229  result += tree_string(ra->getInput(i), depth + 1);
3230  }
3231  return result;
3232 }
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64
const RelAlgNode * getInput(const size_t idx) const
Definition: RelAlgDag.h:826
std::string tree_string(const RelAlgNode *ra, const size_t depth)
Definition: RelAlgDag.cpp:3226
const size_t inputCount() const
Definition: RelAlgDag.h:824

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

bool g_cluster
bool g_enable_union

Definition at line 55 of file RelAlgExecutor.cpp.