OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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::Expr
add_cast (const SQLTypeInfo &new_type_info)
 
virtual std::shared_ptr
< Analyzer::Expr
normalize_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 190 of file Analyzer.h.

Constructor & Destructor Documentation

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

Definition at line 192 of file Analyzer.h.

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

Member Function Documentation

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

References column_id, and table_id.

1280  {
1281  if (!groupby.empty()) {
1282  for (auto e : groupby) {
1283  auto c = std::dynamic_pointer_cast<ColumnVar>(e);
1284  if (c && table_id == c->get_table_id() && column_id == c->get_column_id()) {
1285  return;
1286  }
1287  }
1288  }
1289  throw std::runtime_error(
1290  "expressions in the SELECT or HAVING clause must be an aggregate function or an "
1291  "expression "
1292  "over GROUP BY columns.");
1293 }
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:192
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 213 of file Analyzer.h.

216  {
217  colvar_set.insert(this);
218  }
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 205 of file Analyzer.h.

References rte_idx.

205  {
206  rte_idx_set.insert(rte_idx);
207  }
static bool Analyzer::ColumnVar::colvar_comp ( const ColumnVar l,
const ColumnVar r 
)
inlinestatic

Definition at line 208 of file Analyzer.h.

References get_column_id(), and get_table_id().

208  {
209  return l->get_table_id() < r->get_table_id() ||
210  (l->get_table_id() == r->get_table_id() &&
211  l->get_column_id() < r->get_column_id());
212  }

+ Here is the call graph for this function:

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 column_id, rte_idx, table_id, and 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:176

+ Here is the caller graph for this function:

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

Definition at line 198 of file Analyzer.h.

References SQLTypeInfo::get_comp_param(), and Analyzer::Expr::type_info.

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

198 { return type_info.get_comp_param(); }
SQLTypeInfo type_info
Definition: Analyzer.h:176
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:257

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 197 of file Analyzer.h.

References SQLTypeInfo::get_compression(), and Analyzer::Expr::type_info.

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

197 { return type_info.get_compression(); }
SQLTypeInfo type_info
Definition: Analyzer.h:176
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

1391  {
1392  if (type_info.get_type() == kBOOLEAN) {
1393  scan_predicates.push_back(this);
1394  }
1395 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
SQLTypeInfo type_info
Definition: Analyzer.h:176

+ Here is the call graph for this function:

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

Implements Analyzer::Expr.

Definition at line 1944 of file Analyzer.cpp.

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

1944  {
1945  if (typeid(rhs) != typeid(ColumnVar) && typeid(rhs) != typeid(Var)) {
1946  return false;
1947  }
1948  const ColumnVar& rhs_cv = dynamic_cast<const ColumnVar&>(rhs);
1949  if (rte_idx != -1) {
1950  return (table_id == rhs_cv.get_table_id()) && (column_id == rhs_cv.get_column_id()) &&
1951  (rte_idx == rhs_cv.get_rte_idx());
1952  }
1953  const Var* v = dynamic_cast<const Var*>(this);
1954  if (v == nullptr) {
1955  return false;
1956  }
1957  const Var* rv = dynamic_cast<const Var*>(&rhs);
1958  if (rv == nullptr) {
1959  return false;
1960  }
1961  return (v->get_which_row() == rv->get_which_row()) &&
1962  (v->get_varno() == rv->get_varno());
1963 }
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:192

+ Here is the call graph for this function:

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

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

1709  {
1710  int varno = 1;
1711  for (auto tle : tlist) {
1712  const Expr* e = tle->get_expr();
1713  if (typeid(*e) != typeid(AggExpr)) {
1714  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1715  if (colvar == nullptr) {
1716  throw std::runtime_error(
1717  "Internal Error: targetlist in rewrite_agg_to_var is not all columns and "
1718  "aggregates.");
1719  }
1720  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1721  return makeExpr<Var>(colvar->get_type_info(),
1722  colvar->get_table_id(),
1723  colvar->get_column_id(),
1724  colvar->get_rte_idx(),
1726  varno);
1727  }
1728  }
1729  varno++;
1730  }
1731  throw std::runtime_error(
1732  "Internal error: cannot find ColumnVar from having clause in targetlist.");
1733 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:192

+ Here is the call graph for this function:

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

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

1685  {
1686  int varno = 1;
1687  for (auto tle : tlist) {
1688  const Expr* e = tle->get_expr();
1689  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1690  if (colvar == nullptr) {
1691  throw std::runtime_error(
1692  "Internal Error: targetlist in rewrite_with_child_targetlist is not all "
1693  "columns.");
1694  }
1695  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1696  return makeExpr<Var>(colvar->get_type_info(),
1697  colvar->get_table_id(),
1698  colvar->get_column_id(),
1699  colvar->get_rte_idx(),
1701  varno);
1702  }
1703  varno++;
1704  }
1705  throw std::runtime_error("Internal error: cannot find ColumnVar in child targetlist.");
1706 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:192

+ Here is the call graph for this function:

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

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

1671  {
1672  for (auto tle : tlist) {
1673  const Expr* e = tle->get_expr();
1674  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1675  if (colvar != nullptr) {
1676  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1677  return colvar->deep_copy();
1678  }
1679  }
1680  }
1681  throw std::runtime_error("Internal error: cannot find ColumnVar in targetlist.");
1682 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:192

+ Here is the call graph for this function:

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

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 2287 of file Analyzer.cpp.

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

2287  {
2288  return "(ColumnVar table: " + std::to_string(table_id) +
2289  " column: " + std::to_string(column_id) + " rte: " + std::to_string(rte_idx) +
2290  " " + get_type_info().get_type_name() + ") ";
2291 }
std::string to_string(char const *&&v)
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
std::string get_type_name() const
Definition: sqltypes.h:351

+ Here is the call graph for this function:

Member Data Documentation

int Analyzer::ColumnVar::rte_idx
protected

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