OmniSciDB  72c90bc290
 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 3440 of file RelAlgDag.cpp.

References nodes_.

3440  {
3441  for (auto const& node : nodes_) {
3442  if (node) {
3443  callback(node.get());
3444  }
3445  }
3446 }
std::vector< std::shared_ptr< RelAlgNode > > nodes_
Definition: RelAlgDag.h:3352
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:3350

+ Here is the caller graph for this function:

const RegisteredQueryHint& RelAlgDag::getGlobalHints ( ) const
inline

Definition at line 3338 of file RelAlgDag.h.

References global_hints_.

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

3338 { return global_hints_; }
RegisteredQueryHint global_hints_
Definition: RelAlgDag.h:3360

+ 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:3352

+ Here is the caller graph for this function:

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

Definition at line 3310 of file RelAlgDag.h.

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

3310  {
3311  auto node_it = query_hint_.find(node->toHash());
3312  if (node_it != query_hint_.end()) {
3313  auto const& registered_query_hint_map = node_it->second;
3314  auto hint_it = registered_query_hint_map.find(node->getId());
3315  if (hint_it != registered_query_hint_map.end()) {
3316  auto const& registered_query_hint = hint_it->second;
3318  // apply global hint to the registered query hint for this query block
3319  return std::make_optional(registered_query_hint || global_hints_);
3320  } else {
3321  return std::make_optional(registered_query_hint);
3322  }
3323  }
3324  }
3326  // if no hint is registered from this query block
3327  // we return global hint instead
3328  return std::make_optional(global_hints_);
3329  }
3330  return std::nullopt;
3331  }
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > query_hint_
Definition: RelAlgDag.h:3359
unsigned getId() const
Definition: RelAlgDag.h:869
RegisteredQueryHint global_hints_
Definition: RelAlgDag.h:3360
virtual size_t toHash() const =0
bool isAnyQueryHintDelivered() const
Definition: QueryHint.h:373

+ Here is the call graph for this function:

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

Definition at line 3334 of file RelAlgDag.h.

References query_hint_.

3334  {
3335  return query_hint_;
3336  }
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > query_hint_
Definition: RelAlgDag.h:3359
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:3352
#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:3352
#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:3353
void RelAlgDag::registerQueryHint ( const RelAlgNode node,
const RegisteredQueryHint query_hint 
)
inline

Definition at line 3298 of file RelAlgDag.h.

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

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

3298  {
3299  auto node_key = node->toHash();
3300  auto it = query_hint_.find(node_key);
3301  if (it == query_hint_.end()) {
3302  std::unordered_map<unsigned, RegisteredQueryHint> hint_map;
3303  hint_map.emplace(node->getId(), query_hint);
3304  query_hint_.emplace(node_key, hint_map);
3305  } else {
3306  it->second.emplace(node->getId(), query_hint);
3307  }
3308  }
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > query_hint_
Definition: RelAlgDag.h:3359
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, kOptCudaBlockAndGridSizes, kPreflightCountQueryThreshold, kQueryTimeLimit, kRowwiseOutput, kWatchdog, kWatchdogMaxProjectedRowsPerDevice, kWatchdogOff, RegisteredQueryHint::loop_join_inner_table_max_num_rows, RegisteredQueryHint::max_join_hash_table_size, RegisteredQueryHint::opt_cuda_grid_and_block_size, RegisteredQueryHint::preflight_count_query_threshold, RegisteredQueryHint::query_time_limit, RegisteredQueryHint::registerHint(), registerQueryHint(), RegisteredQueryHint::rowwise_output, 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  }
3246  default:
3247  break;
3248  }
3249  }
3250  // we have four cases depending on 1) g_enable_columnar_output flag
3251  // and 2) query hint status: columnar_output and rowwise_output
3252  // case 1. g_enable_columnar_output = true
3253  // case 1.a) columnar_output = true (so rowwise_output = false);
3254  // case 1.b) rowwise_output = true (so columnar_output = false);
3255  // case 2. g_enable_columnar_output = false
3256  // case 2.a) columnar_output = true (so rowwise_output = false);
3257  // case 2.b) rowwise_output = true (so columnar_output = false);
3258  // case 1.a --> use columnar output
3259  // case 1.b --> use rowwise output
3260  // case 2.a --> use columnar output
3261  // case 2.b --> use rowwise output
3262  if (has_global_columnar_output_hint.has_value() &&
3263  has_global_rowwise_output_hint.has_value()) {
3264  VLOG(1)
3265  << "Two hints 1) columnar output and 2) rowwise output are enabled together, "
3266  << "so skip them and use the runtime configuration "
3267  "\"g_enable_columnar_output\"";
3268  } else if (has_global_columnar_output_hint.has_value() &&
3269  !has_global_rowwise_output_hint.has_value()) {
3271  VLOG(1) << "We already enable columnar output by default "
3272  "(g_enable_columnar_output = true), so skip this columnar output hint";
3273  } else {
3275  query_hint.columnar_output = true;
3276  if (*has_global_columnar_output_hint) {
3277  global_query_hint.registerHint(QueryHint::kColumnarOutput);
3278  global_query_hint.columnar_output = true;
3279  }
3280  }
3281  } else if (!has_global_columnar_output_hint.has_value() &&
3282  has_global_rowwise_output_hint.has_value()) {
3283  if (!g_enable_columnar_output) {
3284  VLOG(1) << "We already use the default rowwise output (g_enable_columnar_output "
3285  "= false), so skip this rowwise output hint";
3286  } else {
3288  query_hint.rowwise_output = true;
3289  if (*has_global_rowwise_output_hint) {
3290  global_query_hint.registerHint(QueryHint::kRowwiseOutput);
3291  global_query_hint.rowwise_output = true;
3292  }
3293  }
3294  }
3295  registerQueryHint(node.get(), query_hint);
3296  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
bool g_use_query_resultset_cache
Definition: Execute.cpp:156
double bbox_intersect_keys_per_bin
Definition: QueryHint.h:353
void registerQueryHint(const RelAlgNode *node, const RegisteredQueryHint &query_hint)
Definition: RelAlgDag.h:3298
std::optional< bool > dynamic_watchdog
Definition: QueryHint.h:334
double cuda_grid_size_multiplier
Definition: QueryHint.h:341
size_t cuda_block_size
Definition: QueryHint.h:340
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:81
bool g_enable_data_recycler
Definition: Execute.cpp:154
size_t max_join_hash_table_size
Definition: QueryHint.h:358
bool opt_cuda_grid_and_block_size
Definition: QueryHint.h:342
bool g_enable_columnar_output
Definition: Execute.cpp:102
bool keep_table_function_result
Definition: QueryHint.h:332
size_t query_time_limit
Definition: QueryHint.h:335
double bbox_intersect_bucket_threshold
Definition: QueryHint.h:348
void registerHint(const QueryHint hint)
Definition: QueryHint.h:378
bool g_enable_watchdog
size_t watchdog_max_projected_rows_per_device
Definition: QueryHint.h:336
std::optional< bool > watchdog
Definition: QueryHint.h:333
size_t preflight_count_query_threshold
Definition: QueryHint.h:337
size_t bbox_intersect_max_size
Definition: QueryHint.h:350
bool force_baseline_hash_join
Definition: QueryHint.h:359
bool bbox_intersect_no_cache
Definition: QueryHint.h:352
std::optional< bool > use_loop_join
Definition: QueryHint.h:356
size_t loop_join_inner_table_max_num_rows
Definition: QueryHint.h:357
bool bbox_intersect_allow_gpu_build
Definition: QueryHint.h:351
size_t aggregate_tree_fanout
Definition: QueryHint.h:345
#define VLOG(n)
Definition: Logger.h:388
bool force_one_to_many_hash_join
Definition: QueryHint.h:360

+ 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:3353

+ 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 3448 of file RelAlgDag.cpp.

References nodes_.

3448  {
3449  for (auto& node : nodes_) {
3450  if (node) {
3451  node->resetQueryExecutionState();
3452  }
3453  }
3454 }
std::vector< std::shared_ptr< RelAlgNode > > nodes_
Definition: RelAlgDag.h:3352
void RelAlgDag::setGlobalQueryHints ( const RegisteredQueryHint global_hints)
inline

Definition at line 3340 of file RelAlgDag.h.

References global_hints_.

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

3340  {
3341  global_hints_ = global_hints;
3342  }
RegisteredQueryHint global_hints_
Definition: RelAlgDag.h:3360

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend struct RelAlgDagModifier
friend

Definition at line 3363 of file RelAlgDag.h.

friend struct RelAlgDagSerializer
friend

Definition at line 3362 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: