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

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::WidthBucketExpr:
+ Collaboration diagram for Analyzer::WidthBucketExpr:

Public Member Functions

 WidthBucketExpr (const std::shared_ptr< Analyzer::Expr > target_value, const std::shared_ptr< Analyzer::Expr > lower_bound, const std::shared_ptr< Analyzer::Expr > upper_bound, const std::shared_ptr< Analyzer::Expr > partition_count)
 
const Exprget_target_value () const
 
const Exprget_lower_bound () const
 
const Exprget_upper_bound () const
 
const Exprget_partition_count () const
 
std::shared_ptr< Analyzer::Exprdeep_copy () const override
 
void group_predicates (std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
 
void collect_rte_idx (std::set< int > &rte_idx_set) const override
 
void collect_column_var (std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
 
std::shared_ptr< Analyzer::Exprrewrite_with_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_with_child_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_agg_to_var (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
double get_bound_val (const Analyzer::Expr *bound_expr) const
 
int32_t get_partition_count_val () const
 
int32_t compute_bucket (double target_const_val) const
 
bool operator== (const Expr &rhs) const override
 
std::string toString () const override
 
void find_expr (std::function< bool(const Expr *)> f, std::list< const Expr * > &expr_list) const override
 
bool can_skip_out_of_bound_check () const
 
void skip_out_of_bound_check () const
 
void set_constant_expr () const
 
bool is_constant_expr () const
 
- Public Member Functions inherited from Analyzer::Expr
 Expr (SQLTypes t, bool notnull)
 
 Expr (SQLTypes t, int d, bool notnull)
 
 Expr (SQLTypes t, int d, int s, bool notnull)
 
 Expr (const SQLTypeInfo &ti, bool has_agg=false)
 
virtual ~Expr ()
 
std::shared_ptr< Analyzer::Exprget_shared_ptr ()
 
const SQLTypeInfoget_type_info () const
 
void set_type_info (const SQLTypeInfo &ti)
 
bool get_contains_agg () const
 
void set_contains_agg (bool a)
 
virtual std::shared_ptr
< Analyzer::Expr
add_cast (const SQLTypeInfo &new_type_info)
 
virtual void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const
 
virtual std::shared_ptr
< Analyzer::Expr
normalize_simple_predicate (int &rte_idx) const
 
virtual size_t get_num_column_vars (const bool include_agg) const
 
virtual void print () const
 
virtual void add_unique (std::list< const Expr * > &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Private Attributes

std::shared_ptr< Analyzer::Exprtarget_value_
 
std::shared_ptr< Analyzer::Exprlower_bound_
 
std::shared_ptr< Analyzer::Exprupper_bound_
 
std::shared_ptr< Analyzer::Exprpartition_count_
 
bool constant_expr_
 
bool skip_out_of_bound_check_
 

Additional Inherited Members

- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 1185 of file Analyzer.h.

Constructor & Destructor Documentation

Analyzer::WidthBucketExpr::WidthBucketExpr ( const std::shared_ptr< Analyzer::Expr target_value,
const std::shared_ptr< Analyzer::Expr lower_bound,
const std::shared_ptr< Analyzer::Expr upper_bound,
const std::shared_ptr< Analyzer::Expr partition_count 
)
inline

Definition at line 1187 of file Analyzer.h.

1191  : Expr(kINT, target_value->get_type_info().get_notnull())
1192  , target_value_(target_value)
1195  , partition_count_(partition_count)
1196  , constant_expr_(false)
1197  , skip_out_of_bound_check_(false) {}
DEVICE auto upper_bound(ARGS &&...args)
Definition: gpu_enabled.h:123
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
DEVICE auto lower_bound(ARGS &&...args)
Definition: gpu_enabled.h:78
Definition: sqltypes.h:72
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249

Member Function Documentation

bool Analyzer::WidthBucketExpr::can_skip_out_of_bound_check ( ) const
inline

Definition at line 1243 of file Analyzer.h.

References skip_out_of_bound_check_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenConstantWidthBucketExpr(), and CodeGenerator::codegenWidthBucketExpr().

1243 { return skip_out_of_bound_check_; }

+ Here is the caller graph for this function:

void Analyzer::WidthBucketExpr::collect_column_var ( std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &  colvar_set,
bool  include_agg 
) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1209 of file Analyzer.h.

References target_value_.

1212  {
1213  target_value_->collect_column_var(colvar_set, include_agg);
1214  }
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249
void Analyzer::WidthBucketExpr::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1206 of file Analyzer.h.

References target_value_.

1206  {
1207  target_value_->collect_rte_idx(rte_idx_set);
1208  }
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249
int32_t Analyzer::WidthBucketExpr::compute_bucket ( double  target_const_val) const

Definition at line 3991 of file Analyzer.cpp.

References get_bound_val(), get_partition_count_val(), inline_fp_null_val(), kDOUBLE, gpu_enabled::lower_bound(), lower_bound_, Analyzer::anonymous_namespace{Analyzer.cpp}::ordered_bucket(), gpu_enabled::upper_bound(), and upper_bound_.

Referenced by getExpressionRange().

3991  {
3992  if (target_const == inline_fp_null_val(SQLTypeInfo(kDOUBLE))) {
3993  return INT32_MIN;
3994  }
3995  double const lower_bound = get_bound_val(lower_bound_.get());
3996  double const upper_bound = get_bound_val(upper_bound_.get());
3997  int32_t const partition_count = get_partition_count_val();
3998  if (lower_bound <= upper_bound) {
3999  return ordered_bucket(lower_bound, upper_bound, partition_count, target_const);
4000  } else {
4001  return ordered_bucket(-lower_bound, -upper_bound, partition_count, -target_const);
4002  }
4003 }
DEVICE auto upper_bound(ARGS &&...args)
Definition: gpu_enabled.h:123
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
double get_bound_val(const Analyzer::Expr *bound_expr) const
Definition: Analyzer.cpp:3936
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
int32_t ordered_bucket(double const lower_bound, double const upper_bound, int32_t const partition_count, double const value)
Definition: Analyzer.cpp:3974
DEVICE auto lower_bound(ARGS &&...args)
Definition: gpu_enabled.h:78
int32_t get_partition_count_val() const
Definition: Analyzer.cpp:3946

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr< Analyzer::Expr > Analyzer::WidthBucketExpr::deep_copy ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 183 of file Analyzer.cpp.

References lower_bound_, partition_count_, target_value_, and upper_bound_.

183  {
184  return makeExpr<WidthBucketExpr>(target_value_->deep_copy(),
185  lower_bound_->deep_copy(),
186  upper_bound_->deep_copy(),
187  partition_count_->deep_copy());
188 }
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249
void Analyzer::WidthBucketExpr::find_expr ( std::function< bool(const Expr *)>  f,
std::list< const Expr * > &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3384 of file Analyzer.cpp.

References Analyzer::Expr::add_unique(), f(), lower_bound_, partition_count_, target_value_, and upper_bound_.

3385  {
3386  if (f(this)) {
3387  add_unique(expr_list);
3388  return;
3389  }
3390  target_value_->find_expr(f, expr_list);
3391  lower_bound_->find_expr(f, expr_list);
3392  upper_bound_->find_expr(f, expr_list);
3393  partition_count_->find_expr(f, expr_list);
3394 }
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:3248
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249

+ Here is the call graph for this function:

double Analyzer::WidthBucketExpr::get_bound_val ( const Analyzer::Expr bound_expr) const

Definition at line 3936 of file Analyzer.cpp.

References CHECK, Analyzer::Expr::deep_copy(), and kDOUBLE.

Referenced by CodeGenerator::codegenConstantWidthBucketExpr(), and compute_bucket().

3936  {
3937  CHECK(bound_expr);
3938  auto copied_expr = bound_expr->deep_copy();
3939  auto casted_expr = copied_expr->add_cast(SQLTypeInfo(kDOUBLE, false));
3940  CHECK(casted_expr);
3941  auto casted_constant = std::dynamic_pointer_cast<const Analyzer::Constant>(casted_expr);
3942  CHECK(casted_constant);
3943  return casted_constant->get_constval().doubleval;
3944 }
virtual std::shared_ptr< Analyzer::Expr > deep_copy() const =0
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Expr* Analyzer::WidthBucketExpr::get_lower_bound ( ) const
inline

Definition at line 1199 of file Analyzer.h.

References lower_bound_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenConstantWidthBucketExpr(), CodeGenerator::codegenWidthBucketExpr(), operator==(), DeepCopyVisitor::visitWidthBucket(), and ScalarExprVisitor< std::set< shared::TableKey > >::visitWidthBucket().

1199 { return lower_bound_.get(); }
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250

+ Here is the caller graph for this function:

const Expr* Analyzer::WidthBucketExpr::get_partition_count ( ) const
inline

Definition at line 1201 of file Analyzer.h.

References partition_count_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenConstantWidthBucketExpr(), CodeGenerator::codegenWidthBucketExpr(), getExpressionRange(), operator==(), DeepCopyVisitor::visitWidthBucket(), and ScalarExprVisitor< std::set< shared::TableKey > >::visitWidthBucket().

1201 { return partition_count_.get(); }
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252

+ Here is the caller graph for this function:

int32_t Analyzer::WidthBucketExpr::get_partition_count_val ( ) const

Definition at line 3946 of file Analyzer.cpp.

References Analyzer::Constant::get_constval(), kBIGINT, kINT, kSMALLINT, kTINYINT, and partition_count_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenConstantWidthBucketExpr(), compute_bucket(), and getExpressionRange().

3946  {
3947  auto const_partition_count_expr =
3948  dynamic_cast<const Analyzer::Constant*>(partition_count_.get());
3949  if (!const_partition_count_expr) {
3950  return -1;
3951  }
3952  auto d = const_partition_count_expr->get_constval();
3953  switch (const_partition_count_expr->get_type_info().get_type()) {
3954  case kTINYINT:
3955  return d.tinyintval;
3956  case kSMALLINT:
3957  return d.smallintval;
3958  case kINT:
3959  return d.intval;
3960  case kBIGINT: {
3961  auto bi = d.bigintval;
3962  if (bi < 1 || bi > INT32_MAX) {
3963  return -1;
3964  }
3965  return bi;
3966  }
3967  default:
3968  return -1;
3969  }
3970 }
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
Datum get_constval() const
Definition: Analyzer.h:348
Definition: sqltypes.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Expr* Analyzer::WidthBucketExpr::get_target_value ( ) const
inline

Definition at line 1198 of file Analyzer.h.

References target_value_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenConstantWidthBucketExpr(), CodeGenerator::codegenWidthBucketExpr(), getExpressionRange(), operator==(), DeepCopyVisitor::visitWidthBucket(), and ScalarExprVisitor< std::set< shared::TableKey > >::visitWidthBucket().

1198 { return target_value_.get(); }
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249

+ Here is the caller graph for this function:

const Expr* Analyzer::WidthBucketExpr::get_upper_bound ( ) const
inline

Definition at line 1200 of file Analyzer.h.

References upper_bound_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenConstantWidthBucketExpr(), CodeGenerator::codegenWidthBucketExpr(), operator==(), DeepCopyVisitor::visitWidthBucket(), and ScalarExprVisitor< std::set< shared::TableKey > >::visitWidthBucket().

1200 { return upper_bound_.get(); }
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251

+ Here is the caller graph for this function:

void Analyzer::WidthBucketExpr::group_predicates ( std::list< const Expr * > &  scan_predicates,
std::list< const Expr * > &  join_predicates,
std::list< const Expr * > &  const_predicates 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1843 of file Analyzer.cpp.

References target_value_.

1845  {
1846  std::set<int> rte_idx_set;
1847  target_value_->collect_rte_idx(rte_idx_set);
1848  if (rte_idx_set.size() > 1) {
1849  join_predicates.push_back(this);
1850  } else if (rte_idx_set.size() == 1) {
1851  scan_predicates.push_back(this);
1852  } else {
1853  const_predicates.push_back(this);
1854  }
1855 }
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249
bool Analyzer::WidthBucketExpr::is_constant_expr ( ) const
inline

Definition at line 1246 of file Analyzer.h.

References constant_expr_.

Referenced by CodeGenerator::codegen(), and getExpressionRange().

1246 { return constant_expr_; }

+ Here is the caller graph for this function:

bool Analyzer::WidthBucketExpr::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2505 of file Analyzer.cpp.

References get_lower_bound(), get_partition_count(), get_target_value(), get_upper_bound(), lower_bound_, partition_count_, target_value_, and upper_bound_.

2505  {
2506  if (typeid(rhs) != typeid(WidthBucketExpr)) {
2507  return false;
2508  }
2509  const WidthBucketExpr& rhs_l = dynamic_cast<const WidthBucketExpr&>(rhs);
2510  if (!(*target_value_ == *rhs_l.get_target_value())) {
2511  return false;
2512  }
2513  if (!(*lower_bound_ == *rhs_l.get_lower_bound())) {
2514  return false;
2515  }
2516  if (!(*upper_bound_ == *rhs_l.get_upper_bound())) {
2517  return false;
2518  }
2519  if (!(*partition_count_ == *rhs_l.get_partition_count())) {
2520  return false;
2521  }
2522  return true;
2523 }
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
WidthBucketExpr(const std::shared_ptr< Analyzer::Expr > target_value, const std::shared_ptr< Analyzer::Expr > lower_bound, const std::shared_ptr< Analyzer::Expr > upper_bound, const std::shared_ptr< Analyzer::Expr > partition_count)
Definition: Analyzer.h:1187
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249

+ Here is the call graph for this function:

std::shared_ptr<Analyzer::Expr> Analyzer::WidthBucketExpr::rewrite_agg_to_var ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1229 of file Analyzer.h.

References lower_bound_, partition_count_, target_value_, and upper_bound_.

1230  {
1231  return makeExpr<WidthBucketExpr>(target_value_->rewrite_agg_to_var(tlist),
1232  lower_bound_,
1233  upper_bound_,
1235  }
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249
std::shared_ptr<Analyzer::Expr> Analyzer::WidthBucketExpr::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1222 of file Analyzer.h.

References lower_bound_, partition_count_, target_value_, and upper_bound_.

1223  {
1224  return makeExpr<WidthBucketExpr>(target_value_->rewrite_with_child_targetlist(tlist),
1225  lower_bound_,
1226  upper_bound_,
1228  }
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249
std::shared_ptr<Analyzer::Expr> Analyzer::WidthBucketExpr::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1215 of file Analyzer.h.

References lower_bound_, partition_count_, target_value_, and upper_bound_.

1216  {
1217  return makeExpr<WidthBucketExpr>(target_value_->rewrite_with_targetlist(tlist),
1218  lower_bound_,
1219  upper_bound_,
1221  }
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249
void Analyzer::WidthBucketExpr::set_constant_expr ( ) const
inline

Definition at line 1245 of file Analyzer.h.

References constant_expr_.

Referenced by CodeGenerator::codegen().

1245 { constant_expr_ = true; }

+ Here is the caller graph for this function:

void Analyzer::WidthBucketExpr::skip_out_of_bound_check ( ) const
inline

Definition at line 1244 of file Analyzer.h.

References skip_out_of_bound_check_.

Referenced by CodeGenerator::codegen().

1244 { skip_out_of_bound_check_ = true; }

+ Here is the caller graph for this function:

std::string Analyzer::WidthBucketExpr::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 3000 of file Analyzer.cpp.

References lower_bound_, partition_count_, target_value_, and upper_bound_.

3000  {
3001  std::string str{"(WIDTH_BUCKET "};
3002  str += target_value_->toString();
3003  str += lower_bound_->toString();
3004  str += upper_bound_->toString();
3005  str += partition_count_->toString();
3006  return str + ") ";
3007 }
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1252
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1250
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1249

Member Data Documentation

bool Analyzer::WidthBucketExpr::constant_expr_
mutableprivate

Definition at line 1254 of file Analyzer.h.

Referenced by is_constant_expr(), and set_constant_expr().

std::shared_ptr<Analyzer::Expr> Analyzer::WidthBucketExpr::lower_bound_
private
std::shared_ptr<Analyzer::Expr> Analyzer::WidthBucketExpr::partition_count_
private
bool Analyzer::WidthBucketExpr::skip_out_of_bound_check_
mutableprivate

Definition at line 1256 of file Analyzer.h.

Referenced by can_skip_out_of_bound_check(), and skip_out_of_bound_check().

std::shared_ptr<Analyzer::Expr> Analyzer::WidthBucketExpr::upper_bound_
private

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