OmniSciDB  04ee39c94c
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::Exprget_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 (bool(*f)(const Expr *), 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 ()
 
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::Expradd_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::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

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

Constructor & Destructor Documentation

◆ LikeExpr()

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

791  : Expr(kBOOLEAN, a->get_type_info().get_notnull())
792  , arg(a)
793  , like_expr(l)
794  , escape_expr(e)
795  , is_ilike(i)
796  , is_simple(s) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849

Member Function Documentation

◆ collect_column_var()

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

813  {
814  arg->collect_column_var(colvar_set, include_agg);
815  }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846

◆ collect_rte_idx()

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

Reimplemented from Analyzer::Expr.

Definition at line 807 of file Analyzer.h.

807  {
808  arg->collect_rte_idx(rte_idx_set);
809  }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846

◆ deep_copy()

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

Implements Analyzer::Expr.

Definition at line 134 of file Analyzer.cpp.

134  {
135  return makeExpr<LikeExpr>(arg->deep_copy(),
136  like_expr->deep_copy(),
137  escape_expr ? escape_expr->deep_copy() : nullptr,
138  is_ilike,
139  is_simple);
140 }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849

◆ find_expr()

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

Reimplemented from Analyzer::Expr.

Definition at line 2651 of file Analyzer.cpp.

References Analyzer::Expr::add_unique(), and Analyzer::InIntegerSet::arg.

2652  {
2653  if (f(this)) {
2654  add_unique(expr_list);
2655  return;
2656  }
2657  arg->find_expr(f, expr_list);
2658  like_expr->find_expr(f, expr_list);
2659  if (escape_expr != nullptr) {
2660  escape_expr->find_expr(f, expr_list);
2661  }
2662 }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
virtual void add_unique(std::list< const Expr *> &expr_list) const
Definition: Analyzer.cpp:2585
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849
+ Here is the call graph for this function:

◆ get_arg()

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

Definition at line 797 of file Analyzer.h.

Referenced by CodeGenerator::codegen(), getExpressionRange(), operator==(), DeepCopyVisitor::visitLikeExpr(), and ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitLikeExpr().

797 { return arg.get(); }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
+ Here is the caller graph for this function:

◆ get_escape_expr()

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

Definition at line 800 of file Analyzer.h.

Referenced by CodeGenerator::codegen(), operator==(), DeepCopyVisitor::visitLikeExpr(), and ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitLikeExpr().

800 { return escape_expr.get(); }
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849
+ Here is the caller graph for this function:

◆ get_is_ilike()

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

Definition at line 801 of file Analyzer.h.

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

801 { return is_ilike; }
+ Here is the caller graph for this function:

◆ get_is_simple()

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

Definition at line 802 of file Analyzer.h.

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

802 { return is_simple; }
+ Here is the caller graph for this function:

◆ get_like_expr()

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

Definition at line 799 of file Analyzer.h.

Referenced by CodeGenerator::codegen(), operator==(), DeepCopyVisitor::visitLikeExpr(), and ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitLikeExpr().

799 { return like_expr.get(); }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
+ Here is the caller graph for this function:

◆ get_own_arg()

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

Definition at line 798 of file Analyzer.h.

Referenced by CodeGenerator::codegen().

798 { return arg; }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
+ Here is the caller graph for this function:

◆ group_predicates()

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

References Analyzer::InIntegerSet::arg.

1515  {
1516  std::set<int> rte_idx_set;
1517  arg->collect_rte_idx(rte_idx_set);
1518  if (rte_idx_set.size() > 1) {
1519  join_predicates.push_back(this);
1520  } else if (rte_idx_set.size() == 1) {
1521  scan_predicates.push_back(this);
1522  } else {
1523  const_predicates.push_back(this);
1524  }
1525 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846

◆ operator==()

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

Implements Analyzer::Expr.

Definition at line 2060 of file Analyzer.cpp.

References Analyzer::InIntegerSet::arg, get_arg(), get_escape_expr(), get_is_ilike(), and get_like_expr().

2060  {
2061  if (typeid(rhs) != typeid(LikeExpr)) {
2062  return false;
2063  }
2064  const LikeExpr& rhs_lk = dynamic_cast<const LikeExpr&>(rhs);
2065  if (!(*arg == *rhs_lk.get_arg()) || !(*like_expr == *rhs_lk.get_like_expr()) ||
2066  is_ilike != rhs_lk.get_is_ilike()) {
2067  return false;
2068  }
2069  if (escape_expr.get() == rhs_lk.get_escape_expr()) {
2070  return true;
2071  }
2072  if (escape_expr != nullptr && rhs_lk.get_escape_expr() != nullptr &&
2073  *escape_expr == *rhs_lk.get_escape_expr()) {
2074  return true;
2075  }
2076  return false;
2077 }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
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:786
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849
+ Here is the call graph for this function:

◆ rewrite_agg_to_var()

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

References operator==().

833  {
834  return makeExpr<LikeExpr>(arg->rewrite_agg_to_var(tlist),
835  like_expr->deep_copy(),
836  escape_expr ? escape_expr->deep_copy() : nullptr,
837  is_ilike,
838  is_simple);
839  }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849
+ Here is the call graph for this function:

◆ rewrite_with_child_targetlist()

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

825  {
826  return makeExpr<LikeExpr>(arg->rewrite_with_child_targetlist(tlist),
827  like_expr->deep_copy(),
828  escape_expr ? escape_expr->deep_copy() : nullptr,
829  is_ilike,
830  is_simple);
831  }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849

◆ rewrite_with_targetlist()

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

817  {
818  return makeExpr<LikeExpr>(arg->rewrite_with_targetlist(tlist),
819  like_expr->deep_copy(),
820  escape_expr ? escape_expr->deep_copy() : nullptr,
821  is_ilike,
822  is_simple);
823  }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849

◆ toString()

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

Implements Analyzer::Expr.

Definition at line 2436 of file Analyzer.cpp.

References Analyzer::InIntegerSet::arg.

2436  {
2437  std::string str{"(LIKE "};
2438  str += arg->toString();
2439  str += like_expr->toString();
2440  if (escape_expr) {
2441  str += escape_expr->toString();
2442  }
2443  str += ") ";
2444  return str;
2445 }
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:847
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:846
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:849

Member Data Documentation

◆ arg

std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::arg
private

Definition at line 846 of file Analyzer.h.

◆ escape_expr

std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::escape_expr
private

Definition at line 849 of file Analyzer.h.

◆ is_ilike

bool Analyzer::LikeExpr::is_ilike
private

Definition at line 850 of file Analyzer.h.

◆ is_simple

bool Analyzer::LikeExpr::is_simple
private

Definition at line 851 of file Analyzer.h.

◆ like_expr

std::shared_ptr<Analyzer::Expr> Analyzer::LikeExpr::like_expr
private

Definition at line 847 of file Analyzer.h.


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