OmniSciDB  b24e664e58
 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 1278 of file Analyzer.cpp.

References column_id, and table_id.

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

Referenced by Planner::Optimizer::optimize_scans().

216  {
217  colvar_set.insert(this);
218  }

+ Here is the caller graph for this function:

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().

Referenced by Planner::Optimizer::optimize_aggs(), and Planner::Optimizer::optimize_scans().

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:

+ Here is the caller 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 SQLTypeInfoCore< TYPE_FACET_PACK >::get_comp_param(), and Analyzer::Expr::type_info.

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

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

+ 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 SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), and Analyzer::Expr::type_info.

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

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

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

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kBOOLEAN, and Analyzer::Expr::type_info.

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

+ Here is the call graph for this function:

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

Implements Analyzer::Expr.

Definition at line 1943 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.

1943  {
1944  if (typeid(rhs) != typeid(ColumnVar) && typeid(rhs) != typeid(Var)) {
1945  return false;
1946  }
1947  const ColumnVar& rhs_cv = dynamic_cast<const ColumnVar&>(rhs);
1948  if (rte_idx != -1) {
1949  return (table_id == rhs_cv.get_table_id()) && (column_id == rhs_cv.get_column_id()) &&
1950  (rte_idx == rhs_cv.get_rte_idx());
1951  }
1952  const Var* v = dynamic_cast<const Var*>(this);
1953  if (v == nullptr) {
1954  return false;
1955  }
1956  const Var* rv = dynamic_cast<const Var*>(&rhs);
1957  if (rv == nullptr) {
1958  return false;
1959  }
1960  return (v->get_which_row() == rv->get_which_row()) &&
1961  (v->get_varno() == rv->get_varno());
1962 }
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 1707 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.

1708  {
1709  int varno = 1;
1710  for (auto tle : tlist) {
1711  const Expr* e = tle->get_expr();
1712  if (typeid(*e) != typeid(AggExpr)) {
1713  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1714  if (colvar == nullptr) {
1715  throw std::runtime_error(
1716  "Internal Error: targetlist in rewrite_agg_to_var is not all columns and "
1717  "aggregates.");
1718  }
1719  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1720  return makeExpr<Var>(colvar->get_type_info(),
1721  colvar->get_table_id(),
1722  colvar->get_column_id(),
1723  colvar->get_rte_idx(),
1725  varno);
1726  }
1727  }
1728  varno++;
1729  }
1730  throw std::runtime_error(
1731  "Internal error: cannot find ColumnVar from having clause in targetlist.");
1732 }
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 1683 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.

1684  {
1685  int varno = 1;
1686  for (auto tle : tlist) {
1687  const Expr* e = tle->get_expr();
1688  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1689  if (colvar == nullptr) {
1690  throw std::runtime_error(
1691  "Internal Error: targetlist in rewrite_with_child_targetlist is not all "
1692  "columns.");
1693  }
1694  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1695  return makeExpr<Var>(colvar->get_type_info(),
1696  colvar->get_table_id(),
1697  colvar->get_column_id(),
1698  colvar->get_rte_idx(),
1700  varno);
1701  }
1702  varno++;
1703  }
1704  throw std::runtime_error("Internal error: cannot find ColumnVar in child targetlist.");
1705 }
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 1669 of file Analyzer.cpp.

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

1670  {
1671  for (auto tle : tlist) {
1672  const Expr* e = tle->get_expr();
1673  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1674  if (colvar != nullptr) {
1675  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1676  return colvar->deep_copy();
1677  }
1678  }
1679  }
1680  throw std::runtime_error("Internal error: cannot find ColumnVar in targetlist.");
1681 }
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 2281 of file Analyzer.cpp.

References column_id, Analyzer::Expr::get_type_info(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type_name(), rte_idx, table_id, and to_string().

2281  {
2282  return "(ColumnVar table: " + std::to_string(table_id) +
2283  " column: " + std::to_string(column_id) + " rte: " + std::to_string(rte_idx) +
2284  " " + get_type_info().get_type_name() + ") ";
2285 }
std::string to_string(char const *&&v)
std::string get_type_name() const
Definition: sqltypes.h:429
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78

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