OmniSciDB  a987f07e93
 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, int r, int c, int i, WhichRow o, int v)
 
 Var (const SQLTypeInfo &ti, WhichRow o, int v)
 
WhichRow get_which_row () const
 
void set_which_row (WhichRow r)
 
int get_varno () const
 
void set_varno (int 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< int > &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, int r, int c, int i)
 
int get_table_id () const
 
int get_column_id () const
 
int get_rte_idx () const
 
void set_rte_idx (int new_rte_idx)
 
EncodingType get_compression () const
 
int get_comp_param () 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_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 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
 
int 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
int table_id
 
int column_id
 
int 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,
int  r,
int  c,
int  i,
WhichRow  o,
int  v 
)
inline

Definition at line 278 of file Analyzer.h.

279  : ColumnVar(ti, r, c, i), which_row(o), varno(v) {}
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:200
WhichRow which_row
Definition: Analyzer.h:305
Analyzer::Var::Var ( const SQLTypeInfo ti,
WhichRow  o,
int  v 
)
inline

Definition at line 280 of file Analyzer.h.

281  : ColumnVar(ti, 0, 0, -1), which_row(o), varno(v) {}
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:200
WhichRow which_row
Definition: Analyzer.h:305

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

References kGROUPBY, and which_row.

1484  {
1485  if (which_row != kGROUPBY) {
1486  throw std::runtime_error("Internal error: invalid VAR in GROUP BY or HAVING.");
1487  }
1488 }
WhichRow which_row
Definition: Analyzer.h:305
void Analyzer::Var::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 290 of file Analyzer.h.

290  {
291  rte_idx_set.insert(-1);
292  }
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_id, Analyzer::ColumnVar::rte_idx, Analyzer::ColumnVar::table_id, 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, table_id, column_id, rte_idx, which_row, varno);
89 }
SQLTypeInfo type_info
Definition: Analyzer.h:184
WhichRow which_row
Definition: Analyzer.h:305

+ Here is the caller graph for this function:

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

Definition at line 284 of file Analyzer.h.

References varno.

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

284 { return varno; }

+ Here is the caller graph for this function:

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

Definition at line 282 of file Analyzer.h.

References which_row.

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

282 { return which_row; }
WhichRow which_row
Definition: Analyzer.h:305

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

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

1954  {
1955  int varno = 1;
1956  for (auto tle : tlist) {
1957  const Expr* e = tle->get_expr();
1958  if (*e == *this) {
1959  return makeExpr<Var>(e->get_type_info(), Var::kINPUT_OUTER, varno);
1960  }
1961  varno++;
1962  }
1963  throw std::runtime_error(
1964  "Internal error: cannot find Var from having clause in targetlist.");
1965 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:74

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

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

References deep_copy().

294  {
295  return deep_copy();
296  }
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 ( int  n)
inline

Definition at line 285 of file Analyzer.h.

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

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

Definition at line 283 of file Analyzer.h.

References which_row.

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

Reimplemented from Analyzer::ColumnVar.

Definition at line 2616 of file Analyzer.cpp.

References Analyzer::ColumnVar::column_id, Analyzer::ColumnVar::rte_idx, Analyzer::ColumnVar::table_id, to_string(), varno, and which_row.

2616  {
2617  return "(Var table: " + std::to_string(table_id) +
2618  " column: " + std::to_string(column_id) + " rte: " + std::to_string(rte_idx) +
2619  " which_row: " + std::to_string(which_row) + " varno: " + std::to_string(varno) +
2620  ") ";
2621 }
std::string to_string(char const *&&v)
WhichRow which_row
Definition: Analyzer.h:305

+ Here is the call graph for this function:

Member Data Documentation

int Analyzer::Var::varno
private

Definition at line 308 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 305 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: