OmniSciDB  c0231cc57d
 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 (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 ()
 
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 635 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 1629 of file Analyzer.cpp.

1631  : Expr(kBOOLEAN, !is_in_values_nullable(a, l)), arg(a), value_list(l) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:73
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
constexpr double a
Definition: Utm.h:32
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671
bool is_in_values_nullable(const std::shared_ptr< Analyzer::Expr > &a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.cpp:1614

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

References arg.

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

Reimplemented from Analyzer::Expr.

Definition at line 648 of file Analyzer.h.

References arg.

648  {
649  arg->collect_rte_idx(rte_idx_set);
650  }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
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:669
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671
void Analyzer::InValues::find_expr ( bool(*)(const Expr *)  f,
std::list< const Expr * > &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3100 of file Analyzer.cpp.

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

3101  {
3102  if (f(this)) {
3103  add_unique(expr_list);
3104  return;
3105  }
3106  arg->find_expr(f, expr_list);
3107  for (auto e : value_list) {
3108  e->find_expr(f, expr_list);
3109  }
3110 }
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:3073
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
constexpr double f
Definition: Utm.h:31
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671

+ Here is the call graph for this function:

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

Definition at line 639 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().

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

+ Here is the caller graph for this function:

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

Definition at line 640 of file Analyzer.h.

References arg.

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

Definition at line 641 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().

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

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

References arg.

1635  {
1636  std::set<int> rte_idx_set;
1637  arg->collect_rte_idx(rte_idx_set);
1638  if (rte_idx_set.size() > 1) {
1639  join_predicates.push_back(this);
1640  } else if (rte_idx_set.size() == 1) {
1641  scan_predicates.push_back(this);
1642  } else {
1643  const_predicates.push_back(this);
1644  }
1645 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
bool Analyzer::InValues::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2407 of file Analyzer.cpp.

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

2407  {
2408  if (typeid(rhs) != typeid(InValues)) {
2409  return false;
2410  }
2411  const InValues& rhs_iv = dynamic_cast<const InValues&>(rhs);
2412  if (!(*arg == *rhs_iv.get_arg())) {
2413  return false;
2414  }
2415  if (value_list.size() != rhs_iv.get_value_list().size()) {
2416  return false;
2417  }
2418  auto q = rhs_iv.get_value_list().begin();
2419  for (auto p : value_list) {
2420  if (!(*p == **q)) {
2421  return false;
2422  }
2423  q++;
2424  }
2425  return true;
2426 }
InValues(std::shared_ptr< Analyzer::Expr > a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.cpp:1629
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671

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

References arg, and value_list.

1997  {
1998  std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
1999  for (auto v : value_list) {
2000  new_value_list.push_back(v->rewrite_agg_to_var(tlist));
2001  }
2002  return makeExpr<InValues>(arg->rewrite_agg_to_var(tlist), new_value_list);
2003 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671
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 1987 of file Analyzer.cpp.

References arg, and value_list.

1988  {
1989  std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
1990  for (auto v : value_list) {
1991  new_value_list.push_back(v->deep_copy());
1992  }
1993  return makeExpr<InValues>(arg->rewrite_with_child_targetlist(tlist), new_value_list);
1994 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671
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 1978 of file Analyzer.cpp.

References arg, and value_list.

1979  {
1980  std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
1981  for (auto v : value_list) {
1982  new_value_list.push_back(v->deep_copy());
1983  }
1984  return makeExpr<InValues>(arg->rewrite_with_targetlist(tlist), new_value_list);
1985 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671
std::string Analyzer::InValues::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2727 of file Analyzer.cpp.

References arg, to_string(), and value_list.

2727  {
2728  std::string str{"(IN "};
2729  str += arg->toString();
2730  str += "(";
2731  int cnt = 0;
2732  bool shorted_value_list_str = false;
2733  for (auto e : value_list) {
2734  str += e->toString();
2735  cnt++;
2736  if (cnt > 4) {
2737  shorted_value_list_str = true;
2738  break;
2739  }
2740  }
2741  if (shorted_value_list_str) {
2742  str += "... | ";
2743  str += "Total # values: ";
2744  str += std::to_string(value_list.size());
2745  }
2746  str += ") ";
2747  return str;
2748 }
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:669
std::string to_string(char const *&&v)
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:671

+ 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: