OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RexLiteral Class Reference

#include <RelAlgDag.h>

+ Inheritance diagram for RexLiteral:
+ Collaboration diagram for RexLiteral:

Public Member Functions

 RexLiteral ()
 
 RexLiteral (const int64_t val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
 
 RexLiteral (const double val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
 
 RexLiteral (const std::string &val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
 
 RexLiteral (const bool val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
 
 RexLiteral (const SQLTypes target_type)
 
virtual void acceptChildren (Visitor &v) const override
 
virtual void accept (Visitor &v, std::string name) const override
 
template<class T >
getVal () const
 
SQLTypes getType () const
 
SQLTypes getTargetType () const
 
unsigned getScale () const
 
unsigned getPrecision () const
 
unsigned getTargetScale () const
 
unsigned getTargetPrecision () const
 
std::string toString (RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
 
std::unique_ptr< RexLiteraldeepCopy () const
 
virtual size_t toHash () const override
 
- Public Member Functions inherited from Rex
virtual ~Rex ()
 
virtual size_t getStepNumber () const
 
- Public Member Functions inherited from RelAlgDagNode
 RelAlgDagNode ()
 
virtual void setStepNumber (size_t step) const
 
std::optional< size_t > getIdInPlanTree () const
 
void setIdInPlanTree (size_t id) const
 

Private Attributes

boost::variant< boost::blank,
int64_t, double, std::string,
bool > 
literal_
 
SQLTypes type_
 
SQLTypes target_type_
 
unsigned scale_
 
unsigned precision_
 
unsigned target_scale_
 
unsigned target_precision_
 

Friends

struct RelAlgDagSerializer
 
std::size_t hash_value (RexLiteral const &)
 

Additional Inherited Members

- Protected Attributes inherited from Rex
std::optional< size_t > hash_
 
- Protected Attributes inherited from RelAlgDagNode
size_t step_ {0}
 
std::optional< size_t > id_in_plan_tree_
 

Detailed Description

Definition at line 193 of file RelAlgDag.h.

Constructor & Destructor Documentation

RexLiteral::RexLiteral ( )
inline

Definition at line 196 of file RelAlgDag.h.

unsigned target_scale_
Definition: RelAlgDag.h:327
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
unsigned precision_
Definition: RelAlgDag.h:326
unsigned scale_
Definition: RelAlgDag.h:325
unsigned target_precision_
Definition: RelAlgDag.h:328
RexLiteral::RexLiteral ( const int64_t  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  target_scale,
const unsigned  target_precision 
)
inline

Definition at line 199 of file RelAlgDag.h.

References CHECK, is_datetime(), kBIGINT, kDECIMAL, kINT, kINTERVAL_DAY_TIME, and kINTERVAL_YEAR_MONTH.

206  : literal_(val)
207  , type_(type)
208  , target_type_(target_type)
209  , scale_(scale)
210  , precision_(precision)
211  , target_scale_(target_scale)
212  , target_precision_(target_precision) {
215  type == kINT);
216  }
SQLTypes target_type_
Definition: RelAlgDag.h:324
unsigned target_scale_
Definition: RelAlgDag.h:327
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
unsigned precision_
Definition: RelAlgDag.h:326
unsigned scale_
Definition: RelAlgDag.h:325
unsigned target_precision_
Definition: RelAlgDag.h:328
#define CHECK(condition)
Definition: Logger.h:291
SQLTypes type_
Definition: RelAlgDag.h:323
Definition: sqltypes.h:72
constexpr auto is_datetime(SQLTypes type)
Definition: sqltypes.h:325

+ Here is the call graph for this function:

RexLiteral::RexLiteral ( const double  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  target_scale,
const unsigned  target_precision 
)
inline

Definition at line 218 of file RelAlgDag.h.

References CHECK_EQ, and kDOUBLE.

225  : literal_(val)
226  , type_(type)
227  , target_type_(target_type)
228  , scale_(scale)
229  , precision_(precision)
230  , target_scale_(target_scale)
231  , target_precision_(target_precision) {
233  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
SQLTypes target_type_
Definition: RelAlgDag.h:324
unsigned target_scale_
Definition: RelAlgDag.h:327
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
unsigned precision_
Definition: RelAlgDag.h:326
unsigned scale_
Definition: RelAlgDag.h:325
unsigned target_precision_
Definition: RelAlgDag.h:328
SQLTypes type_
Definition: RelAlgDag.h:323
RexLiteral::RexLiteral ( const std::string &  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  target_scale,
const unsigned  target_precision 
)
inline

Definition at line 235 of file RelAlgDag.h.

References CHECK_EQ, and kTEXT.

242  : literal_(val)
243  , type_(type)
244  , target_type_(target_type)
245  , scale_(scale)
246  , precision_(precision)
247  , target_scale_(target_scale)
248  , target_precision_(target_precision) {
249  CHECK_EQ(kTEXT, type);
250  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
SQLTypes target_type_
Definition: RelAlgDag.h:324
unsigned target_scale_
Definition: RelAlgDag.h:327
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
unsigned precision_
Definition: RelAlgDag.h:326
unsigned scale_
Definition: RelAlgDag.h:325
Definition: sqltypes.h:79
unsigned target_precision_
Definition: RelAlgDag.h:328
SQLTypes type_
Definition: RelAlgDag.h:323
RexLiteral::RexLiteral ( const bool  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  target_scale,
const unsigned  target_precision 
)
inline

Definition at line 252 of file RelAlgDag.h.

References CHECK_EQ, and kBOOLEAN.

259  : literal_(val)
260  , type_(type)
261  , target_type_(target_type)
262  , scale_(scale)
263  , precision_(precision)
264  , target_scale_(target_scale)
265  , target_precision_(target_precision) {
267  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
SQLTypes target_type_
Definition: RelAlgDag.h:324
unsigned target_scale_
Definition: RelAlgDag.h:327
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
unsigned precision_
Definition: RelAlgDag.h:326
unsigned scale_
Definition: RelAlgDag.h:325
unsigned target_precision_
Definition: RelAlgDag.h:328
SQLTypes type_
Definition: RelAlgDag.h:323
RexLiteral::RexLiteral ( const SQLTypes  target_type)
inline

Definition at line 269 of file RelAlgDag.h.

270  : literal_()
271  , type_(kNULLT)
272  , target_type_(target_type)
273  , scale_(0)
274  , precision_(0)
275  , target_scale_(0)
276  , target_precision_(0) {}
SQLTypes target_type_
Definition: RelAlgDag.h:324
unsigned target_scale_
Definition: RelAlgDag.h:327
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
unsigned precision_
Definition: RelAlgDag.h:326
unsigned scale_
Definition: RelAlgDag.h:325
unsigned target_precision_
Definition: RelAlgDag.h:328
SQLTypes type_
Definition: RelAlgDag.h:323

Member Function Documentation

virtual void RexLiteral::accept ( Visitor v,
std::string  name 
) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 279 of file RelAlgDag.h.

References RelAlgDagNode::acceptChildren(), and RelAlgDagNode::Visitor::visit().

Referenced by TableFunctionsFactory_node.PrintNode::__str__().

279  {
280  if (v.visit(this, std::move(name))) {
281  acceptChildren(v);
282  }
283  }
virtual void acceptChildren(Visitor &v) const override
Definition: RelAlgDag.h:278
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void RexLiteral::acceptChildren ( Visitor v) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 278 of file RelAlgDag.h.

278 {}
std::unique_ptr<RexLiteral> RexLiteral::deepCopy ( ) const
inline

Definition at line 313 of file RelAlgDag.h.

313  {
314  return std::make_unique<RexLiteral>(*this);
315  }
unsigned RexLiteral::getPrecision ( ) const
inline

Definition at line 298 of file RelAlgDag.h.

References precision_.

298 { return precision_; }
unsigned precision_
Definition: RelAlgDag.h:326
unsigned RexLiteral::getScale ( ) const
inline

Definition at line 296 of file RelAlgDag.h.

References scale_.

296 { return scale_; }
unsigned scale_
Definition: RelAlgDag.h:325
unsigned RexLiteral::getTargetPrecision ( ) const
inline

Definition at line 302 of file RelAlgDag.h.

References target_precision_.

302 { return target_precision_; }
unsigned target_precision_
Definition: RelAlgDag.h:328
unsigned RexLiteral::getTargetScale ( ) const
inline

Definition at line 300 of file RelAlgDag.h.

References target_scale_.

300 { return target_scale_; }
unsigned target_scale_
Definition: RelAlgDag.h:327
SQLTypes RexLiteral::getTargetType ( ) const
inline

Definition at line 294 of file RelAlgDag.h.

References target_type_.

294 { return target_type_; }
SQLTypes target_type_
Definition: RelAlgDag.h:324
SQLTypes RexLiteral::getType ( ) const
inline

Definition at line 292 of file RelAlgDag.h.

References type_.

292 { return type_; }
SQLTypes type_
Definition: RelAlgDag.h:323
template<class T >
T RexLiteral::getVal ( ) const
inline

Definition at line 286 of file RelAlgDag.h.

References CHECK, and literal_.

286  {
287  const auto ptr = boost::get<T>(&literal_);
288  CHECK(ptr);
289  return *ptr;
290  }
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t RexLiteral::toHash ( ) const
inlineoverridevirtual

Implements Rex.

Definition at line 317 of file RelAlgDag.h.

References hash_value().

317 { return hash_value(*this); }
friend std::size_t hash_value(RexLiteral const &)
Definition: RelAlgDag.cpp:3534

+ Here is the call graph for this function:

std::string RexLiteral::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 304 of file RelAlgDag.h.

References literal_, precision_, scale_, target_precision_, target_scale_, target_type_, and type_.

305  {
306  std::ostringstream oss;
307  oss << "RexLiteral(" << literal_ << " type=" << type_ << '(' << precision_ << ','
308  << scale_ << ") target_type=" << target_type_ << '(' << target_precision_ << ','
309  << target_scale_ << "))";
310  return oss.str();
311  }
SQLTypes target_type_
Definition: RelAlgDag.h:324
unsigned target_scale_
Definition: RelAlgDag.h:327
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:322
unsigned precision_
Definition: RelAlgDag.h:326
unsigned scale_
Definition: RelAlgDag.h:325
unsigned target_precision_
Definition: RelAlgDag.h:328
SQLTypes type_
Definition: RelAlgDag.h:323

Friends And Related Function Documentation

std::size_t hash_value ( RexLiteral const &  rex_literal)
friend

Definition at line 3534 of file RelAlgDag.cpp.

3534  {
3535  if (rex_literal.hash_) {
3536  return *rex_literal.hash_;
3537  }
3538  rex_literal.hash_ = typeid(RexLiteral).hash_code();
3539  boost::apply_visitor(
3540  [&rex_literal](auto&& current_val) {
3541  using T = std::decay_t<decltype(current_val)>;
3542  if constexpr (!std::is_same_v<boost::blank, T>) {
3543  static_assert(std::is_same_v<int64_t, T> || std::is_same_v<double, T> ||
3544  std::is_same_v<std::string, T> || std::is_same_v<bool, T>);
3545  boost::hash_combine(*rex_literal.hash_, current_val);
3546  }
3547  },
3548  rex_literal.literal_);
3549  boost::hash_combine(*rex_literal.hash_, rex_literal.type_);
3550  boost::hash_combine(*rex_literal.hash_, rex_literal.target_type_);
3551  boost::hash_combine(*rex_literal.hash_, rex_literal.scale_);
3552  boost::hash_combine(*rex_literal.hash_, rex_literal.precision_);
3553  boost::hash_combine(*rex_literal.hash_, rex_literal.target_scale_);
3554  boost::hash_combine(*rex_literal.hash_, rex_literal.target_precision_);
3555  return *rex_literal.hash_;
3556 }
friend struct RelAlgDagSerializer
friend

Definition at line 330 of file RelAlgDag.h.

Member Data Documentation

boost::variant<boost::blank, int64_t, double, std::string, bool> RexLiteral::literal_
private

Definition at line 322 of file RelAlgDag.h.

Referenced by getVal(), and toString().

unsigned RexLiteral::precision_
private

Definition at line 326 of file RelAlgDag.h.

Referenced by getPrecision(), and toString().

unsigned RexLiteral::scale_
private

Definition at line 325 of file RelAlgDag.h.

Referenced by getScale(), and toString().

unsigned RexLiteral::target_precision_
private

Definition at line 328 of file RelAlgDag.h.

Referenced by getTargetPrecision(), and toString().

unsigned RexLiteral::target_scale_
private

Definition at line 327 of file RelAlgDag.h.

Referenced by getTargetScale(), and toString().

SQLTypes RexLiteral::target_type_
private

Definition at line 324 of file RelAlgDag.h.

Referenced by getTargetType(), and toString().

SQLTypes RexLiteral::type_
private

Definition at line 323 of file RelAlgDag.h.

Referenced by getType(), and toString().


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