OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 403 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 405 of file ParserNode.h.

References CHECK, and value_list_.

405  : InExpr(n, a) {
406  CHECK(v);
407  for (const auto e : *v) {
408  value_list_.emplace_back(e);
409  }
410  delete v;
411  }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:420
constexpr double a
Definition: Utm.h:32
InExpr(bool n, Expr *a)
Definition: ParserNode.h:367
#define CHECK(condition)
Definition: Logger.h:291
constexpr double n
Definition: Utm.h:38

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 533 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.

536  {
537  auto arg_expr = arg_->analyze(catalog, query, allow_tlist_ref);
538  SQLTypeInfo ti = arg_expr->get_type_info();
539  bool dict_comp = ti.get_compression() == kENCODING_DICT;
540  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
541  for (auto& p : value_list_) {
542  auto e = p->analyze(catalog, query, allow_tlist_ref);
543  if (ti != e->get_type_info()) {
544  if (ti.is_string() && e->get_type_info().is_string()) {
545  // Todo(todd): Can we have this leverage the cast framework as well
546  ti = Analyzer::BinOper::common_string_type(ti, e->get_type_info());
547  } else if (ti.is_number() && e->get_type_info().is_number()) {
548  ti = Analyzer::BinOper::common_numeric_type(ti, e->get_type_info());
549  } else {
550  throw std::runtime_error("IN expressions must contain compatible types.");
551  }
552  }
553  if (dict_comp) {
554  value_exprs.push_back(e->add_cast(arg_expr->get_type_info()));
555  } else {
556  value_exprs.push_back(e);
557  }
558  }
559  if (!dict_comp) {
560  arg_expr = arg_expr->decompress();
561  arg_expr = arg_expr->add_cast(ti);
562  std::list<std::shared_ptr<Analyzer::Expr>> cast_vals;
563  for (auto p : value_exprs) {
564  cast_vals.push_back(p->add_cast(ti));
565  }
566  value_exprs.swap(cast_vals);
567  }
568  std::shared_ptr<Analyzer::Expr> result =
569  makeExpr<Analyzer::InValues>(arg_expr, value_exprs);
570  if (is_not_) {
571  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
572  }
573  return result;
574 }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:420
bool is_number() const
Definition: sqltypes.h:574
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:452
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:500
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
bool is_string() const
Definition: sqltypes.h:559
Definition: sqldefs.h:38
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:378

+ 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 412 of file ParserNode.h.

References value_list_.

412 { return value_list_; }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:420
std::string Parser::InValues::to_string ( ) const
overridevirtual

Reimplemented from Parser::InExpr.

Definition at line 2203 of file ParserNode.cpp.

References to_string().

2203  {
2204  std::string str = InExpr::to_string() + "(";
2205  bool notfirst = false;
2206  for (auto& p : value_list_) {
2207  if (notfirst) {
2208  str += ", ";
2209  } else {
2210  notfirst = true;
2211  }
2212  str += p->to_string();
2213  }
2214  str += ")";
2215  return str;
2216 }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:420
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 420 of file ParserNode.h.

Referenced by get_value_list(), and InValues().


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