OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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::Expr
get_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 (std::function< bool(const Expr *)> f, 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::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
 

Protected Attributes

SQLOps optype
 
std::shared_ptr< Analyzer::Exproperand
 
- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 371 of file Analyzer.h.

Constructor & Destructor Documentation

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

Definition at line 373 of file Analyzer.h.

374  : Expr(ti, has_agg), optype(o), operand(p) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:74
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
SQLOps optype
Definition: Analyzer.h:419
Analyzer::UOper::UOper ( SQLTypes  t,
SQLOps  o,
std::shared_ptr< Analyzer::Expr p 
)
inline

Definition at line 375 of file Analyzer.h.

376  : Expr(t, o == kISNULL ? true : p->get_type_info().get_notnull())
377  , optype(o)
378  , operand(p) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:74
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
SQLOps optype
Definition: Analyzer.h:419

Member Function Documentation

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

Reimplemented from Analyzer::Expr.

Definition at line 1401 of file Analyzer.cpp.

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

1401  {
1402  if (optype != kCAST) {
1403  return Expr::add_cast(new_type_info);
1404  }
1405  if (type_info.is_string() && new_type_info.is_string() &&
1406  new_type_info.get_compression() == kENCODING_DICT &&
1408  const SQLTypeInfo oti = operand->get_type_info();
1409  if (oti.is_string() && oti.get_compression() == kENCODING_DICT &&
1410  (oti.get_comp_param() == new_type_info.get_comp_param() ||
1411  oti.get_comp_param() == TRANSIENT_DICT(new_type_info.get_comp_param()))) {
1412  auto result = operand;
1413  operand = nullptr;
1414  return result;
1415  }
1416  }
1417  return Expr::add_cast(new_type_info);
1418 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
Definition: sqldefs.h:48
SQLTypeInfo type_info
Definition: Analyzer.h:184
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
virtual std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:728
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:389
bool is_string() const
Definition: sqltypes.h:576
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:311
SQLOps optype
Definition: Analyzer.h:419

+ Here is the call graph for this function:

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

Reimplemented from Analyzer::Expr.

Definition at line 1490 of file Analyzer.cpp.

References operand.

1491  {
1492  operand->check_group_by(groupby);
1493 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
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 391 of file Analyzer.h.

References operand.

394  {
395  operand->collect_column_var(colvar_set, include_agg);
396  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
void Analyzer::UOper::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 388 of file Analyzer.h.

References operand.

388  {
389  operand->collect_rte_idx(rte_idx_set);
390  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
std::shared_ptr< Analyzer::Expr > Analyzer::UOper::deep_copy ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 102 of file Analyzer.cpp.

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

102  {
103  return makeExpr<UOper>(type_info, contains_agg, optype, operand->deep_copy());
104 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
SQLTypeInfo type_info
Definition: Analyzer.h:184
bool contains_agg
Definition: Analyzer.h:185
SQLOps optype
Definition: Analyzer.h:419
void Analyzer::UOper::find_expr ( std::function< bool(const Expr *)>  f,
std::list< const Expr * > &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3121 of file Analyzer.cpp.

References Analyzer::Expr::add_unique(), anonymous_namespace{Utm.h}::f, and operand.

3122  {
3123  if (f(this)) {
3124  add_unique(expr_list);
3125  return;
3126  }
3127  operand->find_expr(f, expr_list);
3128 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:3101
constexpr double f
Definition: Utm.h:31

+ Here is the call graph for this function:

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

Definition at line 381 of file Analyzer.h.

References operand.

Referenced by remove_cast().

381 { return operand; }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420

+ Here is the caller graph for this function:

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 1585 of file Analyzer.cpp.

References operand.

1587  {
1588  std::set<int> rte_idx_set;
1589  operand->collect_rte_idx(rte_idx_set);
1590  if (rte_idx_set.size() > 1) {
1591  join_predicates.push_back(this);
1592  } else if (rte_idx_set.size() == 1) {
1593  scan_predicates.push_back(this);
1594  } else {
1595  const_predicates.push_back(this);
1596  }
1597 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
bool Analyzer::UOper::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2279 of file Analyzer.cpp.

References get_operand(), get_optype(), operand, and optype.

2279  {
2280  if (typeid(rhs) != typeid(UOper)) {
2281  return false;
2282  }
2283  const UOper& rhs_uo = dynamic_cast<const UOper&>(rhs);
2284  return optype == rhs_uo.get_optype() && *operand == *rhs_uo.get_operand();
2285 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
UOper(const SQLTypeInfo &ti, bool has_agg, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:373
SQLOps optype
Definition: Analyzer.h:419

+ Here is the call graph for this function:

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 407 of file Analyzer.h.

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

408  {
409  return makeExpr<UOper>(
410  type_info, contains_agg, optype, operand->rewrite_agg_to_var(tlist));
411  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
SQLTypeInfo type_info
Definition: Analyzer.h:184
bool contains_agg
Definition: Analyzer.h:185
SQLOps optype
Definition: Analyzer.h:419
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 402 of file Analyzer.h.

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

403  {
404  return makeExpr<UOper>(
405  type_info, contains_agg, optype, operand->rewrite_with_child_targetlist(tlist));
406  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
SQLTypeInfo type_info
Definition: Analyzer.h:184
bool contains_agg
Definition: Analyzer.h:185
SQLOps optype
Definition: Analyzer.h:419
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 397 of file Analyzer.h.

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

398  {
399  return makeExpr<UOper>(
400  type_info, contains_agg, optype, operand->rewrite_with_targetlist(tlist));
401  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
SQLTypeInfo type_info
Definition: Analyzer.h:184
bool contains_agg
Definition: Analyzer.h:185
SQLOps optype
Definition: Analyzer.h:419
std::string Analyzer::UOper::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2637 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, operand, optype, to_string(), and Analyzer::Expr::type_info.

2637  {
2638  std::string op;
2639  switch (optype) {
2640  case kNOT:
2641  op = "NOT ";
2642  break;
2643  case kUMINUS:
2644  op = "- ";
2645  break;
2646  case kISNULL:
2647  op = "IS NULL ";
2648  break;
2649  case kEXISTS:
2650  op = "EXISTS ";
2651  break;
2652  case kCAST:
2653  op = "CAST " + type_info.get_type_name() + "(" +
2655  std::to_string(type_info.get_scale()) + ") " +
2658  break;
2659  case kUNNEST:
2660  op = "UNNEST ";
2661  break;
2662  default:
2663  break;
2664  }
2665  return "(" + op + operand->toString() + ") ";
2666 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:420
HOST DEVICE int get_scale() const
Definition: sqltypes.h:385
std::string get_compression_name() const
Definition: sqltypes.h:542
Definition: sqldefs.h:48
SQLTypeInfo type_info
Definition: Analyzer.h:184
std::string to_string(char const *&&v)
int get_precision() const
Definition: sqltypes.h:383
std::string get_type_name() const
Definition: sqltypes.h:504
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:389
Definition: sqldefs.h:38
SQLOps optype
Definition: Analyzer.h:419

+ Here is the call graph for this function:

Member Data Documentation

SQLOps Analyzer::UOper::optype
protected

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