OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FromTableReordering.cpp File Reference
#include "FromTableReordering.h"
#include "Execute.h"
#include "ExpressionRewrite.h"
#include "RangeTableIndexVisitor.h"
#include "Visitors/GeospatialFunctionFinder.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

const Analyzer::ColumnVaranonymous_namespace{FromTableReordering.cpp}::get_geo_cv (std::vector< const Analyzer::ColumnVar * > const &geo_args, shared::TableKey const &table_key)
 
static std::unordered_map
< SQLTypes, cost_t > static
bool 
anonymous_namespace{FromTableReordering.cpp}::force_table_reordering_st_contain_func (std::string_view target_func_name)
 
static bool anonymous_namespace{FromTableReordering.cpp}::force_table_reordering_st_intersects_func (std::string_view target_func_name)
 
bool anonymous_namespace{FromTableReordering.cpp}::should_force_table_reordering (shared::TableKey const &inner_arg_key, SQLTypes const inner_type, shared::TableKey const &outer_arg_key, SQLTypes const outer_type, std::string const &geo_func_name, const std::vector< InputTableInfo > &table_infos)
 
std::tuple< cost_t, cost_t,
InnerQualDecision
anonymous_namespace{FromTableReordering.cpp}::get_join_qual_cost (const Analyzer::Expr *qual, const std::vector< InputTableInfo > &table_infos, 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, std::vector< std::map< node_t, InnerQualDecision >> &qual_detection_res)
 
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< std::map< node_t, InnerQualDecision >> &qual_normalization_res)
 
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 {kPOINT, 60}
 

Function Documentation

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 650 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().

653  {
654  std::vector<std::map<node_t, InnerQualDecision>> qual_normalization_res(
655  table_infos.size());
656  const auto join_cost_graph = build_join_cost_graph(
657  left_deep_join_quals, table_infos, executor, qual_normalization_res);
658  // Use the number of tuples in each table to break ties in BFS.
659  const auto compare_node = [&table_infos](const node_t lhs_nest_level,
660  const node_t rhs_nest_level) {
661  return table_infos[lhs_nest_level].info.getNumTuplesUpperBound() <
662  table_infos[rhs_nest_level].info.getNumTuplesUpperBound();
663  };
664  const auto compare_edge = [&compare_node](const TraversalEdge& lhs_edge,
665  const TraversalEdge& rhs_edge) {
666  // Only use the number of tuples as a tie-breaker, if costs are equal.
667  if (lhs_edge.join_cost == rhs_edge.join_cost) {
668  return compare_node(lhs_edge.nest_level, rhs_edge.nest_level);
669  }
670  return lhs_edge.join_cost > rhs_edge.join_cost;
671  };
672  return traverse_join_cost_graph(join_cost_graph,
673  table_infos,
674  compare_node,
675  compare_edge,
676  left_deep_join_quals,
677  qual_normalization_res);
678 }
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: