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

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::Var:
+ Collaboration diagram for Analyzer::Var:

Public Types

enum  WhichRow { kINPUT_OUTER, kINPUT_INNER, kOUTPUT, kGROUPBY }
 

Public Member Functions

 Var (const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx, WhichRow o, int32_t v)
 
 Var (const SQLTypeInfo &ti, WhichRow o, int32_t v)
 
 which_row (o)
 
 varno (v)
 
WhichRow get_which_row () const
 
void set_which_row (WhichRow r)
 
int32_t get_varno () const
 
void set_varno (int32_t n)
 
std::shared_ptr< Analyzer::Exprdeep_copy () const override
 
std::string toString () const override
 
void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
 
void collect_rte_idx (std::set< int32_t > &rte_idx_set) 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
 
- Public Member Functions inherited from Analyzer::ColumnVar
 ColumnVar (const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
 
const shared::ColumnKeygetColumnKey () const
 
shared::TableKey getTableKey () const
 
int32_t get_rte_idx () const
 
void set_rte_idx (int32_t new_rte_idx)
 
EncodingType get_compression () const
 
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< int32_t > &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
 
bool operator== (const Expr &rhs) 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 std::shared_ptr
< Analyzer::Expr
normalize_simple_predicate (int &rte_idx) const
 
virtual void collect_rte_idx (std::set< int > &rte_idx_set) 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
 
virtual void find_expr (std::function< bool(const Expr *)> f, std::list< const Expr * > &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Private Attributes

WhichRow which_row
 
int32_t varno
 

Additional Inherited Members

- Static Public Member Functions inherited from Analyzer::ColumnVar
static bool colvar_comp (const ColumnVar *l, const ColumnVar *r)
 
- Protected Attributes inherited from Analyzer::ColumnVar
shared::ColumnKey column_key_
 
int32_t rte_idx_
 
- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 275 of file Analyzer.h.

Member Enumeration Documentation

Enumerator
kINPUT_OUTER 
kINPUT_INNER 
kOUTPUT 
kGROUPBY 

Definition at line 277 of file Analyzer.h.

Constructor & Destructor Documentation

Analyzer::Var::Var ( const SQLTypeInfo ti,
const shared::ColumnKey column_key,
int32_t  rte_idx,
WhichRow  o,
int32_t  v 
)
inline

Definition at line 278 of file Analyzer.h.

283  : ColumnVar(ti, column_key, rte_idx), which_row(o), varno(v) {}
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196
WhichRow which_row
Definition: Analyzer.h:309
int32_t varno
Definition: Analyzer.h:312
Analyzer::Var::Var ( const SQLTypeInfo ti,
WhichRow  o,
int32_t  v 
)
inline

Definition at line 284 of file Analyzer.h.

285  : ColumnVar(ti, {0, 0, 0}, -1), which_row(o), varno(v) {}
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196
WhichRow which_row
Definition: Analyzer.h:309
int32_t varno
Definition: Analyzer.h:312

Member Function Documentation

void Analyzer::Var::check_group_by ( const std::list< std::shared_ptr< Analyzer::Expr >> &  groupby) const
overridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 1526 of file Analyzer.cpp.

References kGROUPBY, and which_row.

1527  {
1528  if (which_row != kGROUPBY) {
1529  throw std::runtime_error("Internal error: invalid VAR in GROUP BY or HAVING.");
1530  }
1531 }
WhichRow which_row
Definition: Analyzer.h:309
void Analyzer::Var::collect_rte_idx ( std::set< int32_t > &  rte_idx_set) const
inlineoverride

Definition at line 294 of file Analyzer.h.

294  {
295  rte_idx_set.insert(-1);
296  }
std::shared_ptr< Analyzer::Expr > Analyzer::Var::deep_copy ( ) const
overridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 87 of file Analyzer.cpp.

References Analyzer::ColumnVar::column_key_, Analyzer::ColumnVar::rte_idx_, Analyzer::Expr::type_info, varno, and which_row.

Referenced by Parser::ColumnRef::analyze(), rewrite_with_child_targetlist(), rewrite_with_targetlist(), and DeepCopyVisitor::visitVar().

87  {
88  return makeExpr<Var>(type_info, column_key_, rte_idx_, which_row, varno);
89 }
shared::ColumnKey column_key_
Definition: Analyzer.h:239
SQLTypeInfo type_info
Definition: Analyzer.h:180
WhichRow which_row
Definition: Analyzer.h:309
int32_t varno
Definition: Analyzer.h:312

+ Here is the caller graph for this function:

int32_t Analyzer::Var::get_varno ( ) const
inline

Definition at line 288 of file Analyzer.h.

References varno.

Referenced by Analyzer::ColumnVar::operator==(), anonymous_namespace{QueryMemoryDescriptor.cpp}::target_expr_group_by_indices(), and ScalarExprToSql::visitVar().

288 { return varno; }
int32_t varno
Definition: Analyzer.h:312

+ Here is the caller graph for this function:

WhichRow Analyzer::Var::get_which_row ( ) const
inline

Definition at line 286 of file Analyzer.h.

References which_row.

Referenced by Parser::ColumnRef::analyze(), and Analyzer::ColumnVar::operator==().

286 { return which_row; }
WhichRow which_row
Definition: Analyzer.h:309

+ Here is the caller graph for this function:

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

Reimplemented from Analyzer::ColumnVar.

Definition at line 2026 of file Analyzer.cpp.

References Analyzer::Expr::get_type_info(), kINPUT_OUTER, and varno.

2027  {
2028  int varno = 1;
2029  for (auto tle : tlist) {
2030  const Expr* e = tle->get_expr();
2031  if (*e == *this) {
2032  return makeExpr<Var>(e->get_type_info(), Var::kINPUT_OUTER, varno);
2033  }
2034  varno++;
2035  }
2036  throw std::runtime_error(
2037  "Internal error: cannot find Var from having clause in targetlist.");
2038 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
int32_t varno
Definition: Analyzer.h:312

+ Here is the call graph for this function:

std::shared_ptr<Analyzer::Expr> Analyzer::Var::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 301 of file Analyzer.h.

References deep_copy().

302  {
303  return deep_copy();
304  }
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:87

+ Here is the call graph for this function:

std::shared_ptr<Analyzer::Expr> Analyzer::Var::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 297 of file Analyzer.h.

References deep_copy().

298  {
299  return deep_copy();
300  }
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:87

+ Here is the call graph for this function:

void Analyzer::Var::set_varno ( int32_t  n)
inline

Definition at line 289 of file Analyzer.h.

References anonymous_namespace{Utm.h}::n, and varno.

289 { varno = n; }
int32_t varno
Definition: Analyzer.h:312
constexpr double n
Definition: Utm.h:38
void Analyzer::Var::set_which_row ( WhichRow  r)
inline

Definition at line 287 of file Analyzer.h.

References which_row.

287 { which_row = r; }
WhichRow which_row
Definition: Analyzer.h:309
std::string Analyzer::Var::toString ( ) const
overridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 2733 of file Analyzer.cpp.

References Analyzer::ColumnVar::column_key_, Analyzer::ColumnVar::rte_idx_, to_string(), varno, and which_row.

2733  {
2734  std::stringstream ss;
2735  ss << "(Var " << column_key_ << ", rte: " << std::to_string(rte_idx_)
2736  << ", which_row: " << std::to_string(which_row)
2737  << ", varno: " << std::to_string(varno) + ") ";
2738  return ss.str();
2739 }
shared::ColumnKey column_key_
Definition: Analyzer.h:239
std::string to_string(char const *&&v)
WhichRow which_row
Definition: Analyzer.h:309
int32_t varno
Definition: Analyzer.h:312

+ Here is the call graph for this function:

Analyzer::Var::varno ( )
inline

Definition at line 285 of file Analyzer.h.

285 : ColumnVar(ti, {0, 0, 0}, -1), which_row(o), varno(v) {}
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196
WhichRow which_row
Definition: Analyzer.h:309
int32_t varno
Definition: Analyzer.h:312
Analyzer::Var::which_row ( )

Member Data Documentation

int32_t Analyzer::Var::varno
private

Definition at line 312 of file Analyzer.h.

Referenced by deep_copy(), get_varno(), rewrite_agg_to_var(), set_varno(), and toString().

WhichRow Analyzer::Var::which_row
private

Definition at line 309 of file Analyzer.h.

Referenced by check_group_by(), deep_copy(), get_which_row(), set_which_row(), and toString().


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