OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelAlgDag Class Reference

#include <RelAlgDag.h>

+ Inheritance diagram for RelAlgDag:
+ Collaboration diagram for RelAlgDag:

Public Types

enum  BuildState { BuildState::kNotBuilt, BuildState::kBuiltNotOptimized, BuildState::kBuiltOptimized }
 

Public Member Functions

 RelAlgDag ()
 
BuildState getBuildState () const
 
void eachNode (std::function< void(RelAlgNode const *)> const &) const
 
const RelAlgNodegetRootNode () const
 
std::shared_ptr< const RelAlgNodegetRootNodeShPtr () const
 
std::vector< std::shared_ptr
< RelAlgNode > > & 
getNodes ()
 
void registerSubquery (std::shared_ptr< RexSubQuery > subquery)
 
const std::vector
< std::shared_ptr< RexSubQuery > > & 
getSubqueries () const
 
void registerQueryHints (std::shared_ptr< RelAlgNode > node, Hints *hints_delivered, RegisteredQueryHint &global_query_hint)
 
void registerQueryHint (const RelAlgNode *node, const RegisteredQueryHint &query_hint)
 
std::optional
< RegisteredQueryHint
getQueryHint (const RelAlgNode *node) const
 
std::unordered_map< size_t,
std::unordered_map< unsigned,
RegisteredQueryHint > > & 
getQueryHints ()
 
const RegisteredQueryHintgetGlobalHints () const
 
void setGlobalQueryHints (const RegisteredQueryHint &global_hints)
 
void resetQueryExecutionState ()
 

Private Attributes

BuildState build_state_
 
std::vector< std::shared_ptr
< RelAlgNode > > 
nodes_
 
std::vector< std::shared_ptr
< RexSubQuery > > 
subqueries_
 
std::unordered_map< size_t,
std::unordered_map< unsigned,
RegisteredQueryHint > > 
query_hint_
 
RegisteredQueryHint global_hints_
 

Friends

struct RelAlgDagSerializer
 
struct RelAlgDagModifier
 

Detailed Description

Class defining an in-memory, easy-to-navigate internal representation of a relational algebra DAG interpreted from a JSON provided by Calcite. Must be built through the RelAlgDagBuilder interface.

Definition at line 2799 of file RelAlgDag.h.

Member Enumeration Documentation

enum RelAlgDag::BuildState
strong
Enumerator
kNotBuilt 
kBuiltNotOptimized 
kBuiltOptimized 

Definition at line 2801 of file RelAlgDag.h.

2801 { kNotBuilt, kBuiltNotOptimized, kBuiltOptimized };

Constructor & Destructor Documentation

RelAlgDag::RelAlgDag ( )
inline

Definition at line 2803 of file RelAlgDag.h.

References kNotBuilt.

Member Function Documentation

void RelAlgDag::eachNode ( std::function< void(RelAlgNode const *)> const &  callback) const

Definition at line 3463 of file RelAlgDag.cpp.

References nodes_.

3463  {
3464  for (auto const& node : nodes_) {
3465  if (node) {
3466  callback(node.get());
3467  }
3468  }
3469 }
std::vector< std::shared_ptr< RelAlgNode > > nodes_
Definition: RelAlgDag.h:3381
BuildState RelAlgDag::getBuildState ( ) const
inline

Definition at line 2805 of file RelAlgDag.h.

References build_state_.

Referenced by RelAlgDagBuilder::optimizeDag().

2805 { return build_state_; }
BuildState build_state_
Definition: RelAlgDag.h:3379

+ Here is the caller graph for this function:

const RegisteredQueryHint& RelAlgDag::getGlobalHints ( ) const
inline

Definition at line 3367 of file RelAlgDag.h.

References global_hints_.

Referenced by anonymous_namespace{RelAlgDag.cpp}::parse_subquery().

3367 { return global_hints_; }
RegisteredQueryHint global_hints_
Definition: RelAlgDag.h:3389

+ Here is the caller graph for this function:

std::vector<std::shared_ptr<RelAlgNode> >& RelAlgDag::getNodes ( )
inline

Definition at line 2824 of file RelAlgDag.h.

References nodes_.

Referenced by RelAlgExecutor::executeRelAlgQueryNoRetry().

2824 { return nodes_; }
std::vector< std::shared_ptr< RelAlgNode > > nodes_
Definition: RelAlgDag.h:3381

+ Here is the caller graph for this function:

std::optional<RegisteredQueryHint> RelAlgDag::getQueryHint ( const RelAlgNode node) const
inline

Definition at line 3339 of file RelAlgDag.h.

References RelAlgNode::getId(), global_hints_, RegisteredQueryHint::isAnyQueryHintDelivered(), query_hint_, and RelAlgNode::toHash().

3339  {
3340  auto node_it = query_hint_.find(node->toHash());
3341  if (node_it != query_hint_.end()) {
3342  auto const& registered_query_hint_map = node_it->second;
3343  auto hint_it = registered_query_hint_map.find(node->getId());
3344  if (hint_it != registered_query_hint_map.end()) {
3345  auto const& registered_query_hint = hint_it->second;
3347  // apply global hint to the registered query hint for this query block
3348  return std::make_optional(registered_query_hint || global_hints_);
3349  } else {
3350  return std::make_optional(registered_query_hint);
3351  }
3352  }
3353  }
3355  // if no hint is registered from this query block
3356  // we return global hint instead
3357  return std::make_optional(global_hints_);
3358  }
3359  return std::nullopt;
3360  }
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > query_hint_
Definition: RelAlgDag.h:3388
unsigned getId() const
Definition: RelAlgDag.h:869
RegisteredQueryHint global_hints_
Definition: RelAlgDag.h:3389
virtual size_t toHash() const =0
bool isAnyQueryHintDelivered() const
Definition: QueryHint.h:388

+ Here is the call graph for this function:

std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint> >& RelAlgDag::getQueryHints ( )
inline

Definition at line 3363 of file RelAlgDag.h.

References query_hint_.

3363  {
3364  return query_hint_;
3365  }
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > query_hint_
Definition: RelAlgDag.h:3388
const RelAlgNode& RelAlgDag::getRootNode ( ) const
inline

Returns the root node of the DAG.

Definition at line 2812 of file RelAlgDag.h.

References CHECK, and nodes_.

2812  {
2813  CHECK(nodes_.size());
2814  const auto& last_ptr = nodes_.back();
2815  CHECK(last_ptr);
2816  return *last_ptr;
2817  }
std::vector< std::shared_ptr< RelAlgNode > > nodes_
Definition: RelAlgDag.h:3381
#define CHECK(condition)
Definition: Logger.h:291
std::shared_ptr<const RelAlgNode> RelAlgDag::getRootNodeShPtr ( ) const
inline

Definition at line 2819 of file RelAlgDag.h.

References CHECK, and nodes_.

2819  {
2820  CHECK(nodes_.size());
2821  return nodes_.back();
2822  }
std::vector< std::shared_ptr< RelAlgNode > > nodes_
Definition: RelAlgDag.h:3381
#define CHECK(condition)
Definition: Logger.h:291
const std::vector<std::shared_ptr<RexSubQuery> >& RelAlgDag::getSubqueries ( ) const
inline

Gets all registered subqueries. Only the root DAG can contain subqueries.

Definition at line 2837 of file RelAlgDag.h.

References subqueries_.

2837  {
2838  return subqueries_;
2839  }
std::vector< std::shared_ptr< RexSubQuery > > subqueries_
Definition: RelAlgDag.h:3382
void RelAlgDag::registerQueryHint ( const RelAlgNode node,
const RegisteredQueryHint query_hint 
)
inline

Definition at line 3327 of file RelAlgDag.h.

References RelAlgNode::getId(), query_hint_, and RelAlgNode::toHash().

Referenced by anonymous_namespace{RelAlgDag.cpp}::parse_subquery(), and registerQueryHints().

3327  {
3328  auto node_key = node->toHash();
3329  auto it = query_hint_.find(node_key);
3330  if (it == query_hint_.end()) {
3331  std::unordered_map<unsigned, RegisteredQueryHint> hint_map;
3332  hint_map.emplace(node->getId(), query_hint);
3333  query_hint_.emplace(node_key, hint_map);
3334  } else {
3335  it->second.emplace(node->getId(), query_hint);
3336  }
3337  }
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > query_hint_
Definition: RelAlgDag.h:3388
unsigned getId() const
Definition: RelAlgDag.h:869
virtual size_t toHash() const =0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAlgDag::registerQueryHints ( std::shared_ptr< RelAlgNode node,
Hints hints_delivered,
RegisteredQueryHint global_query_hint 
)
inline

Definition at line 2842 of file RelAlgDag.h.

References RegisteredQueryHint::aggregate_tree_fanout, RegisteredQueryHint::bbox_intersect_allow_gpu_build, RegisteredQueryHint::bbox_intersect_bucket_threshold, RegisteredQueryHint::bbox_intersect_keys_per_bin, RegisteredQueryHint::bbox_intersect_max_size, RegisteredQueryHint::bbox_intersect_no_cache, CHECK_EQ, RegisteredQueryHint::columnar_output, RegisteredQueryHint::cpu_mode, RegisteredQueryHint::cuda_block_size, RegisteredQueryHint::cuda_grid_size_multiplier, RegisteredQueryHint::dynamic_watchdog, RegisteredQueryHint::force_baseline_hash_join, RegisteredQueryHint::force_one_to_many_hash_join, g_enable_columnar_output, g_enable_data_recycler, g_enable_dynamic_watchdog, g_enable_watchdog, g_use_query_resultset_cache, kAggregateTreeFanout, kAllowLoopJoin, kBBoxIntersectAllowGpuBuild, kBBoxIntersectBucketThreshold, kBBoxIntersectKeysPerBin, kBBoxIntersectMaxSize, kBBoxIntersectNoCache, kColumnarOutput, kCpuMode, kCudaBlockSize, kCudaGridSize, kDisableLoopJoin, kDynamicWatchdog, kDynamicWatchdogOff, RegisteredQueryHint::keep_result, RegisteredQueryHint::keep_table_function_result, kforceBaselineHashJoin, kforceOneToManyHashJoin, kKeepResult, kKeepTableFuncResult, kLoopJoinInnerTableMaxNumRows, kMaxJoinHashTableSize, kNDVGroupsEstimatorMultiplier, kOptCudaBlockAndGridSizes, kPreflightCountQueryThreshold, kQueryTimeLimit, kRowwiseOutput, kTableReorderingOff, kWatchdog, kWatchdogMaxProjectedRowsPerDevice, kWatchdogOff, RegisteredQueryHint::loop_join_inner_table_max_num_rows, RegisteredQueryHint::max_join_hash_table_size, RegisteredQueryHint::ndv_groups_estimator_multiplier, RegisteredQueryHint::opt_cuda_grid_and_block_size, RegisteredQueryHint::preflight_count_query_threshold, RegisteredQueryHint::query_time_limit, RegisteredQueryHint::registerHint(), registerQueryHint(), RegisteredQueryHint::rowwise_output, RegisteredQueryHint::table_reordering_off, RegisteredQueryHint::use_loop_join, VLOG, RegisteredQueryHint::watchdog, and RegisteredQueryHint::watchdog_max_projected_rows_per_device.

2844  {
2845  std::optional<bool> has_global_columnar_output_hint = std::nullopt;
2846  std::optional<bool> has_global_rowwise_output_hint = std::nullopt;
2847  RegisteredQueryHint query_hint;
2848  for (auto it = hints_delivered->begin(); it != hints_delivered->end(); it++) {
2849  auto target = it->second;
2850  auto hint_type = it->first;
2851  switch (hint_type) {
2852  case QueryHint::kCpuMode: {
2853  query_hint.registerHint(QueryHint::kCpuMode);
2854  query_hint.cpu_mode = true;
2855  if (target.isGlobalHint()) {
2856  global_query_hint.registerHint(QueryHint::kCpuMode);
2857  global_query_hint.cpu_mode = true;
2858  }
2859  break;
2860  }
2862  has_global_columnar_output_hint = target.isGlobalHint();
2863  break;
2864  }
2866  has_global_rowwise_output_hint = target.isGlobalHint();
2867  break;
2868  }
2870  if (target.getListOptions().size() != 1) {
2871  VLOG(1) << "Skip the given query hint \"bbox_intersect_bucket_threshold\" ("
2872  << target.getListOptions()[0]
2873  << ") : invalid # hint options are given";
2874  break;
2875  }
2876  double bbox_intersect_bucket_threshold = std::stod(target.getListOptions()[0]);
2877  if (bbox_intersect_bucket_threshold >= 0.0 &&
2878  bbox_intersect_bucket_threshold <= 90.0) {
2880  query_hint.bbox_intersect_bucket_threshold = bbox_intersect_bucket_threshold;
2881  if (target.isGlobalHint()) {
2883  global_query_hint.bbox_intersect_bucket_threshold =
2884  bbox_intersect_bucket_threshold;
2885  }
2886  } else {
2887  VLOG(1) << "Skip the given query hint \"bbox_intersect_bucket_threshold\" ("
2888  << bbox_intersect_bucket_threshold
2889  << ") : the hint value should be within 0.0 ~ 90.0";
2890  }
2891  break;
2892  }
2894  if (target.getListOptions().size() != 1) {
2895  VLOG(1) << "Skip the given query hint \"bbox_intersect_max_size\" ("
2896  << target.getListOptions()[0]
2897  << ") : invalid # hint options are given";
2898  break;
2899  }
2900  std::stringstream ss(target.getListOptions()[0]);
2901  int bbox_intersect_max_size;
2902  ss >> bbox_intersect_max_size;
2903  if (bbox_intersect_max_size >= 0) {
2905  query_hint.bbox_intersect_max_size = (size_t)bbox_intersect_max_size;
2906  if (target.isGlobalHint()) {
2908  global_query_hint.bbox_intersect_max_size = (size_t)bbox_intersect_max_size;
2909  }
2910  } else {
2911  VLOG(1) << "Skip the query hint \"bbox_intersect_max_size\" ("
2912  << bbox_intersect_max_size
2913  << ") : the hint value should be larger than or equal to zero";
2914  }
2915  break;
2916  }
2919  query_hint.bbox_intersect_allow_gpu_build = true;
2920  if (target.isGlobalHint()) {
2922  global_query_hint.bbox_intersect_allow_gpu_build = true;
2923  }
2924  break;
2925  }
2928  query_hint.bbox_intersect_no_cache = true;
2929  if (target.isGlobalHint()) {
2931  global_query_hint.bbox_intersect_no_cache = true;
2932  }
2933  VLOG(1) << "Skip auto tuner and hashtable caching for bbox_intersect join.";
2934  break;
2935  }
2937  if (target.getListOptions().size() != 1) {
2938  VLOG(1) << "Skip the given query hint \"bbox_intersect_keys_per_bin\" ("
2939  << target.getListOptions()[0]
2940  << ") : invalid # hint options are given";
2941  break;
2942  }
2943  double bbox_intersect_keys_per_bin = std::stod(target.getListOptions()[0]);
2944  if (bbox_intersect_keys_per_bin > 0.0 &&
2945  bbox_intersect_keys_per_bin < std::numeric_limits<double>::max()) {
2947  query_hint.bbox_intersect_keys_per_bin = bbox_intersect_keys_per_bin;
2948  if (target.isGlobalHint()) {
2950  global_query_hint.bbox_intersect_keys_per_bin = bbox_intersect_keys_per_bin;
2951  }
2952  } else {
2953  VLOG(1) << "Skip the given query hint \"bbox_intersect_keys_per_bin\" ("
2954  << bbox_intersect_keys_per_bin
2955  << ") : the hint value should be larger than zero";
2956  }
2957  break;
2958  }
2959  case QueryHint::kKeepResult: {
2961  VLOG(1) << "Skip query hint \'keep_result\' because neither data recycler "
2962  "nor query resultset recycler is enabled";
2963  } else {
2965  query_hint.keep_result = true;
2966  if (target.isGlobalHint()) {
2967  global_query_hint.registerHint(QueryHint::kKeepResult);
2968  global_query_hint.keep_result = true;
2969  }
2970  }
2971  break;
2972  }
2975  VLOG(1) << "Skip query hint \'keep_table_function_result\' because neither "
2976  "data recycler "
2977  "nor query resultset recycler is enabled";
2978  } else {
2979  // we assume table function's hint is handled as global hint by default
2980  global_query_hint.registerHint(QueryHint::kKeepTableFuncResult);
2981  global_query_hint.keep_table_function_result = true;
2982  }
2983  break;
2984  }
2986  if (target.getListOptions().size() != 1u) {
2987  VLOG(1) << "Skip the given query hint \"aggregate_tree_fanout\" ("
2988  << target.getListOptions()[0]
2989  << ") : invalid # hint options are given";
2990  break;
2991  }
2992  int aggregate_tree_fanout = std::stoi(target.getListOptions()[0]);
2993  if (aggregate_tree_fanout < 0) {
2994  VLOG(1) << "A fan-out of an aggregate tree should be larger than zero";
2995  } else if (aggregate_tree_fanout > 1024) {
2996  VLOG(1) << "Too large fanout is provided (i.e., fanout < 1024)";
2997  } else {
2999  query_hint.aggregate_tree_fanout = aggregate_tree_fanout;
3000  if (target.isGlobalHint()) {
3001  global_query_hint.registerHint(QueryHint::kAggregateTreeFanout);
3002  global_query_hint.aggregate_tree_fanout = aggregate_tree_fanout;
3003  }
3004  }
3005  break;
3006  }
3008  CHECK_EQ(1u, target.getListOptions().size());
3009  int cuda_block_size = std::stoi(target.getListOptions()[0]);
3010  if (cuda_block_size <= 0) {
3011  VLOG(1) << "CUDA block size should be larger than zero";
3012  } else if (cuda_block_size > 1024) {
3013  VLOG(1) << "CUDA block size should be less or equal to 1024";
3014  } else {
3016  query_hint.cuda_block_size = cuda_block_size;
3017  if (target.isGlobalHint()) {
3018  global_query_hint.registerHint(QueryHint::kCudaBlockSize);
3019  global_query_hint.cuda_block_size = cuda_block_size;
3020  }
3021  }
3022  break;
3023  }
3024  case QueryHint::kCudaGridSize: {
3025  CHECK_EQ(1u, target.getListOptions().size());
3026  double cuda_grid_size_multiplier = std::stod(target.getListOptions()[0]);
3027  double min_grid_size_multiplier{0};
3028  double max_grid_size_multiplier{1024};
3029  if (cuda_grid_size_multiplier <= min_grid_size_multiplier) {
3030  VLOG(1) << "CUDA grid size multiplier should be larger than zero";
3031  } else if (cuda_grid_size_multiplier > max_grid_size_multiplier) {
3032  VLOG(1) << "CUDA grid size multiplier should be less than 1024";
3033  } else {
3035  query_hint.cuda_grid_size_multiplier = cuda_grid_size_multiplier;
3036  if (target.isGlobalHint()) {
3037  global_query_hint.registerHint(QueryHint::kCudaGridSize);
3038  global_query_hint.cuda_grid_size_multiplier = cuda_grid_size_multiplier;
3039  }
3040  }
3041  break;
3042  }
3045  query_hint.opt_cuda_grid_and_block_size = true;
3046  if (target.isGlobalHint()) {
3048  global_query_hint.opt_cuda_grid_and_block_size = true;
3049  }
3050  break;
3051  }
3052  case QueryHint::kWatchdog: {
3053  if (g_enable_watchdog) {
3054  VLOG(1) << "Skip the given query hint \"watchdog\": already enabled";
3055  } else {
3056  query_hint.registerHint(QueryHint::kWatchdog);
3057  query_hint.watchdog = true;
3058  if (target.isGlobalHint()) {
3059  global_query_hint.registerHint(QueryHint::kWatchdog);
3060  global_query_hint.watchdog = true;
3061  }
3062  }
3063  break;
3064  }
3065  case QueryHint::kWatchdogOff: {
3066  if (!g_enable_watchdog) {
3067  VLOG(1) << "Skip the given query hint \"watchdog_off\": already disabled";
3068  } else {
3070  query_hint.watchdog = false;
3071  if (target.isGlobalHint()) {
3072  global_query_hint.registerHint(QueryHint::kWatchdogOff);
3073  global_query_hint.watchdog = false;
3074  }
3075  }
3076 
3077  break;
3078  }
3081  VLOG(1) << "Skip the given query hint \"dynamic_watchdog\": already enabled";
3082  } else {
3084  query_hint.dynamic_watchdog = true;
3085  if (target.isGlobalHint()) {
3086  global_query_hint.registerHint(QueryHint::kDynamicWatchdog);
3087  global_query_hint.dynamic_watchdog = true;
3088  }
3089  }
3090  break;
3091  }
3094  VLOG(1)
3095  << "Skip the given query hint \"dynamic_watchdog_off\": already disabled";
3096  } else {
3098  query_hint.dynamic_watchdog = false;
3099  if (target.isGlobalHint()) {
3100  global_query_hint.registerHint(QueryHint::kDynamicWatchdogOff);
3101  global_query_hint.dynamic_watchdog = false;
3102  }
3103  }
3104  break;
3105  }
3107  if (hints_delivered->find(QueryHint::kDynamicWatchdogOff) !=
3108  hints_delivered->end()) {
3109  VLOG(1) << "Skip the given query hint \"query_time_limit\" ("
3110  << target.getListOptions()[0]
3111  << ") : cannot use it with \"dynamic_watchdog_off\" hint";
3112  break;
3113  }
3114  if (target.getListOptions().size() != 1) {
3115  VLOG(1) << "Skip the given query hint \"query_time_limit\" ("
3116  << target.getListOptions()[0]
3117  << ") : invalid # hint options are given";
3118  break;
3119  }
3120  double query_time_limit = std::stoi(target.getListOptions()[0]);
3121  if (query_time_limit <= 0) {
3122  VLOG(1) << "Skip the given query hint \"query_time_limit\" ("
3123  << target.getListOptions()[0]
3124  << ") : the hint value should be larger than zero";
3125  break;
3126  }
3128  query_hint.query_time_limit = query_time_limit;
3129  if (target.isGlobalHint()) {
3130  global_query_hint.registerHint(QueryHint::kQueryTimeLimit);
3131  global_query_hint.query_time_limit = query_time_limit;
3132  }
3133  break;
3134  }
3137  query_hint.use_loop_join = true;
3138  if (target.isGlobalHint()) {
3139  global_query_hint.registerHint(QueryHint::kAllowLoopJoin);
3140  global_query_hint.use_loop_join = true;
3141  }
3142  break;
3143  }
3146  query_hint.use_loop_join = false;
3147  if (target.isGlobalHint()) {
3148  global_query_hint.registerHint(QueryHint::kDisableLoopJoin);
3149  global_query_hint.use_loop_join = false;
3150  }
3151  break;
3152  }
3154  CHECK_EQ(1u, target.getListOptions().size());
3155  int loop_size_threshold = std::stoi(target.getListOptions()[0]);
3156  if (loop_size_threshold <= 0) {
3157  VLOG(1)
3158  << "Skip the given query hint \"loop_join_inner_table_max_num_rows\" ("
3159  << target.getListOptions()[0]
3160  << ") : the hint value should be larger than zero";
3161  } else {
3163  query_hint.loop_join_inner_table_max_num_rows = loop_size_threshold;
3164  if (target.isGlobalHint()) {
3166  global_query_hint.loop_join_inner_table_max_num_rows = loop_size_threshold;
3167  }
3168  }
3169  break;
3170  }
3172  CHECK_EQ(1u, target.getListOptions().size());
3173  int max_join_hash_table_size = std::stoi(target.getListOptions()[0]);
3174  if (max_join_hash_table_size <= 0) {
3175  VLOG(1) << "Skip the given query hint \"max_join_hashtable_size\" ("
3176  << target.getListOptions()[0]
3177  << ") : the hint value should be larger than zero";
3178  } else {
3180  query_hint.max_join_hash_table_size = max_join_hash_table_size;
3181  if (target.isGlobalHint()) {
3183  global_query_hint.max_join_hash_table_size = max_join_hash_table_size;
3184  }
3185  }
3186  break;
3187  }
3190  query_hint.force_baseline_hash_join = true;
3191  if (target.isGlobalHint()) {
3193  global_query_hint.force_baseline_hash_join = true;
3194  }
3195  break;
3196  }
3199  query_hint.force_one_to_many_hash_join = true;
3200  if (target.isGlobalHint()) {
3202  global_query_hint.force_one_to_many_hash_join = true;
3203  }
3204  break;
3205  }
3207  CHECK_EQ(1u, target.getListOptions().size());
3208  int watchdog_max_projected_rows_per_device =
3209  std::stoi(target.getListOptions()[0]);
3210  if (watchdog_max_projected_rows_per_device <= 0) {
3211  VLOG(1) << "Skip the given query hint "
3212  "\"watchdog_max_projected_rows_per_device\" ("
3213  << target.getListOptions()[0]
3214  << ") : the hint value should be larger than zero";
3215  } else {
3218  watchdog_max_projected_rows_per_device;
3219  if (target.isGlobalHint()) {
3220  global_query_hint.registerHint(
3222  global_query_hint.watchdog_max_projected_rows_per_device =
3223  watchdog_max_projected_rows_per_device;
3224  }
3225  }
3226  break;
3227  }
3229  CHECK_EQ(1u, target.getListOptions().size());
3230  int preflight_count_query_threshold = std::stoi(target.getListOptions()[0]);
3231  if (preflight_count_query_threshold <= 0) {
3232  VLOG(1) << "Skip the given query hint \"preflight_count_query_threshold\" ("
3233  << target.getListOptions()[0]
3234  << ") : the hint value should be larger than zero";
3235  } else {
3237  query_hint.preflight_count_query_threshold = preflight_count_query_threshold;
3238  if (target.isGlobalHint()) {
3240  global_query_hint.preflight_count_query_threshold =
3241  preflight_count_query_threshold;
3242  }
3243  }
3244  break;
3245  }
3248  query_hint.table_reordering_off = true;
3249  if (target.isGlobalHint()) {
3250  global_query_hint.registerHint(QueryHint::kTableReorderingOff);
3251  global_query_hint.table_reordering_off = true;
3252  }
3253  break;
3254  }
3256  CHECK_EQ(1u, target.getListOptions().size());
3257  double ndv_groups_estimator_multiplier = std::stod(target.getListOptions()[0]);
3258  if (ndv_groups_estimator_multiplier < 1.0 ||
3259  ndv_groups_estimator_multiplier > 2.0) {
3260  VLOG(1) << "Skip the given query hint \"ndv_groups_estimator_multiplier\" ("
3261  << target.getListOptions()[0]
3262  << ") : the valid hint value range is 1.0 <= "
3263  "ndv_groups_estimator_multiplier <= 2.0";
3264  } else {
3266  query_hint.ndv_groups_estimator_multiplier = ndv_groups_estimator_multiplier;
3267  if (target.isGlobalHint()) {
3269  global_query_hint.ndv_groups_estimator_multiplier =
3270  ndv_groups_estimator_multiplier;
3271  }
3272  }
3273  break;
3274  }
3275  default:
3276  break;
3277  }
3278  }
3279  // we have four cases depending on 1) g_enable_columnar_output flag
3280  // and 2) query hint status: columnar_output and rowwise_output
3281  // case 1. g_enable_columnar_output = true
3282  // case 1.a) columnar_output = true (so rowwise_output = false);
3283  // case 1.b) rowwise_output = true (so columnar_output = false);
3284  // case 2. g_enable_columnar_output = false
3285  // case 2.a) columnar_output = true (so rowwise_output = false);
3286  // case 2.b) rowwise_output = true (so columnar_output = false);
3287  // case 1.a --> use columnar output
3288  // case 1.b --> use rowwise output
3289  // case 2.a --> use columnar output
3290  // case 2.b --> use rowwise output
3291  if (has_global_columnar_output_hint.has_value() &&
3292  has_global_rowwise_output_hint.has_value()) {
3293  VLOG(1)
3294  << "Two hints 1) columnar output and 2) rowwise output are enabled together, "
3295  << "so skip them and use the runtime configuration "
3296  "\"g_enable_columnar_output\"";
3297  } else if (has_global_columnar_output_hint.has_value() &&
3298  !has_global_rowwise_output_hint.has_value()) {
3300  VLOG(1) << "We already enable columnar output by default "
3301  "(g_enable_columnar_output = true), so skip this columnar output hint";
3302  } else {
3304  query_hint.columnar_output = true;
3305  if (*has_global_columnar_output_hint) {
3306  global_query_hint.registerHint(QueryHint::kColumnarOutput);
3307  global_query_hint.columnar_output = true;
3308  }
3309  }
3310  } else if (!has_global_columnar_output_hint.has_value() &&
3311  has_global_rowwise_output_hint.has_value()) {
3312  if (!g_enable_columnar_output) {
3313  VLOG(1) << "We already use the default rowwise output (g_enable_columnar_output "
3314  "= false), so skip this rowwise output hint";
3315  } else {
3317  query_hint.rowwise_output = true;
3318  if (*has_global_rowwise_output_hint) {
3319  global_query_hint.registerHint(QueryHint::kRowwiseOutput);
3320  global_query_hint.rowwise_output = true;
3321  }
3322  }
3323  }
3324  registerQueryHint(node.get(), query_hint);
3325  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
bool g_use_query_resultset_cache
Definition: Execute.cpp:160
double bbox_intersect_keys_per_bin
Definition: QueryHint.h:368
void registerQueryHint(const RelAlgNode *node, const RegisteredQueryHint &query_hint)
Definition: RelAlgDag.h:3327
std::optional< bool > dynamic_watchdog
Definition: QueryHint.h:347
double cuda_grid_size_multiplier
Definition: QueryHint.h:356
size_t cuda_block_size
Definition: QueryHint.h:355
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:81
bool g_enable_data_recycler
Definition: Execute.cpp:158
size_t max_join_hash_table_size
Definition: QueryHint.h:373
bool opt_cuda_grid_and_block_size
Definition: QueryHint.h:357
bool g_enable_columnar_output
Definition: Execute.cpp:106
bool keep_table_function_result
Definition: QueryHint.h:345
size_t query_time_limit
Definition: QueryHint.h:348
double bbox_intersect_bucket_threshold
Definition: QueryHint.h:363
double ndv_groups_estimator_multiplier
Definition: QueryHint.h:352
void registerHint(const QueryHint hint)
Definition: QueryHint.h:393
bool g_enable_watchdog
size_t watchdog_max_projected_rows_per_device
Definition: QueryHint.h:349
std::optional< bool > watchdog
Definition: QueryHint.h:346
size_t preflight_count_query_threshold
Definition: QueryHint.h:350
size_t bbox_intersect_max_size
Definition: QueryHint.h:365
bool force_baseline_hash_join
Definition: QueryHint.h:374
bool bbox_intersect_no_cache
Definition: QueryHint.h:367
std::optional< bool > use_loop_join
Definition: QueryHint.h:371
size_t loop_join_inner_table_max_num_rows
Definition: QueryHint.h:372
bool bbox_intersect_allow_gpu_build
Definition: QueryHint.h:366
size_t aggregate_tree_fanout
Definition: QueryHint.h:360
#define VLOG(n)
Definition: Logger.h:388
bool force_one_to_many_hash_join
Definition: QueryHint.h:375

+ Here is the call graph for this function:

void RelAlgDag::registerSubquery ( std::shared_ptr< RexSubQuery subquery)
inline

Registers a subquery with a root DAG builder. Should only be called during DAG building and registration should only occur on the root.

Definition at line 2830 of file RelAlgDag.h.

References subqueries_.

Referenced by anonymous_namespace{RelAlgDag.cpp}::parse_subquery().

2830  {
2831  subqueries_.push_back(subquery);
2832  }
std::vector< std::shared_ptr< RexSubQuery > > subqueries_
Definition: RelAlgDag.h:3382

+ Here is the caller graph for this function:

void RelAlgDag::resetQueryExecutionState ( )

Gets all registered subqueries. Only the root DAG can contain subqueries.

Definition at line 3471 of file RelAlgDag.cpp.

References nodes_.

3471  {
3472  for (auto& node : nodes_) {
3473  if (node) {
3474  node->resetQueryExecutionState();
3475  }
3476  }
3477 }
std::vector< std::shared_ptr< RelAlgNode > > nodes_
Definition: RelAlgDag.h:3381
void RelAlgDag::setGlobalQueryHints ( const RegisteredQueryHint global_hints)
inline

Definition at line 3369 of file RelAlgDag.h.

References global_hints_.

Referenced by RelAlgExecutor::executeRelAlgQueryNoRetry(), and anonymous_namespace{RelAlgDag.cpp}::parse_subquery().

3369  {
3370  global_hints_ = global_hints;
3371  }
RegisteredQueryHint global_hints_
Definition: RelAlgDag.h:3389

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend struct RelAlgDagModifier
friend

Definition at line 3392 of file RelAlgDag.h.

friend struct RelAlgDagSerializer
friend

Definition at line 3391 of file RelAlgDag.h.

Member Data Documentation

BuildState RelAlgDag::build_state_
private
RegisteredQueryHint RelAlgDag::global_hints_
private
std::vector<std::shared_ptr<RelAlgNode> > RelAlgDag::nodes_
private
std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint> > RelAlgDag::query_hint_
private
std::vector<std::shared_ptr<RexSubQuery> > RelAlgDag::subqueries_
private

The documentation for this class was generated from the following files: