OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FromTableReordering.h File Reference
#include "InputMetadata.h"
#include "RelAlgExecutionUnit.h"
+ Include dependency graph for FromTableReordering.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::vector< size_t > get_node_input_permutation (const JoinQualsPerNestingLevel &left_deep_join_quals, const std::vector< InputTableInfo > &table_infos, const Executor *executor)
 

Function Documentation

std::vector<size_t> get_node_input_permutation ( const JoinQualsPerNestingLevel left_deep_join_quals,
const std::vector< InputTableInfo > &  table_infos,
const Executor executor 
)

Definition at line 575 of file FromTableReordering.cpp.

References anonymous_namespace{FromTableReordering.cpp}::build_join_cost_graph(), and anonymous_namespace{FromTableReordering.cpp}::traverse_join_cost_graph().

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering().

578  {
579  std::vector<std::map<node_t, InnerQualDecision>> qual_normalization_res(
580  table_infos.size());
581  const auto join_cost_graph = build_join_cost_graph(
582  left_deep_join_quals, table_infos, executor, qual_normalization_res);
583  // Use the number of tuples in each table to break ties in BFS.
584  const auto compare_node = [&table_infos](const node_t lhs_nest_level,
585  const node_t rhs_nest_level) {
586  return table_infos[lhs_nest_level].info.getNumTuplesUpperBound() <
587  table_infos[rhs_nest_level].info.getNumTuplesUpperBound();
588  };
589  const auto compare_edge = [&compare_node](const TraversalEdge& lhs_edge,
590  const TraversalEdge& rhs_edge) {
591  // Only use the number of tuples as a tie-breaker, if costs are equal.
592  if (lhs_edge.join_cost == rhs_edge.join_cost) {
593  return compare_node(lhs_edge.nest_level, rhs_edge.nest_level);
594  }
595  return lhs_edge.join_cost > rhs_edge.join_cost;
596  };
597  return traverse_join_cost_graph(join_cost_graph,
598  table_infos,
599  compare_node,
600  compare_edge,
601  left_deep_join_quals,
602  qual_normalization_res);
603 }
std::vector< std::map< node_t, cost_t > > build_join_cost_graph(const JoinQualsPerNestingLevel &left_deep_join_quals, const std::vector< InputTableInfo > &table_infos, const Executor *executor, std::vector< std::map< node_t, InnerQualDecision >> &qual_detection_res)
std::vector< node_t > traverse_join_cost_graph(const std::vector< std::map< node_t, cost_t >> &join_cost_graph, const std::vector< InputTableInfo > &table_infos, const std::function< bool(const node_t lhs_nest_level, const node_t rhs_nest_level)> &compare_node, const std::function< bool(const TraversalEdge &, const TraversalEdge &)> &compare_edge, const JoinQualsPerNestingLevel &left_deep_join_quals, std::vector< std::map< node_t, InnerQualDecision >> &qual_normalization_res)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: