OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analyzer::InValues Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::InValues:
+ Collaboration diagram for Analyzer::InValues:

Public Member Functions

 InValues (std::shared_ptr< Analyzer::Expr > a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
 
const Exprget_arg () const
 
const std::shared_ptr
< Analyzer::Expr
get_own_arg () const
 
const std::list
< std::shared_ptr
< Analyzer::Expr > > & 
get_value_list () 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
 
const std::list
< std::shared_ptr
< Analyzer::Expr > > 
value_list
 

Additional Inherited Members

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

Detailed Description

Definition at line 636 of file Analyzer.h.

Constructor & Destructor Documentation

Analyzer::InValues::InValues ( std::shared_ptr< Analyzer::Expr a,
const std::list< std::shared_ptr< Analyzer::Expr >> &  l 
)

Definition at line 1645 of file Analyzer.cpp.

1647  : Expr(kBOOLEAN, !is_in_values_nullable(a, l)), arg(a), value_list(l) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:74
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
constexpr double a
Definition: Utm.h:32
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672
bool is_in_values_nullable(const std::shared_ptr< Analyzer::Expr > &a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.cpp:1630

Member Function Documentation

void Analyzer::InValues::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 652 of file Analyzer.h.

References arg.

655  {
656  arg->collect_column_var(colvar_set, include_agg);
657  }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
void Analyzer::InValues::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 649 of file Analyzer.h.

References arg.

649  {
650  arg->collect_rte_idx(rte_idx_set);
651  }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
std::shared_ptr< Analyzer::Expr > Analyzer::InValues::deep_copy ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 128 of file Analyzer.cpp.

References arg, and value_list.

128  {
129  std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
130  for (auto p : value_list) {
131  new_value_list.push_back(p->deep_copy());
132  }
133  return makeExpr<InValues>(arg->deep_copy(), new_value_list);
134 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672
void Analyzer::InValues::find_expr ( std::function< bool(const Expr *)>  f,
std::list< const Expr * > &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3130 of file Analyzer.cpp.

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

3131  {
3132  if (f(this)) {
3133  add_unique(expr_list);
3134  return;
3135  }
3136  arg->find_expr(f, expr_list);
3137  for (auto e : value_list) {
3138  e->find_expr(f, expr_list);
3139  }
3140 }
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:3101
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
constexpr double f
Definition: Utm.h:31
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672

+ Here is the call graph for this function:

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

Definition at line 640 of file Analyzer.h.

References arg.

Referenced by CodeGenerator::codegen(), CodeGenerator::createInValuesBitmap(), QueryRewriter::generateCaseForDomainValues(), operator==(), QueryRewriter::rewriteConstrainedByInImpl(), ScalarExprToSql::visitInValues(), DeepCopyVisitor::visitInValues(), and ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitInValues().

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

+ Here is the caller graph for this function:

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

Definition at line 641 of file Analyzer.h.

References arg.

641 { return arg; }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
const std::list<std::shared_ptr<Analyzer::Expr> >& Analyzer::InValues::get_value_list ( ) const
inline

Definition at line 642 of file Analyzer.h.

References value_list.

Referenced by CodeGenerator::codegen(), CodeGenerator::createInValuesBitmap(), QueryRewriter::generateCaseForDomainValues(), operator==(), ScalarExprToSql::visitInValues(), DeepCopyVisitor::visitInValues(), and ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitInValues().

642  {
643  return value_list;
644  }
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672

+ Here is the caller graph for this function:

void Analyzer::InValues::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 1649 of file Analyzer.cpp.

References arg.

1651  {
1652  std::set<int> rte_idx_set;
1653  arg->collect_rte_idx(rte_idx_set);
1654  if (rte_idx_set.size() > 1) {
1655  join_predicates.push_back(this);
1656  } else if (rte_idx_set.size() == 1) {
1657  scan_predicates.push_back(this);
1658  } else {
1659  const_predicates.push_back(this);
1660  }
1661 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
bool Analyzer::InValues::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2423 of file Analyzer.cpp.

References arg, get_arg(), get_value_list(), and value_list.

2423  {
2424  if (typeid(rhs) != typeid(InValues)) {
2425  return false;
2426  }
2427  const InValues& rhs_iv = dynamic_cast<const InValues&>(rhs);
2428  if (!(*arg == *rhs_iv.get_arg())) {
2429  return false;
2430  }
2431  if (value_list.size() != rhs_iv.get_value_list().size()) {
2432  return false;
2433  }
2434  auto q = rhs_iv.get_value_list().begin();
2435  for (auto p : value_list) {
2436  if (!(*p == **q)) {
2437  return false;
2438  }
2439  q++;
2440  }
2441  return true;
2442 }
InValues(std::shared_ptr< Analyzer::Expr > a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.cpp:1645
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672

+ Here is the call graph for this function:

std::shared_ptr< Analyzer::Expr > Analyzer::InValues::rewrite_agg_to_var ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 2012 of file Analyzer.cpp.

References arg, and value_list.

2013  {
2014  std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
2015  for (auto v : value_list) {
2016  new_value_list.push_back(v->rewrite_agg_to_var(tlist));
2017  }
2018  return makeExpr<InValues>(arg->rewrite_agg_to_var(tlist), new_value_list);
2019 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672
std::shared_ptr< Analyzer::Expr > Analyzer::InValues::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 2003 of file Analyzer.cpp.

References arg, and value_list.

2004  {
2005  std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
2006  for (auto v : value_list) {
2007  new_value_list.push_back(v->deep_copy());
2008  }
2009  return makeExpr<InValues>(arg->rewrite_with_child_targetlist(tlist), new_value_list);
2010 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672
std::shared_ptr< Analyzer::Expr > Analyzer::InValues::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1994 of file Analyzer.cpp.

References arg, and value_list.

1995  {
1996  std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
1997  for (auto v : value_list) {
1998  new_value_list.push_back(v->deep_copy());
1999  }
2000  return makeExpr<InValues>(arg->rewrite_with_targetlist(tlist), new_value_list);
2001 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672
std::string Analyzer::InValues::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2743 of file Analyzer.cpp.

References arg, to_string(), and value_list.

2743  {
2744  std::string str{"(IN "};
2745  str += arg->toString();
2746  str += "(";
2747  int cnt = 0;
2748  bool shorted_value_list_str = false;
2749  for (auto e : value_list) {
2750  str += e->toString();
2751  cnt++;
2752  if (cnt > 4) {
2753  shorted_value_list_str = true;
2754  break;
2755  }
2756  }
2757  if (shorted_value_list_str) {
2758  str += "... | ";
2759  str += "Total # values: ";
2760  str += std::to_string(value_list.size());
2761  }
2762  str += ") ";
2763  return str;
2764 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:670
std::string to_string(char const *&&v)
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:672

+ Here is the call graph for this function:

Member Data Documentation

const std::list<std::shared_ptr<Analyzer::Expr> > Analyzer::InValues::value_list
private

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