OmniSciDB  b24e664e58
 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 413 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 415 of file ParserNode.h.

References CHECK(), and value_list.

415  : InExpr(n, a) {
416  CHECK(v);
417  for (const auto e : *v) {
418  value_list.emplace_back(e);
419  }
420  delete v;
421  }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:430
CHECK(cgen_state)
InExpr(bool n, Expr *a)
Definition: ParserNode.h:377

+ 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 364 of file ParserNode.cpp.

References Analyzer::BinOper::common_numeric_type(), Analyzer::BinOper::common_string_type(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_number(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_string(), kBOOLEAN, kENCODING_DICT, kNOT, and run_benchmark_import::result.

367  {
368  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
369  SQLTypeInfo ti = arg_expr->get_type_info();
370  bool dict_comp = ti.get_compression() == kENCODING_DICT;
371  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
372  for (auto& p : value_list) {
373  auto e = p->analyze(catalog, query, allow_tlist_ref);
374  if (ti != e->get_type_info()) {
375  if (ti.is_string() && e->get_type_info().is_string()) {
376  ti = Analyzer::BinOper::common_string_type(ti, e->get_type_info());
377  } else if (ti.is_number() && e->get_type_info().is_number()) {
378  ti = Analyzer::BinOper::common_numeric_type(ti, e->get_type_info());
379  } else {
380  throw std::runtime_error("IN expressions must contain compatible types.");
381  }
382  }
383  if (dict_comp) {
384  value_exprs.push_back(e->add_cast(arg_expr->get_type_info()));
385  } else {
386  value_exprs.push_back(e);
387  }
388  }
389  if (!dict_comp) {
390  arg_expr = arg_expr->decompress();
391  arg_expr = arg_expr->add_cast(ti);
392  std::list<std::shared_ptr<Analyzer::Expr>> cast_vals;
393  for (auto p : value_exprs) {
394  cast_vals.push_back(p->add_cast(ti));
395  }
396  value_exprs.swap(cast_vals);
397  }
398  std::shared_ptr<Analyzer::Expr> result =
399  makeExpr<Analyzer::InValues>(arg_expr, value_exprs);
400  if (is_not) {
401  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
402  }
403  return result;
404 }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
std::unique_ptr< Expr > arg
Definition: ParserNode.h:388
bool is_number() const
Definition: sqltypes.h:482
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:430
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:387
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:427
bool is_string() const
Definition: sqltypes.h:477
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 422 of file ParserNode.h.

References value_list.

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

Reimplemented from Parser::InExpr.

Definition at line 1401 of file ParserNode.cpp.

References to_string().

1401  {
1402  std::string str = InExpr::to_string() + "(";
1403  bool notfirst = false;
1404  for (auto& p : value_list) {
1405  if (notfirst) {
1406  str += ", ";
1407  } else {
1408  notfirst = true;
1409  }
1410  str += p->to_string();
1411  }
1412  str += ")";
1413  return str;
1414 }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:430
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 430 of file ParserNode.h.

Referenced by get_value_list(), and InValues().


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