OmniSciDB  8a228a1076
Analyzer::ColumnVar Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::ColumnVar:
+ Collaboration diagram for Analyzer::ColumnVar:

Public Member Functions

 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
 
EncodingType get_compression () const
 
int get_comp_param () const
 
void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
 
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
 
- 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::Expradd_cast (const SQLTypeInfo &new_type_info)
 
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
 
virtual void find_expr (bool(*f)(const Expr *), std::list< const Expr *> &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Static Public Member Functions

static bool colvar_comp (const ColumnVar *l, const ColumnVar *r)
 

Protected Attributes

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

Constructor & Destructor Documentation

◆ ColumnVar()

Analyzer::ColumnVar::ColumnVar ( const SQLTypeInfo ti,
int  r,
int  c,
int  i 
)
inline

Definition at line 193 of file Analyzer.h.

194  : Expr(ti), table_id(r), column_id(c), rte_idx(i) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70

Member Function Documentation

◆ check_group_by()

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

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1353 of file Analyzer.cpp.

1354  {
1355  if (!groupby.empty()) {
1356  for (auto e : groupby) {
1357  auto c = std::dynamic_pointer_cast<ColumnVar>(e);
1358  if (c && table_id == c->get_table_id() && column_id == c->get_column_id()) {
1359  return;
1360  }
1361  }
1362  }
1363  throw std::runtime_error(
1364  "expressions in the SELECT or HAVING clause must be an aggregate function or an "
1365  "expression "
1366  "over GROUP BY columns.");
1367 }
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:193

◆ collect_column_var()

void Analyzer::ColumnVar::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 214 of file Analyzer.h.

References operator==().

217  {
218  colvar_set.insert(this);
219  }
+ Here is the call graph for this function:

◆ collect_rte_idx()

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

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 206 of file Analyzer.h.

206  {
207  rte_idx_set.insert(rte_idx);
208  }

◆ colvar_comp()

static bool Analyzer::ColumnVar::colvar_comp ( const ColumnVar l,
const ColumnVar r 
)
inlinestatic

Definition at line 209 of file Analyzer.h.

References get_column_id(), and get_table_id().

209  {
210  return l->get_table_id() < r->get_table_id() ||
211  (l->get_table_id() == r->get_table_id() &&
212  l->get_column_id() < r->get_column_id());
213  }
+ Here is the call graph for this function:

◆ deep_copy()

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

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 59 of file Analyzer.cpp.

References Analyzer::Expr::type_info.

Referenced by rewrite_with_targetlist(), DeepCopyVisitor::visitColumnVar(), and anonymous_namespace{ScalarCodeGenerator.cpp}::UsedColumnExpressions::visitColumnVar().

59  {
60  return makeExpr<ColumnVar>(type_info, table_id, column_id, rte_idx);
61 }
SQLTypeInfo type_info
Definition: Analyzer.h:177
+ Here is the caller graph for this function:

◆ get_column_id()

◆ get_comp_param()

int Analyzer::ColumnVar::get_comp_param ( ) const
inline

Definition at line 199 of file Analyzer.h.

Referenced by anonymous_namespace{ColumnIR.cpp}::get_col_decoder().

199 { return type_info.get_comp_param(); }
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:268
SQLTypeInfo type_info
Definition: Analyzer.h:177
+ Here is the caller graph for this function:

◆ get_compression()

EncodingType Analyzer::ColumnVar::get_compression ( ) const
inline

Definition at line 198 of file Analyzer.h.

Referenced by anonymous_namespace{ColumnIR.cpp}::get_col_decoder().

198 { return type_info.get_compression(); }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:267
SQLTypeInfo type_info
Definition: Analyzer.h:177
+ Here is the caller graph for this function:

◆ get_rte_idx()

◆ get_table_id()

◆ group_predicates()

void Analyzer::ColumnVar::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 1463 of file Analyzer.cpp.

References SQLTypeInfo::get_type(), kBOOLEAN, and Analyzer::Expr::type_info.

1465  {
1466  if (type_info.get_type() == kBOOLEAN) {
1467  scan_predicates.push_back(this);
1468  }
1469 }
SQLTypeInfo type_info
Definition: Analyzer.h:177
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
+ Here is the call graph for this function:

◆ operator==()

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

Implements Analyzer::Expr.

Definition at line 2032 of file Analyzer.cpp.

References get_column_id(), get_rte_idx(), get_table_id(), Analyzer::Var::get_varno(), and Analyzer::Var::get_which_row().

2032  {
2033  if (typeid(rhs) != typeid(ColumnVar) && typeid(rhs) != typeid(Var)) {
2034  return false;
2035  }
2036  const ColumnVar& rhs_cv = dynamic_cast<const ColumnVar&>(rhs);
2037  if (rte_idx != -1) {
2038  return (table_id == rhs_cv.get_table_id()) && (column_id == rhs_cv.get_column_id()) &&
2039  (rte_idx == rhs_cv.get_rte_idx());
2040  }
2041  const Var* v = dynamic_cast<const Var*>(this);
2042  if (v == nullptr) {
2043  return false;
2044  }
2045  const Var* rv = dynamic_cast<const Var*>(&rhs);
2046  if (rv == nullptr) {
2047  return false;
2048  }
2049  return (v->get_which_row() == rv->get_which_row()) &&
2050  (v->get_varno() == rv->get_varno());
2051 }
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:193
+ Here is the call graph for this function:

◆ rewrite_agg_to_var()

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

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1796 of file Analyzer.cpp.

References get_column_id(), get_rte_idx(), get_table_id(), Analyzer::Expr::get_type_info(), and Analyzer::Var::kINPUT_OUTER.

1797  {
1798  int varno = 1;
1799  for (auto tle : tlist) {
1800  const Expr* e = tle->get_expr();
1801  if (typeid(*e) != typeid(AggExpr)) {
1802  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1803  if (colvar == nullptr) {
1804  throw std::runtime_error(
1805  "Internal Error: targetlist in rewrite_agg_to_var is not all columns and "
1806  "aggregates.");
1807  }
1808  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1809  return makeExpr<Var>(colvar->get_type_info(),
1810  colvar->get_table_id(),
1811  colvar->get_column_id(),
1812  colvar->get_rte_idx(),
1814  varno);
1815  }
1816  }
1817  varno++;
1818  }
1819  throw std::runtime_error(
1820  "Internal error: cannot find ColumnVar from having clause in targetlist.");
1821 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:193
+ Here is the call graph for this function:

◆ rewrite_with_child_targetlist()

std::shared_ptr< Analyzer::Expr > Analyzer::ColumnVar::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1772 of file Analyzer.cpp.

References get_column_id(), get_rte_idx(), get_table_id(), Analyzer::Expr::get_type_info(), and Analyzer::Var::kINPUT_OUTER.

1773  {
1774  int varno = 1;
1775  for (auto tle : tlist) {
1776  const Expr* e = tle->get_expr();
1777  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1778  if (colvar == nullptr) {
1779  throw std::runtime_error(
1780  "Internal Error: targetlist in rewrite_with_child_targetlist is not all "
1781  "columns.");
1782  }
1783  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1784  return makeExpr<Var>(colvar->get_type_info(),
1785  colvar->get_table_id(),
1786  colvar->get_column_id(),
1787  colvar->get_rte_idx(),
1789  varno);
1790  }
1791  varno++;
1792  }
1793  throw std::runtime_error("Internal error: cannot find ColumnVar in child targetlist.");
1794 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:193
+ Here is the call graph for this function:

◆ rewrite_with_targetlist()

std::shared_ptr< Analyzer::Expr > Analyzer::ColumnVar::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1758 of file Analyzer.cpp.

References deep_copy(), get_column_id(), and get_table_id().

1759  {
1760  for (auto tle : tlist) {
1761  const Expr* e = tle->get_expr();
1762  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1763  if (colvar != nullptr) {
1764  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1765  return colvar->deep_copy();
1766  }
1767  }
1768  }
1769  throw std::runtime_error("Internal error: cannot find ColumnVar in targetlist.");
1770 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:193
+ Here is the call graph for this function:

◆ toString()

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

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 2403 of file Analyzer.cpp.

References Analyzer::Expr::get_type_info(), SQLTypeInfo::get_type_name(), and to_string().

2403  {
2404  return "(ColumnVar table: " + std::to_string(table_id) +
2405  " column: " + std::to_string(column_id) + " rte: " + std::to_string(rte_idx) +
2406  " " + get_type_info().get_type_name() + ") ";
2407 }
std::string to_string(char const *&&v)
std::string get_type_name() const
Definition: sqltypes.h:362
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
+ Here is the call graph for this function:

Member Data Documentation

◆ column_id

int Analyzer::ColumnVar::column_id
protected

Definition at line 231 of file Analyzer.h.

◆ rte_idx

int Analyzer::ColumnVar::rte_idx
protected

Definition at line 232 of file Analyzer.h.

◆ table_id

int Analyzer::ColumnVar::table_id
protected

Definition at line 230 of file Analyzer.h.


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