OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner Class Reference
+ Collaboration diagram for anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner:

Public Member Functions

 BucketSizeTuner (const double bucket_threshold, const double step, const double min_threshold, const Data_Namespace::MemoryLevel effective_memory_level, const std::vector< ColumnsForDevice > &columns_per_device, const std::vector< InnerOuter > &inner_outer_pairs, const size_t table_tuple_count, const Executor *executor)
 
bool tuneOneStep ()
 
bool tuneOneStep (const TuningState::TuningDirection tuning_direction)
 
bool tuneOneStep (const TuningState::TuningDirection tuning_direction, const double step_overide)
 
auto getMinBucketSize () const
 
std::vector< double > getInverseBucketSizes ()
 

Private Member Functions

bool bucketThresholdsBelowMinThreshold () const
 
std::vector< double > computeBucketSizes () const
 
bool tuneSmallerOneStep (const double step_overide)
 
bool tuneLargerOneStep (const double step_overide)
 

Private Attributes

size_t num_dims_
 
std::vector< double > bucket_thresholds_
 
size_t num_steps_ {0}
 
const double step_
 
const double min_threshold_
 
const Data_Namespace::MemoryLevel effective_memory_level_
 
const std::vector
< ColumnsForDevice > & 
columns_per_device_
 
const std::vector< InnerOuter > & inner_outer_pairs_
 
const size_t table_tuple_count_
 
const Executorexecutor_
 
std::vector< double > current_bucket_sizes_
 

Friends

std::ostream & operator<< (std::ostream &os, const BucketSizeTuner &tuner)
 

Detailed Description

Definition at line 396 of file BoundingBoxIntersectJoinHashTable.cpp.

Constructor & Destructor Documentation

anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::BucketSizeTuner ( const double  bucket_threshold,
const double  step,
const double  min_threshold,
const Data_Namespace::MemoryLevel  effective_memory_level,
const std::vector< ColumnsForDevice > &  columns_per_device,
const std::vector< InnerOuter > &  inner_outer_pairs,
const size_t  table_tuple_count,
const Executor executor 
)
inline

Definition at line 398 of file BoundingBoxIntersectJoinHashTable.cpp.

References CHECK.

406  : num_dims_(2) // Todo: allow varying number of dims
407  , bucket_thresholds_(/*count=*/num_dims_, /*value=*/bucket_threshold)
408  , step_(step)
409  , min_threshold_(min_threshold)
410  , effective_memory_level_(effective_memory_level)
411  , columns_per_device_(columns_per_device)
412  , inner_outer_pairs_(inner_outer_pairs)
413  , table_tuple_count_(table_tuple_count)
414  , executor_(executor) {
415  CHECK(!columns_per_device_.empty());
416  }
#define CHECK(condition)
Definition: Logger.h:291

Member Function Documentation

bool anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::bucketThresholdsBelowMinThreshold ( ) const
inlineprivate

Definition at line 459 of file BoundingBoxIntersectJoinHashTable.cpp.

459  {
460  for (const auto& t : bucket_thresholds_) {
461  if (t < min_threshold_) {
462  return true;
463  }
464  }
465  return false;
466  }
std::vector<double> anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::computeBucketSizes ( ) const
inlineprivate

Definition at line 468 of file BoundingBoxIntersectJoinHashTable.cpp.

References anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::compute_bucket_sizes(), and executor_().

468  {
469  if (table_tuple_count_ == 0) {
470  return std::vector<double>(/*count=*/num_dims_, /*val=*/0);
471  }
474  columns_per_device_.front().join_columns[0],
475  columns_per_device_.front().join_column_types[0],
477  executor_);
478  }
std::vector< double > compute_bucket_sizes(const std::vector< double > &bucket_thresholds, const Data_Namespace::MemoryLevel effective_memory_level, const JoinColumn &join_column, const JoinColumnTypeInfo &join_column_type, const std::vector< InnerOuter > &inner_outer_pairs, const Executor *executor)

+ Here is the call graph for this function:

std::vector<double> anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::getInverseBucketSizes ( )
inline

Method to retrieve inverted bucket sizes, which are what are used elsewhere in the hash join framework for bounding box intersection

Returns
the inverted bucket sizes, i.e. a set of that will place a raw value in a bucket when multiplied by the raw value

Definition at line 445 of file BoundingBoxIntersectJoinHashTable.cpp.

References CHECK_EQ.

445  {
446  if (num_steps_ == 0) {
447  CHECK_EQ(current_bucket_sizes_.size(), static_cast<size_t>(0));
449  }
451  std::vector<double> inverse_bucket_sizes;
452  for (const auto s : current_bucket_sizes_) {
453  inverse_bucket_sizes.emplace_back(1.0 / s);
454  }
455  return inverse_bucket_sizes;
456  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
auto anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::getMinBucketSize ( ) const
inline

Definition at line 435 of file BoundingBoxIntersectJoinHashTable.cpp.

435  {
436  return *std::min_element(bucket_thresholds_.begin(), bucket_thresholds_.end());
437  }
bool anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::tuneLargerOneStep ( const double  step_overide)
inlineprivate

Definition at line 505 of file BoundingBoxIntersectJoinHashTable.cpp.

References CHECK_EQ.

505  {
506  if (!current_bucket_sizes_.empty()) {
509  }
510  // If current_bucket_sizes was empty, we will start from our initial threshold
511  for (auto& t : bucket_thresholds_) {
512  t *= step_overide;
513  }
514  // When tuning up, do not dynamically compute bucket_sizes, as compute_bucket_sizes as
515  // written will pick the largest bin size below the threshold, meaning our bucket_size
516  // will never increase beyond the size of the largest polygon. This could mean that we
517  // can never make the bucket sizes large enough to get our hash table below the
518  // maximum size Possible todo: enable templated version of compute_bucket_sizes that
519  // allows for optionally finding smallest extent above threshold, to mirror default
520  // behavior finding largest extent below threshold, and use former variant here
522  num_steps_++;
523  return true;
524  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
bool anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::tuneOneStep ( )
inline

Definition at line 418 of file BoundingBoxIntersectJoinHashTable.cpp.

References tuneOneStep().

Referenced by tuneOneStep().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::tuneOneStep ( const TuningState::TuningDirection  tuning_direction)
inline
bool anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::tuneOneStep ( const TuningState::TuningDirection  tuning_direction,
const double  step_overide 
)
inline
bool anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::tuneSmallerOneStep ( const double  step_overide)
inlineprivate

Definition at line 480 of file BoundingBoxIntersectJoinHashTable.cpp.

References CHECK_EQ, and VLOG.

480  {
481  if (!current_bucket_sizes_.empty()) {
484  for (auto& t : bucket_thresholds_) {
485  t /= step_overide;
486  }
487  }
489  VLOG(1) << "Aborting tuning for bounding box intersection as at least one bucket "
490  "size is below min threshold";
491  return false;
492  }
493  const auto next_bucket_sizes = computeBucketSizes();
494  if (next_bucket_sizes == current_bucket_sizes_) {
495  VLOG(1) << "Aborting tuning for bounding box intersection as bucket size is no "
496  "longer changing.";
497  return false;
498  }
499 
500  current_bucket_sizes_ = next_bucket_sizes;
501  num_steps_++;
502  return true;
503  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
#define VLOG(n)
Definition: Logger.h:388

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const BucketSizeTuner tuner 
)
friend

Definition at line 542 of file BoundingBoxIntersectJoinHashTable.cpp.

542  {
543  os << "Step Num: " << tuner.num_steps_ << ", Threshold: " << std::fixed << "("
544  << tuner.bucket_thresholds_[0] << ", " << tuner.bucket_thresholds_[1] << ")"
545  << ", Step Size: " << std::fixed << tuner.step_ << ", Min: " << std::fixed
546  << tuner.min_threshold_;
547  return os;
548 }

Member Data Documentation

std::vector<double> anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::bucket_thresholds_
private
const std::vector<ColumnsForDevice>& anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::columns_per_device_
private

Definition at line 532 of file BoundingBoxIntersectJoinHashTable.cpp.

std::vector<double> anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::current_bucket_sizes_
private

Definition at line 537 of file BoundingBoxIntersectJoinHashTable.cpp.

const Data_Namespace::MemoryLevel anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::effective_memory_level_
private

Definition at line 531 of file BoundingBoxIntersectJoinHashTable.cpp.

const Executor* anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::executor_
private

Definition at line 535 of file BoundingBoxIntersectJoinHashTable.cpp.

const std::vector<InnerOuter>& anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::inner_outer_pairs_
private

Definition at line 533 of file BoundingBoxIntersectJoinHashTable.cpp.

const double anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::min_threshold_
private
size_t anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::num_dims_
private

Definition at line 526 of file BoundingBoxIntersectJoinHashTable.cpp.

size_t anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::num_steps_ {0}
private
const double anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::step_
private
const size_t anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::BucketSizeTuner::table_tuple_count_
private

Definition at line 534 of file BoundingBoxIntersectJoinHashTable.cpp.


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