OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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
 
void set_rte_idx (int new_rte_idx)
 
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 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 (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 196 of file Analyzer.h.

Constructor & Destructor Documentation

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

Definition at line 198 of file Analyzer.h.

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

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

References column_id, and table_id.

1433  {
1434  if (!groupby.empty()) {
1435  for (auto e : groupby) {
1436  auto c = std::dynamic_pointer_cast<ColumnVar>(e);
1437  if (c && table_id == c->get_table_id() && column_id == c->get_column_id()) {
1438  return;
1439  }
1440  }
1441  }
1442  throw std::runtime_error(
1443  "expressions in the SELECT or HAVING clause must be an aggregate function or an "
1444  "expression "
1445  "over GROUP BY columns.");
1446 }
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:198
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 220 of file Analyzer.h.

Referenced by RelAlgTranslator::translateWindowFunction().

223  {
224  colvar_set.insert(this);
225  }

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

References rte_idx.

212  {
213  rte_idx_set.insert(rte_idx);
214  }
static bool Analyzer::ColumnVar::colvar_comp ( const ColumnVar l,
const ColumnVar r 
)
inlinestatic

Definition at line 215 of file Analyzer.h.

References get_column_id(), and get_table_id().

Referenced by Analyzer::Expr::get_num_column_vars(), Analyzer::StringOper::hasSingleDictEncodedColInput(), RelAlgTranslator::translateWindowFunction(), and anonymous_namespace{FromTableReordering.cpp}::traverse_join_cost_graph().

215  {
216  return l->get_table_id() < r->get_table_id() ||
217  (l->get_table_id() == r->get_table_id() &&
218  l->get_column_id() < r->get_column_id());
219  }

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

66  {
67  return makeExpr<ColumnVar>(type_info, table_id, column_id, rte_idx);
68 }
SQLTypeInfo type_info
Definition: Analyzer.h:182

+ Here is the caller graph for this function:

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

Definition at line 205 of file Analyzer.h.

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

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

205 { return type_info.get_comp_param(); }
SQLTypeInfo type_info
Definition: Analyzer.h:182
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338

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

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

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

204 { return type_info.get_compression(); }
SQLTypeInfo type_info
Definition: Analyzer.h:182
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337

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

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

1544  {
1545  if (type_info.get_type() == kBOOLEAN) {
1546  scan_predicates.push_back(this);
1547  }
1548 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
SQLTypeInfo type_info
Definition: Analyzer.h:182

+ Here is the call graph for this function:

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

Implements Analyzer::Expr.

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

2154  {
2155  if (typeid(rhs) != typeid(ColumnVar) && typeid(rhs) != typeid(Var)) {
2156  return false;
2157  }
2158  const ColumnVar& rhs_cv = dynamic_cast<const ColumnVar&>(rhs);
2159  if (rte_idx != -1) {
2160  return (table_id == rhs_cv.get_table_id()) && (column_id == rhs_cv.get_column_id()) &&
2161  (rte_idx == rhs_cv.get_rte_idx());
2162  }
2163  const Var* v = dynamic_cast<const Var*>(this);
2164  if (v == nullptr) {
2165  return false;
2166  }
2167  const Var* rv = dynamic_cast<const Var*>(&rhs);
2168  if (rv == nullptr) {
2169  return false;
2170  }
2171  return (v->get_which_row() == rv->get_which_row()) &&
2172  (v->get_varno() == rv->get_varno());
2173 }
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:198

+ 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 1891 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.

1892  {
1893  int varno = 1;
1894  for (auto tle : tlist) {
1895  const Expr* e = tle->get_expr();
1896  if (typeid(*e) != typeid(AggExpr)) {
1897  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1898  if (colvar == nullptr) {
1899  throw std::runtime_error(
1900  "Internal Error: targetlist in rewrite_agg_to_var is not all columns and "
1901  "aggregates.");
1902  }
1903  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1904  return makeExpr<Var>(colvar->get_type_info(),
1905  colvar->get_table_id(),
1906  colvar->get_column_id(),
1907  colvar->get_rte_idx(),
1909  varno);
1910  }
1911  }
1912  varno++;
1913  }
1914  throw std::runtime_error(
1915  "Internal error: cannot find ColumnVar from having clause in targetlist.");
1916 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:72
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:198

+ 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 1867 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.

1868  {
1869  int varno = 1;
1870  for (auto tle : tlist) {
1871  const Expr* e = tle->get_expr();
1872  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1873  if (colvar == nullptr) {
1874  throw std::runtime_error(
1875  "Internal Error: targetlist in rewrite_with_child_targetlist is not all "
1876  "columns.");
1877  }
1878  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1879  return makeExpr<Var>(colvar->get_type_info(),
1880  colvar->get_table_id(),
1881  colvar->get_column_id(),
1882  colvar->get_rte_idx(),
1884  varno);
1885  }
1886  varno++;
1887  }
1888  throw std::runtime_error("Internal error: cannot find ColumnVar in child targetlist.");
1889 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:72
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:198

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

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

1854  {
1855  for (auto tle : tlist) {
1856  const Expr* e = tle->get_expr();
1857  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1858  if (colvar != nullptr) {
1859  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1860  return colvar->deep_copy();
1861  }
1862  }
1863  }
1864  throw std::runtime_error("Internal error: cannot find ColumnVar in targetlist.");
1865 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:72
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:198

+ Here is the call graph for this function:

void Analyzer::ColumnVar::set_rte_idx ( int  new_rte_idx)
inline

Definition at line 203 of file Analyzer.h.

References rte_idx.

203 { rte_idx = new_rte_idx; }
std::string Analyzer::ColumnVar::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 2564 of file Analyzer.cpp.

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

Referenced by PerfectJoinHashTable::getAlternativeCacheKey().

2564  {
2565  return "(ColumnVar table: " + std::to_string(table_id) +
2566  " column: " + std::to_string(column_id) + " rte: " + std::to_string(rte_idx) +
2567  " " + get_type_info().get_type_name() + ") ";
2568 }
std::string to_string(char const *&&v)
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:81
std::string get_type_name() const
Definition: sqltypes.h:443

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

int Analyzer::ColumnVar::rte_idx
protected

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