OmniSciDB  dfae7c3b14
Analyzer::UOper Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::UOper:
+ Collaboration diagram for Analyzer::UOper:

Public Member Functions

 UOper (const SQLTypeInfo &ti, bool has_agg, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
 
 UOper (SQLTypes t, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
 
SQLOps get_optype () const
 
const Exprget_operand () const
 
const std::shared_ptr< Analyzer::Exprget_own_operand () const
 
void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
 
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
 
bool operator== (const Expr &rhs) const override
 
std::string toString () const override
 
void find_expr (bool(*f)(const Expr *), std::list< const Expr *> &expr_list) const override
 
std::shared_ptr< Analyzer::Expradd_cast (const SQLTypeInfo &new_type_info) override
 
- 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::Exprnormalize_simple_predicate (int &rte_idx) 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

SQLOps optype
 
std::shared_ptr< Analyzer::Exproperand
 

Additional Inherited Members

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

Detailed Description

Definition at line 362 of file Analyzer.h.

Constructor & Destructor Documentation

◆ UOper() [1/2]

Analyzer::UOper::UOper ( const SQLTypeInfo ti,
bool  has_agg,
SQLOps  o,
std::shared_ptr< Analyzer::Expr p 
)
inline

Definition at line 364 of file Analyzer.h.

365  : Expr(ti, has_agg), optype(o), operand(p) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
SQLOps optype
Definition: Analyzer.h:410

◆ UOper() [2/2]

Analyzer::UOper::UOper ( SQLTypes  t,
SQLOps  o,
std::shared_ptr< Analyzer::Expr p 
)
inline

Definition at line 366 of file Analyzer.h.

367  : Expr(t, o == kISNULL ? true : p->get_type_info().get_notnull())
368  , optype(o)
369  , operand(p) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
SQLOps optype
Definition: Analyzer.h:410

Member Function Documentation

◆ add_cast()

std::shared_ptr< Analyzer::Expr > Analyzer::UOper::add_cast ( const SQLTypeInfo new_type_info)
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1287 of file Analyzer.cpp.

References Analyzer::Expr::add_cast(), SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::is_string(), kCAST, kENCODING_DICT, kENCODING_NONE, run_benchmark_import::result, TRANSIENT_DICT, and Analyzer::Expr::type_info.

1287  {
1288  if (optype != kCAST) {
1289  return Expr::add_cast(new_type_info);
1290  }
1291  if (type_info.is_string() && new_type_info.is_string() &&
1292  new_type_info.get_compression() == kENCODING_DICT &&
1294  const SQLTypeInfo oti = operand->get_type_info();
1295  if (oti.is_string() && oti.get_compression() == kENCODING_DICT &&
1296  (oti.get_comp_param() == new_type_info.get_comp_param() ||
1297  oti.get_comp_param() == TRANSIENT_DICT(new_type_info.get_comp_param()))) {
1298  auto result = operand;
1299  operand = nullptr;
1300  return result;
1301  }
1302  }
1303  return Expr::add_cast(new_type_info);
1304 }
bool is_string() const
Definition: sqltypes.h:417
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:268
Definition: sqldefs.h:49
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:267
SQLTypeInfo type_info
Definition: Analyzer.h:176
virtual std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:689
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:199
SQLOps optype
Definition: Analyzer.h:410
+ Here is the call graph for this function:

◆ check_group_by()

void Analyzer::UOper::check_group_by ( const std::list< std::shared_ptr< Analyzer::Expr >> &  groupby) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1376 of file Analyzer.cpp.

1377  {
1378  operand->check_group_by(groupby);
1379 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411

◆ collect_column_var()

void Analyzer::UOper::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 382 of file Analyzer.h.

385  {
386  operand->collect_column_var(colvar_set, include_agg);
387  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411

◆ collect_rte_idx()

void Analyzer::UOper::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 379 of file Analyzer.h.

379  {
380  operand->collect_rte_idx(rte_idx_set);
381  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411

◆ deep_copy()

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

Implements Analyzer::Expr.

Definition at line 95 of file Analyzer.cpp.

References Analyzer::Expr::contains_agg, and Analyzer::Expr::type_info.

95  {
96  return makeExpr<UOper>(type_info, contains_agg, optype, operand->deep_copy());
97 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
SQLTypeInfo type_info
Definition: Analyzer.h:176
bool contains_agg
Definition: Analyzer.h:177
SQLOps optype
Definition: Analyzer.h:410

◆ find_expr()

void Analyzer::UOper::find_expr ( bool(*)(const Expr *)  f,
std::list< const Expr *> &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 2834 of file Analyzer.cpp.

References Analyzer::Expr::add_unique().

2834  {
2835  if (f(this)) {
2836  add_unique(expr_list);
2837  return;
2838  }
2839  operand->find_expr(f, expr_list);
2840 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
virtual void add_unique(std::list< const Expr *> &expr_list) const
Definition: Analyzer.cpp:2815
+ Here is the call graph for this function:

◆ get_operand()

◆ get_optype()

SQLOps Analyzer::UOper::get_optype ( ) const
inline

◆ get_own_operand()

const std::shared_ptr<Analyzer::Expr> Analyzer::UOper::get_own_operand ( ) const
inline

Definition at line 372 of file Analyzer.h.

Referenced by remove_cast().

372 { return operand; }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
+ Here is the caller graph for this function:

◆ group_predicates()

void Analyzer::UOper::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 1471 of file Analyzer.cpp.

1473  {
1474  std::set<int> rte_idx_set;
1475  operand->collect_rte_idx(rte_idx_set);
1476  if (rte_idx_set.size() > 1) {
1477  join_predicates.push_back(this);
1478  } else if (rte_idx_set.size() == 1) {
1479  scan_predicates.push_back(this);
1480  } else {
1481  const_predicates.push_back(this);
1482  }
1483 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411

◆ operator==()

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

Implements Analyzer::Expr.

Definition at line 2120 of file Analyzer.cpp.

References get_operand(), and get_optype().

2120  {
2121  if (typeid(rhs) != typeid(UOper)) {
2122  return false;
2123  }
2124  const UOper& rhs_uo = dynamic_cast<const UOper&>(rhs);
2125  return optype == rhs_uo.get_optype() && *operand == *rhs_uo.get_operand();
2126 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
UOper(const SQLTypeInfo &ti, bool has_agg, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:364
SQLOps optype
Definition: Analyzer.h:410
+ Here is the call graph for this function:

◆ rewrite_agg_to_var()

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

Reimplemented from Analyzer::Expr.

Definition at line 398 of file Analyzer.h.

References operator==(), and toString().

399  {
400  return makeExpr<UOper>(
401  type_info, contains_agg, optype, operand->rewrite_agg_to_var(tlist));
402  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
SQLTypeInfo type_info
Definition: Analyzer.h:176
bool contains_agg
Definition: Analyzer.h:177
SQLOps optype
Definition: Analyzer.h:410
+ Here is the call graph for this function:

◆ rewrite_with_child_targetlist()

std::shared_ptr<Analyzer::Expr> Analyzer::UOper::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 393 of file Analyzer.h.

394  {
395  return makeExpr<UOper>(
396  type_info, contains_agg, optype, operand->rewrite_with_child_targetlist(tlist));
397  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
SQLTypeInfo type_info
Definition: Analyzer.h:176
bool contains_agg
Definition: Analyzer.h:177
SQLOps optype
Definition: Analyzer.h:410

◆ rewrite_with_targetlist()

std::shared_ptr<Analyzer::Expr> Analyzer::UOper::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 388 of file Analyzer.h.

389  {
390  return makeExpr<UOper>(
391  type_info, contains_agg, optype, operand->rewrite_with_targetlist(tlist));
392  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
SQLTypeInfo type_info
Definition: Analyzer.h:176
bool contains_agg
Definition: Analyzer.h:177
SQLOps optype
Definition: Analyzer.h:410

◆ toString()

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

Implements Analyzer::Expr.

Definition at line 2440 of file Analyzer.cpp.

References SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression_name(), SQLTypeInfo::get_precision(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_type_name(), kCAST, kEXISTS, kISNULL, kNOT, kUMINUS, kUNNEST, to_string(), and Analyzer::Expr::type_info.

2440  {
2441  std::string op;
2442  switch (optype) {
2443  case kNOT:
2444  op = "NOT ";
2445  break;
2446  case kUMINUS:
2447  op = "- ";
2448  break;
2449  case kISNULL:
2450  op = "IS NULL ";
2451  break;
2452  case kEXISTS:
2453  op = "EXISTS ";
2454  break;
2455  case kCAST:
2456  op = "CAST " + type_info.get_type_name() + "(" +
2458  std::to_string(type_info.get_scale()) + ") " +
2461  break;
2462  case kUNNEST:
2463  op = "UNNEST ";
2464  break;
2465  default:
2466  break;
2467  }
2468  return "(" + op + operand->toString() + ") ";
2469 }
int get_precision() const
Definition: sqltypes.h:262
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:411
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:268
Definition: sqldefs.h:49
SQLTypeInfo type_info
Definition: Analyzer.h:176
HOST DEVICE int get_scale() const
Definition: sqltypes.h:264
std::string to_string(char const *&&v)
std::string get_compression_name() const
Definition: sqltypes.h:394
std::string get_type_name() const
Definition: sqltypes.h:362
Definition: sqldefs.h:39
SQLOps optype
Definition: Analyzer.h:410
+ Here is the call graph for this function:

Member Data Documentation

◆ operand

std::shared_ptr<Analyzer::Expr> Analyzer::UOper::operand
private

Definition at line 411 of file Analyzer.h.

◆ optype

SQLOps Analyzer::UOper::optype
private

Definition at line 410 of file Analyzer.h.


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