OmniSciDB  c07336695a
FromTableReordering.cpp File Reference
#include "FromTableReordering.h"
#include "../Analyzer/Analyzer.h"
#include "Execute.h"
#include "RangeTableIndexVisitor.h"
#include <numeric>
#include <queue>
#include <regex>
+ Include dependency graph for FromTableReordering.cpp:

Go to the source code of this file.

Classes

class  anonymous_namespace{FromTableReordering.cpp}::SchedulingDependencyTracking
 
struct  anonymous_namespace{FromTableReordering.cpp}::TraversalEdge
 

Namespaces

 anonymous_namespace{FromTableReordering.cpp}
 

Typedefs

using anonymous_namespace{FromTableReordering.cpp}::cost_t = unsigned
 
using anonymous_namespace{FromTableReordering.cpp}::node_t = size_t
 

Functions

std::pair< cost_t, cost_t > anonymous_namespace{FromTableReordering.cpp}::get_join_qual_cost (const Analyzer::Expr *qual, const Executor *executor)
 
std::vector< std::map< node_t, cost_t > > anonymous_namespace{FromTableReordering.cpp}::build_join_cost_graph (const JoinQualsPerNestingLevel &left_deep_join_quals, const std::vector< InputTableInfo > &table_infos, const Executor *executor)
 
SchedulingDependencyTracking anonymous_namespace{FromTableReordering.cpp}::build_dependency_tracking (const JoinQualsPerNestingLevel &left_deep_join_quals, const std::vector< std::map< node_t, cost_t >> &join_cost_graph)
 
std::vector< node_t > anonymous_namespace{FromTableReordering.cpp}::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< node_t > get_node_input_permutation (const JoinQualsPerNestingLevel &left_deep_join_quals, const std::vector< InputTableInfo > &table_infos, const Executor *executor)
 

Variables

static std::unordered_map< SQLTypes, cost_t > anonymous_namespace{FromTableReordering.cpp}::GEO_TYPE_COSTS
 

Function Documentation

◆ get_node_input_permutation()

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

Definition at line 240 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(), and TEST().

243  {
244  const auto join_cost_graph =
245  build_join_cost_graph(left_deep_join_quals, table_infos, executor);
246  // Use the number of tuples in each table to break ties in BFS.
247  const auto compare_node = [&table_infos](const node_t lhs_nest_level,
248  const node_t rhs_nest_level) {
249  return table_infos[lhs_nest_level].info.getNumTuplesUpperBound() <
250  table_infos[rhs_nest_level].info.getNumTuplesUpperBound();
251  };
252  const auto compare_edge = [&compare_node](const TraversalEdge& lhs_edge,
253  const TraversalEdge& rhs_edge) {
254  // Only use the number of tuples as a tie-breaker, if costs are equal.
255  if (lhs_edge.join_cost == rhs_edge.join_cost) {
256  return compare_node(lhs_edge.nest_level, rhs_edge.nest_level);
257  }
258  return lhs_edge.join_cost < rhs_edge.join_cost;
259  };
261  join_cost_graph, table_infos, compare_node, compare_edge, left_deep_join_quals);
262 }
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, cost_t > > build_join_cost_graph(const JoinQualsPerNestingLevel &left_deep_join_quals, const std::vector< InputTableInfo > &table_infos, const Executor *executor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function: