OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analyzer::LikeExpr Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::LikeExpr:
+ Collaboration diagram for Analyzer::LikeExpr:

Public Member Functions

 LikeExpr (std::shared_ptr< Analyzer::Expr > a, std::shared_ptr< Analyzer::Expr > l, std::shared_ptr< Analyzer::Expr > e, bool i, bool s)
 
const Exprget_arg () const
 
const std::shared_ptr
< Analyzer::Expr
get_own_arg () const
 
const Exprget_like_expr () const
 
const Exprget_escape_expr () const
 
bool get_is_ilike () const
 
bool get_is_simple () 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
 
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
 
- 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::Exprarg
 
std::shared_ptr< Analyzer::Exprlike_expr
 
std::shared_ptr< Analyzer::Exprescape_expr
 
bool is_ilike
 
bool is_simple
 

Additional Inherited Members

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

Detailed Description

Definition at line 1048 of file Analyzer.h.

Constructor & Destructor Documentation

Analyzer::LikeExpr::LikeExpr ( std::shared_ptr< Analyzer::Expr a,
std::shared_ptr< Analyzer::Expr l,
std::shared_ptr< Analyzer::Expr e,
bool  i,
bool  s 
)
inline

Definition at line 1050 of file Analyzer.h.

1055  : Expr(kBOOLEAN, a->get_type_info().get_notnull())
1056  , arg(a)
1057  , like_expr(l)
1058  , escape_expr(e)
1059  , is_ilike(i)
1060  , is_simple(s) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
constexpr double a
Definition: Utm.h:32
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113

Member Function Documentation

void Analyzer::LikeExpr::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 1074 of file Analyzer.h.

References arg.

1077  {
1078  arg->collect_column_var(colvar_set, include_agg);
1079  }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
void Analyzer::LikeExpr::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1071 of file Analyzer.h.

References arg.

1071  {
1072  arg->collect_rte_idx(rte_idx_set);
1073  }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
std::shared_ptr< Analyzer::Expr > Analyzer::LikeExpr::deep_copy ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 169 of file Analyzer.cpp.

References arg, escape_expr, is_ilike, is_simple, and like_expr.

169  {
170  return makeExpr<LikeExpr>(arg->deep_copy(),
171  like_expr->deep_copy(),
172  escape_expr ? escape_expr->deep_copy() : nullptr,
173  is_ilike,
174  is_simple);
175 }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113
void Analyzer::LikeExpr::find_expr ( std::function< bool(const Expr *)>  f,
std::list< const Expr * > &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3355 of file Analyzer.cpp.

References Analyzer::Expr::add_unique(), arg, escape_expr, f(), and like_expr.

3356  {
3357  if (f(this)) {
3358  add_unique(expr_list);
3359  return;
3360  }
3361  arg->find_expr(f, expr_list);
3362  like_expr->find_expr(f, expr_list);
3363  if (escape_expr != nullptr) {
3364  escape_expr->find_expr(f, expr_list);
3365  }
3366 }
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:3245
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113

+ Here is the call graph for this function:

const Expr* Analyzer::LikeExpr::get_arg ( ) const
inline

Definition at line 1061 of file Analyzer.h.

References arg.

Referenced by CodeGenerator::codegen(), getExpressionRange(), operator==(), ScalarExprToSql::visitLikeExpr(), DeepCopyVisitor::visitLikeExpr(), ScalarExprVisitor< std::set< shared::TableKey > >::visitLikeExpr(), and TextEncodingCastCountVisitor::visitLikeExpr().

1061 { return arg.get(); }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110

+ Here is the caller graph for this function:

const Expr* Analyzer::LikeExpr::get_escape_expr ( ) const
inline

Definition at line 1064 of file Analyzer.h.

References escape_expr.

Referenced by CodeGenerator::codegen(), operator==(), ScalarExprToSql::visitLikeExpr(), DeepCopyVisitor::visitLikeExpr(), ScalarExprVisitor< std::set< shared::TableKey > >::visitLikeExpr(), and TextEncodingCastCountVisitor::visitLikeExpr().

1064 { return escape_expr.get(); }
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113

+ Here is the caller graph for this function:

bool Analyzer::LikeExpr::get_is_ilike ( ) const
inline

Definition at line 1065 of file Analyzer.h.

References is_ilike.

Referenced by CodeGenerator::codegen(), operator==(), and DeepCopyVisitor::visitLikeExpr().

1065 { return is_ilike; }

+ Here is the caller graph for this function:

bool Analyzer::LikeExpr::get_is_simple ( ) const
inline

Definition at line 1066 of file Analyzer.h.

References is_simple.

Referenced by CodeGenerator::codegen(), and DeepCopyVisitor::visitLikeExpr().

1066 { return is_simple; }

+ Here is the caller graph for this function:

const Expr* Analyzer::LikeExpr::get_like_expr ( ) const
inline

Definition at line 1063 of file Analyzer.h.

References like_expr.

Referenced by CodeGenerator::codegen(), operator==(), ScalarExprToSql::visitLikeExpr(), DeepCopyVisitor::visitLikeExpr(), ScalarExprVisitor< std::set< shared::TableKey > >::visitLikeExpr(), and TextEncodingCastCountVisitor::visitLikeExpr().

1063 { return like_expr.get(); }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111

+ Here is the caller graph for this function:

const std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::get_own_arg ( ) const
inline

Definition at line 1062 of file Analyzer.h.

References arg.

Referenced by CodeGenerator::codegen().

1062 { return arg; }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110

+ Here is the caller graph for this function:

void Analyzer::LikeExpr::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 1815 of file Analyzer.cpp.

References arg.

1817  {
1818  std::set<int> rte_idx_set;
1819  arg->collect_rte_idx(rte_idx_set);
1820  if (rte_idx_set.size() > 1) {
1821  join_predicates.push_back(this);
1822  } else if (rte_idx_set.size() == 1) {
1823  scan_predicates.push_back(this);
1824  } else {
1825  const_predicates.push_back(this);
1826  }
1827 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
bool Analyzer::LikeExpr::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2468 of file Analyzer.cpp.

References arg, escape_expr, get_arg(), get_escape_expr(), get_is_ilike(), get_like_expr(), is_ilike, and like_expr.

2468  {
2469  if (typeid(rhs) != typeid(LikeExpr)) {
2470  return false;
2471  }
2472  const LikeExpr& rhs_lk = dynamic_cast<const LikeExpr&>(rhs);
2473  if (!(*arg == *rhs_lk.get_arg()) || !(*like_expr == *rhs_lk.get_like_expr()) ||
2474  is_ilike != rhs_lk.get_is_ilike()) {
2475  return false;
2476  }
2477  if (escape_expr.get() == rhs_lk.get_escape_expr()) {
2478  return true;
2479  }
2480  if (escape_expr != nullptr && rhs_lk.get_escape_expr() != nullptr &&
2481  *escape_expr == *rhs_lk.get_escape_expr()) {
2482  return true;
2483  }
2484  return false;
2485 }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
LikeExpr(std::shared_ptr< Analyzer::Expr > a, std::shared_ptr< Analyzer::Expr > l, std::shared_ptr< Analyzer::Expr > e, bool i, bool s)
Definition: Analyzer.h:1050
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113

+ Here is the call graph for this function:

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

Reimplemented from Analyzer::Expr.

Definition at line 1096 of file Analyzer.h.

References arg, escape_expr, is_ilike, is_simple, and like_expr.

1097  {
1098  return makeExpr<LikeExpr>(arg->rewrite_agg_to_var(tlist),
1099  like_expr->deep_copy(),
1100  escape_expr ? escape_expr->deep_copy() : nullptr,
1101  is_ilike,
1102  is_simple);
1103  }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113
std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1088 of file Analyzer.h.

References arg, escape_expr, is_ilike, is_simple, and like_expr.

1089  {
1090  return makeExpr<LikeExpr>(arg->rewrite_with_child_targetlist(tlist),
1091  like_expr->deep_copy(),
1092  escape_expr ? escape_expr->deep_copy() : nullptr,
1093  is_ilike,
1094  is_simple);
1095  }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113
std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1080 of file Analyzer.h.

References arg, escape_expr, is_ilike, is_simple, and like_expr.

1081  {
1082  return makeExpr<LikeExpr>(arg->rewrite_with_targetlist(tlist),
1083  like_expr->deep_copy(),
1084  escape_expr ? escape_expr->deep_copy() : nullptr,
1085  is_ilike,
1086  is_simple);
1087  }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113
std::string Analyzer::LikeExpr::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2978 of file Analyzer.cpp.

References arg, escape_expr, and like_expr.

2978  {
2979  std::string str{"(LIKE "};
2980  str += arg->toString();
2981  str += like_expr->toString();
2982  if (escape_expr) {
2983  str += escape_expr->toString();
2984  }
2985  str += ") ";
2986  return str;
2987 }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1111
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1110
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1113

Member Data Documentation

std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::escape_expr
private
bool Analyzer::LikeExpr::is_ilike
private
bool Analyzer::LikeExpr::is_simple
private
std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::like_expr
private

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