OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 (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::Expr
normalize_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 356 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 358 of file Analyzer.h.

359  : 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:405
SQLOps optype
Definition: Analyzer.h:404
Analyzer::UOper::UOper ( SQLTypes  t,
SQLOps  o,
std::shared_ptr< Analyzer::Expr p 
)
inline

Definition at line 360 of file Analyzer.h.

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

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 1212 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, operand, optype, run_benchmark_import::result, TRANSIENT_DICT, and Analyzer::Expr::type_info.

1212  {
1213  if (optype != kCAST) {
1214  return Expr::add_cast(new_type_info);
1215  }
1216  if (type_info.is_string() && new_type_info.is_string() &&
1217  new_type_info.get_compression() == kENCODING_DICT &&
1219  const SQLTypeInfo oti = operand->get_type_info();
1220  if (oti.is_string() && oti.get_compression() == kENCODING_DICT &&
1221  (oti.get_comp_param() == new_type_info.get_comp_param() ||
1222  oti.get_comp_param() == TRANSIENT_DICT(new_type_info.get_comp_param()))) {
1223  auto result = operand;
1224  operand = nullptr;
1225  return result;
1226  }
1227  }
1228  return Expr::add_cast(new_type_info);
1229 }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:335
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
Definition: sqldefs.h:49
SQLTypeInfo type_info
Definition: Analyzer.h:176
virtual std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:671
bool is_string() const
Definition: sqltypes.h:477
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:190
SQLOps optype
Definition: Analyzer.h:404

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

References operand.

1302  {
1303  operand->check_group_by(groupby);
1304 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
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 376 of file Analyzer.h.

References operand.

379  {
380  operand->collect_column_var(colvar_set, include_agg);
381  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
void Analyzer::UOper::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 373 of file Analyzer.h.

References operand.

373  {
374  operand->collect_rte_idx(rte_idx_set);
375  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
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, operand, optype, 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:405
SQLTypeInfo type_info
Definition: Analyzer.h:176
bool contains_agg
Definition: Analyzer.h:177
SQLOps optype
Definition: Analyzer.h:404
void Analyzer::UOper::find_expr ( bool(*)(const Expr *)  f,
std::list< const Expr * > &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 2658 of file Analyzer.cpp.

References Analyzer::Expr::add_unique(), and operand.

2658  {
2659  if (f(this)) {
2660  add_unique(expr_list);
2661  return;
2662  }
2663  operand->find_expr(f, expr_list);
2664 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:2639

+ Here is the call graph for this function:

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

Definition at line 366 of file Analyzer.h.

References operand.

Referenced by remove_cast().

366 { return operand; }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405

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

References operand.

1398  {
1399  std::set<int> rte_idx_set;
1400  operand->collect_rte_idx(rte_idx_set);
1401  if (rte_idx_set.size() > 1) {
1402  join_predicates.push_back(this);
1403  } else if (rte_idx_set.size() == 1) {
1404  scan_predicates.push_back(this);
1405  } else {
1406  const_predicates.push_back(this);
1407  }
1408 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
bool Analyzer::UOper::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2031 of file Analyzer.cpp.

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

2031  {
2032  if (typeid(rhs) != typeid(UOper)) {
2033  return false;
2034  }
2035  const UOper& rhs_uo = dynamic_cast<const UOper&>(rhs);
2036  return optype == rhs_uo.get_optype() && *operand == *rhs_uo.get_operand();
2037 }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
UOper(const SQLTypeInfo &ti, bool has_agg, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:358
SQLOps optype
Definition: Analyzer.h:404

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

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

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

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

388  {
389  return makeExpr<UOper>(
390  type_info, contains_agg, optype, operand->rewrite_with_child_targetlist(tlist));
391  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
SQLTypeInfo type_info
Definition: Analyzer.h:176
bool contains_agg
Definition: Analyzer.h:177
SQLOps optype
Definition: Analyzer.h:404
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 382 of file Analyzer.h.

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

383  {
384  return makeExpr<UOper>(
385  type_info, contains_agg, optype, operand->rewrite_with_targetlist(tlist));
386  }
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
SQLTypeInfo type_info
Definition: Analyzer.h:176
bool contains_agg
Definition: Analyzer.h:177
SQLOps optype
Definition: Analyzer.h:404
std::string Analyzer::UOper::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

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

2318  {
2319  std::string op;
2320  switch (optype) {
2321  case kNOT:
2322  op = "NOT ";
2323  break;
2324  case kUMINUS:
2325  op = "- ";
2326  break;
2327  case kISNULL:
2328  op = "IS NULL ";
2329  break;
2330  case kEXISTS:
2331  op = "EXISTS ";
2332  break;
2333  case kCAST:
2334  op = "CAST " + type_info.get_type_name() + "(" +
2336  std::to_string(type_info.get_scale()) + ") " +
2339  break;
2340  case kUNNEST:
2341  op = "UNNEST ";
2342  break;
2343  default:
2344  break;
2345  }
2346  return "(" + op + operand->toString() + ") ";
2347 }
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:335
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:405
HOST DEVICE int get_scale() const
Definition: sqltypes.h:331
Definition: sqldefs.h:49
SQLTypeInfo type_info
Definition: Analyzer.h:176
std::string to_string(char const *&&v)
std::string get_type_name() const
Definition: sqltypes.h:429
int get_precision() const
Definition: sqltypes.h:329
Definition: sqldefs.h:39
SQLOps optype
Definition: Analyzer.h:404
std::string get_compression_name() const
Definition: sqltypes.h:454

+ Here is the call graph for this function:

Member Data Documentation


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