20 #include <unordered_set>
26 std::lock_guard<std::mutex> cache_lock(
cache_lock_);
39 return result.first->second;
44 std::lock_guard<std::mutex> cache_lock(
cache_lock_);
51 std::lock_guard<std::mutex> cache_lock(
cache_lock_);
56 std::vector<const Analyzer::ColumnVar*>& col_vars,
57 bool col_id_only)
const {
66 using Hasher = std::function<void(Analyzer::ColumnVar const*)>;
67 Hasher hash_col_id = [&col_vars_info_hash](
auto const* cv) {
68 boost::hash_combine(col_vars_info_hash, cv->getColumnKey().column_id);
70 Hasher hash_cv_string = [&col_vars_info_hash](
auto const* cv) {
71 boost::hash_combine(col_vars_info_hash, cv->toString());
74 col_vars.begin(), col_vars.end(), col_id_only ? hash_col_id : hash_cv_string);
75 return col_vars_info_hash;
80 bool extract_only_col_id) {
91 auto get_sorted_col_info = [=](
const Analyzer::Expr* join_cols) ->
size_t {
93 CHECK(!join_col_vars.empty())
94 <<
"Join expression should have at least one join column variable";
100 CHECK(qual_bin_oper);
101 boost::hash_combine(hashed_join_col_info,
102 get_sorted_col_info(qual_bin_oper->get_left_operand()));
103 boost::hash_combine(hashed_join_col_info,
104 get_sorted_col_info(qual_bin_oper->get_right_operand()));
107 CHECK(qual_bin_oper);
108 boost::hash_combine(hashed_join_col_info,
109 get_sorted_col_info(qual_bin_oper->get_left_operand()));
112 CHECK(qual_bin_oper);
113 boost::hash_combine(hashed_join_col_info,
114 get_sorted_col_info(qual_bin_oper->get_right_operand()));
117 boost::hash_combine(hashed_join_col_info, get_sorted_col_info(join_expr));
119 return hashed_join_col_info;
123 std::cout <<
"Edge list:" << std::endl;
125 std::ostringstream os;
126 os <<
"\n\nNodeMap:\n";
128 os <<
"[" << kv.second <<
"] " << kv.first <<
"\n";
130 std::cout << os.str() << std::endl;
134 std::lock_guard<std::mutex> cache_lock(
cache_lock_);
147 std::lock_guard<std::mutex> cache_lock(
cache_lock_);
std::optional< RelNodeId > addNodeIfAbsent(const RelAlgNode *)
void connectNodes(const RelNodeId parent_id, const RelNodeId child_id)
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
void clearQueryPlanCache()
DEVICE void sort(ARGS &&...args)
T visit(const Analyzer::Expr *expr) const
size_t getCurrentNodeMapSizeUnlocked() const
size_t getJoinColumnsInfoHash(const Analyzer::Expr *join_expr, JoinColumnSide target_side, bool extract_only_col_id)
ColumnVarsVisitor col_var_visitor_
QueryPlanDag cached_query_plan_dag_
size_t max_node_map_size_
size_t translateColVarsToInfoHash(std::vector< const Analyzer::ColumnVar * > &col_vars, bool col_id_only) const
size_t getCurrentNodeMapCardinality() const
const shared::ColumnKey & getColumnKey() const
void setNodeMapMaxSize(const size_t map_size)
constexpr size_t elem_size_
size_t getCurrentNodeMapSize() const
virtual size_t toHash() const =0
std::vector< const Analyzer::ColumnVar * > collectColVars(const Analyzer::Expr *target)