OmniSciDB  a5dc49c757
 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 534 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.

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

References to_string().

2213  {
2214  std::string str = InExpr::to_string() + "(";
2215  bool notfirst = false;
2216  for (auto& p : value_list_) {
2217  if (notfirst) {
2218  str += ", ";
2219  } else {
2220  notfirst = true;
2221  }
2222  str += p->to_string();
2223  }
2224  str += ")";
2225  return str;
2226 }
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: