OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::InValues Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::InValues:
+ Collaboration diagram for Parser::InValues:

Public Member Functions

 InValues (bool n, Expr *a, std::list< Expr * > *v)
 
const std::list
< std::unique_ptr< Expr > > & 
get_value_list () const
 
std::shared_ptr< Analyzer::Expranalyze (const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
 
std::string to_string () const override
 
- Public Member Functions inherited from Parser::InExpr
 InExpr (bool n, Expr *a)
 
bool get_is_not () const
 
const Exprget_arg () const
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Private Attributes

std::list< std::unique_ptr
< Expr > > 
value_list
 

Additional Inherited Members

- Public Types inherited from Parser::Expr
enum  TlistRefType { TLIST_NONE, TLIST_REF, TLIST_COPY }
 
- Protected Attributes inherited from Parser::InExpr
bool is_not
 
std::unique_ptr< Exprarg
 

Detailed Description

Definition at line 397 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::InValues::InValues ( bool  n,
Expr a,
std::list< Expr * > *  v 
)
inline

Definition at line 399 of file ParserNode.h.

References CHECK(), and value_list.

399  : InExpr(n, a) {
400  CHECK(v);
401  for (const auto e : *v) {
402  value_list.emplace_back(e);
403  }
404  delete v;
405  }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
CHECK(cgen_state)
InExpr(bool n, Expr *a)
Definition: ParserNode.h:361

+ Here is the call graph for this function:

Member Function Documentation

std::shared_ptr< Analyzer::Expr > Parser::InValues::analyze ( const Catalog_Namespace::Catalog catalog,
Analyzer::Query query,
TlistRefType  allow_tlist_ref = TLIST_NONE 
) const
overridevirtual

Implements Parser::InExpr.

Definition at line 381 of file ParserNode.cpp.

References Analyzer::BinOper::common_numeric_type(), Analyzer::BinOper::common_string_type(), SQLTypeInfo::get_compression(), SQLTypeInfo::is_number(), SQLTypeInfo::is_string(), kBOOLEAN, kENCODING_DICT, kNOT, and run_benchmark_import::result.

384  {
385  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
386  SQLTypeInfo ti = arg_expr->get_type_info();
387  bool dict_comp = ti.get_compression() == kENCODING_DICT;
388  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
389  for (auto& p : value_list) {
390  auto e = p->analyze(catalog, query, allow_tlist_ref);
391  if (ti != e->get_type_info()) {
392  if (ti.is_string() && e->get_type_info().is_string()) {
393  ti = Analyzer::BinOper::common_string_type(ti, e->get_type_info());
394  } else if (ti.is_number() && e->get_type_info().is_number()) {
395  ti = Analyzer::BinOper::common_numeric_type(ti, e->get_type_info());
396  } else {
397  throw std::runtime_error("IN expressions must contain compatible types.");
398  }
399  }
400  if (dict_comp) {
401  value_exprs.push_back(e->add_cast(arg_expr->get_type_info()));
402  } else {
403  value_exprs.push_back(e);
404  }
405  }
406  if (!dict_comp) {
407  arg_expr = arg_expr->decompress();
408  arg_expr = arg_expr->add_cast(ti);
409  std::list<std::shared_ptr<Analyzer::Expr>> cast_vals;
410  for (auto p : value_exprs) {
411  cast_vals.push_back(p->add_cast(ti));
412  }
413  value_exprs.swap(cast_vals);
414  }
415  std::shared_ptr<Analyzer::Expr> result =
416  makeExpr<Analyzer::InValues>(arg_expr, value_exprs);
417  if (is_not) {
418  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
419  }
420  return result;
421 }
bool is_number() const
Definition: sqltypes.h:420
std::unique_ptr< Expr > arg
Definition: ParserNode.h:372
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:398
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:438
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:266
bool is_string() const
Definition: sqltypes.h:415
Definition: sqldefs.h:39

+ Here is the call graph for this function:

const std::list<std::unique_ptr<Expr> >& Parser::InValues::get_value_list ( ) const
inline

Definition at line 406 of file ParserNode.h.

References value_list.

406 { return value_list; }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
std::string Parser::InValues::to_string ( ) const
overridevirtual

Reimplemented from Parser::InExpr.

Definition at line 1345 of file ParserNode.cpp.

References to_string().

1345  {
1346  std::string str = InExpr::to_string() + "(";
1347  bool notfirst = false;
1348  for (auto& p : value_list) {
1349  if (notfirst) {
1350  str += ", ";
1351  } else {
1352  notfirst = true;
1353  }
1354  str += p->to_string();
1355  }
1356  str += ")";
1357  return str;
1358 }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
std::string to_string() const override

+ Here is the call graph for this function:

Member Data Documentation

std::list<std::unique_ptr<Expr> > Parser::InValues::value_list
private

Definition at line 414 of file ParserNode.h.

Referenced by get_value_list(), and InValues().


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