OmniSciDB  343343d194
 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 409 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 411 of file ParserNode.h.

References CHECK, v(), and value_list.

411  : InExpr(n, a) {
412  CHECK(v);
413  for (const auto e : *v) {
414  value_list.emplace_back(e);
415  }
416  delete v;
417  }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:426
T v(const TargetValue &r)
InExpr(bool n, Expr *a)
Definition: ParserNode.h:373
#define CHECK(condition)
Definition: Logger.h:187

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

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

References value_list.

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

Reimplemented from Parser::InExpr.

Definition at line 1389 of file ParserNode.cpp.

References to_string().

1389  {
1390  std::string str = InExpr::to_string() + "(";
1391  bool notfirst = false;
1392  for (auto& p : value_list) {
1393  if (notfirst) {
1394  str += ", ";
1395  } else {
1396  notfirst = true;
1397  }
1398  str += p->to_string();
1399  }
1400  str += ")";
1401  return str;
1402 }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:426
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 426 of file ParserNode.h.

Referenced by get_value_list(), and InValues().


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