OmniSciDB  04ee39c94c
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 ()
 
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 355 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 357 of file Analyzer.h.

358  : 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:404
SQLOps optype
Definition: Analyzer.h:403

◆ UOper() [2/2]

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

Definition at line 359 of file Analyzer.h.

360  : Expr(t, o == kISNULL ? true : p->get_type_info().get_notnull())
361  , optype(o)
362  , operand(p) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
SQLOps optype
Definition: Analyzer.h:403

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

References Analyzer::Expr::add_cast(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_comp_param(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_string(), kCAST, kENCODING_DICT, kENCODING_NONE, run-benchmark-import::result, TRANSIENT_DICT, and Analyzer::Expr::type_info.

1204  {
1205  if (optype != kCAST) {
1206  return Expr::add_cast(new_type_info);
1207  }
1208  if (type_info.is_string() && new_type_info.is_string() &&
1209  new_type_info.get_compression() == kENCODING_DICT &&
1211  const SQLTypeInfo oti = operand->get_type_info();
1212  if (oti.is_string() && oti.get_compression() == kENCODING_DICT &&
1213  (oti.get_comp_param() == new_type_info.get_comp_param() ||
1214  oti.get_comp_param() == TRANSIENT_DICT(new_type_info.get_comp_param()))) {
1215  auto result = operand;
1216  operand = nullptr;
1217  return result;
1218  }
1219  }
1220  return Expr::add_cast(new_type_info);
1221 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
Definition: sqldefs.h:49
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
SQLTypeInfo type_info
Definition: Analyzer.h:175
virtual std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:663
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:332
bool is_string() const
Definition: sqltypes.h:450
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:187
SQLOps optype
Definition: Analyzer.h:403
+ 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 1293 of file Analyzer.cpp.

1294  {
1295  operand->check_group_by(groupby);
1296 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404

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

378  {
379  operand->collect_column_var(colvar_set, include_agg);
380  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404

◆ collect_rte_idx()

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

Reimplemented from Analyzer::Expr.

Definition at line 372 of file Analyzer.h.

372  {
373  operand->collect_rte_idx(rte_idx_set);
374  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404

◆ 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:404
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176
SQLOps optype
Definition: Analyzer.h:403

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

References Analyzer::Expr::add_unique().

2604  {
2605  if (f(this)) {
2606  add_unique(expr_list);
2607  return;
2608  }
2609  operand->find_expr(f, expr_list);
2610 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
virtual void add_unique(std::list< const Expr *> &expr_list) const
Definition: Analyzer.cpp:2585
+ 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 365 of file Analyzer.h.

Referenced by remove_cast().

365 { return operand; }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
+ 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 1388 of file Analyzer.cpp.

1390  {
1391  std::set<int> rte_idx_set;
1392  operand->collect_rte_idx(rte_idx_set);
1393  if (rte_idx_set.size() > 1) {
1394  join_predicates.push_back(this);
1395  } else if (rte_idx_set.size() == 1) {
1396  scan_predicates.push_back(this);
1397  } else {
1398  const_predicates.push_back(this);
1399  }
1400 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404

◆ operator==()

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

Implements Analyzer::Expr.

Definition at line 2009 of file Analyzer.cpp.

References get_operand(), and get_optype().

2009  {
2010  if (typeid(rhs) != typeid(UOper)) {
2011  return false;
2012  }
2013  const UOper& rhs_uo = dynamic_cast<const UOper&>(rhs);
2014  return optype == rhs_uo.get_optype() && *operand == *rhs_uo.get_operand();
2015 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
UOper(const SQLTypeInfo &ti, bool has_agg, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:357
SQLOps optype
Definition: Analyzer.h:403
+ 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 391 of file Analyzer.h.

References operator==().

392  {
393  return makeExpr<UOper>(
394  type_info, contains_agg, optype, operand->rewrite_agg_to_var(tlist));
395  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176
SQLOps optype
Definition: Analyzer.h:403
+ 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 386 of file Analyzer.h.

387  {
388  return makeExpr<UOper>(
389  type_info, contains_agg, optype, operand->rewrite_with_child_targetlist(tlist));
390  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176
SQLOps optype
Definition: Analyzer.h:403

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

382  {
383  return makeExpr<UOper>(
384  type_info, contains_agg, optype, operand->rewrite_with_targetlist(tlist));
385  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176
SQLOps optype
Definition: Analyzer.h:403

◆ toString()

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

Implements Analyzer::Expr.

Definition at line 2277 of file Analyzer.cpp.

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

2277  {
2278  std::string op;
2279  switch (optype) {
2280  case kNOT:
2281  op = "NOT ";
2282  break;
2283  case kUMINUS:
2284  op = "- ";
2285  break;
2286  case kISNULL:
2287  op = "IS NULL ";
2288  break;
2289  case kEXISTS:
2290  op = "EXISTS ";
2291  break;
2292  case kCAST:
2293  op = "CAST " + type_info.get_type_name() + "(" +
2295  std::to_string(type_info.get_scale()) + ") " +
2298  break;
2299  case kUNNEST:
2300  op = "UNNEST ";
2301  break;
2302  default:
2303  break;
2304  }
2305  return "(" + op + operand->toString() + ") ";
2306 }
int get_precision() const
Definition: sqltypes.h:326
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:404
HOST DEVICE int get_scale() const
Definition: sqltypes.h:328
Definition: sqldefs.h:49
std::string get_compression_name() const
Definition: sqltypes.h:448
SQLTypeInfo type_info
Definition: Analyzer.h:175
std::string to_string(char const *&&v)
std::string get_type_name() const
Definition: sqltypes.h:426
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:332
Definition: sqldefs.h:39
SQLOps optype
Definition: Analyzer.h:403
+ Here is the call graph for this function:

Member Data Documentation

◆ operand

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

Definition at line 404 of file Analyzer.h.

◆ optype

SQLOps Analyzer::UOper::optype
private

Definition at line 403 of file Analyzer.h.


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