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

#include <RelAlgDagBuilder.h>

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

Public Member Functions

 RexLiteral (const int64_t val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned type_scale, const unsigned type_precision)
 
 RexLiteral (const double val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned type_scale, const unsigned type_precision)
 
 RexLiteral (const std::string &val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned type_scale, const unsigned type_precision)
 
 RexLiteral (const bool val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned type_scale, const unsigned type_precision)
 
 RexLiteral (const SQLTypes target_type)
 
template<class T >
getVal () const
 
SQLTypes getType () const
 
SQLTypes getTargetType () const
 
unsigned getScale () const
 
unsigned getPrecision () const
 
unsigned getTypeScale () const
 
unsigned getTypePrecision () const
 
std::string toString () const override
 
size_t toHash () const override
 
std::unique_ptr< RexLiteraldeepCopy () const
 
- Public Member Functions inherited from Rex
virtual ~Rex ()
 

Private Attributes

const boost::variant< int64_t,
double, std::string, bool,
void * > 
literal_
 
const SQLTypes type_
 
const SQLTypes target_type_
 
const unsigned scale_
 
const unsigned precision_
 
const unsigned type_scale_
 
const unsigned type_precision_
 

Additional Inherited Members

- Protected Attributes inherited from Rex
std::optional< size_t > hash_
 

Detailed Description

Definition at line 84 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

RexLiteral::RexLiteral ( const int64_t  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  type_scale,
const unsigned  type_precision 
)
inline

Definition at line 86 of file RelAlgDagBuilder.h.

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

Referenced by toHash().

93  : literal_(val)
94  , type_(type)
95  , target_type_(target_type)
96  , scale_(scale)
97  , precision_(precision)
98  , type_scale_(type_scale)
99  , type_precision_(type_precision) {
102  type == kINT);
103  }
const unsigned type_scale_
const boost::variant< int64_t, double, std::string, bool, void * > literal_
const unsigned precision_
const unsigned type_precision_
const SQLTypes type_
const SQLTypes target_type_
#define CHECK(condition)
Definition: Logger.h:206
Definition: sqltypes.h:44
const unsigned scale_
constexpr auto is_datetime(SQLTypes type)
Definition: sqltypes.h:257

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RexLiteral::RexLiteral ( const double  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  type_scale,
const unsigned  type_precision 
)
inline

Definition at line 105 of file RelAlgDagBuilder.h.

References CHECK_EQ, and kDOUBLE.

112  : literal_(val)
113  , type_(type)
114  , target_type_(target_type)
115  , scale_(scale)
116  , precision_(precision)
117  , type_scale_(type_scale)
118  , type_precision_(type_precision) {
120  }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
const unsigned type_scale_
const boost::variant< int64_t, double, std::string, bool, void * > literal_
const unsigned precision_
const unsigned type_precision_
const SQLTypes type_
const SQLTypes target_type_
const unsigned scale_
RexLiteral::RexLiteral ( const std::string &  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  type_scale,
const unsigned  type_precision 
)
inline

Definition at line 122 of file RelAlgDagBuilder.h.

References CHECK_EQ, and kTEXT.

129  : literal_(val)
130  , type_(type)
131  , target_type_(target_type)
132  , scale_(scale)
133  , precision_(precision)
134  , type_scale_(type_scale)
135  , type_precision_(type_precision) {
136  CHECK_EQ(kTEXT, type);
137  }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
const unsigned type_scale_
const boost::variant< int64_t, double, std::string, bool, void * > literal_
const unsigned precision_
const unsigned type_precision_
const SQLTypes type_
Definition: sqltypes.h:51
const SQLTypes target_type_
const unsigned scale_
RexLiteral::RexLiteral ( const bool  val,
const SQLTypes  type,
const SQLTypes  target_type,
const unsigned  scale,
const unsigned  precision,
const unsigned  type_scale,
const unsigned  type_precision 
)
inline

Definition at line 139 of file RelAlgDagBuilder.h.

References CHECK_EQ, and kBOOLEAN.

146  : literal_(val)
147  , type_(type)
148  , target_type_(target_type)
149  , scale_(scale)
150  , precision_(precision)
151  , type_scale_(type_scale)
152  , type_precision_(type_precision) {
154  }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
const unsigned type_scale_
const boost::variant< int64_t, double, std::string, bool, void * > literal_
const unsigned precision_
const unsigned type_precision_
const SQLTypes type_
const SQLTypes target_type_
const unsigned scale_
RexLiteral::RexLiteral ( const SQLTypes  target_type)
inline

Definition at line 156 of file RelAlgDagBuilder.h.

157  : literal_(nullptr)
158  , type_(kNULLT)
159  , target_type_(target_type)
160  , scale_(0)
161  , precision_(0)
162  , type_scale_(0)
163  , type_precision_(0) {}
const unsigned type_scale_
const boost::variant< int64_t, double, std::string, bool, void * > literal_
const unsigned precision_
const unsigned type_precision_
const SQLTypes type_
const SQLTypes target_type_
const unsigned scale_

Member Function Documentation

std::unique_ptr<RexLiteral> RexLiteral::deepCopy ( ) const
inline

Definition at line 206 of file RelAlgDagBuilder.h.

References CHECK, literal_, precision_, scale_, target_type_, type_, type_precision_, and type_scale_.

206  {
207  switch (literal_.which()) {
208  case 0: {
209  int64_t val = getVal<int64_t>();
210  return std::make_unique<RexLiteral>(
212  }
213  case 1: {
214  double val = getVal<double>();
215  return std::make_unique<RexLiteral>(
217  }
218  case 2: {
219  auto val = getVal<std::string>();
220  return std::make_unique<RexLiteral>(
222  }
223  case 3: {
224  bool val = getVal<bool>();
225  return std::make_unique<RexLiteral>(
227  }
228  case 4: {
229  return std::make_unique<RexLiteral>(target_type_);
230  }
231  default:
232  CHECK(false);
233  }
234  return nullptr;
235  }
const unsigned type_scale_
const boost::variant< int64_t, double, std::string, bool, void * > literal_
const unsigned precision_
const unsigned type_precision_
const SQLTypes type_
const SQLTypes target_type_
#define CHECK(condition)
Definition: Logger.h:206
const unsigned scale_
unsigned RexLiteral::getPrecision ( ) const
inline

Definition at line 178 of file RelAlgDagBuilder.h.

References precision_.

178 { return precision_; }
const unsigned precision_
unsigned RexLiteral::getScale ( ) const
inline

Definition at line 176 of file RelAlgDagBuilder.h.

References scale_.

176 { return scale_; }
const unsigned scale_
SQLTypes RexLiteral::getTargetType ( ) const
inline

Definition at line 174 of file RelAlgDagBuilder.h.

References target_type_.

174 { return target_type_; }
const SQLTypes target_type_
SQLTypes RexLiteral::getType ( ) const
inline

Definition at line 172 of file RelAlgDagBuilder.h.

References type_.

172 { return type_; }
const SQLTypes type_
unsigned RexLiteral::getTypePrecision ( ) const
inline

Definition at line 182 of file RelAlgDagBuilder.h.

References type_precision_.

182 { return type_precision_; }
const unsigned type_precision_
unsigned RexLiteral::getTypeScale ( ) const
inline

Definition at line 180 of file RelAlgDagBuilder.h.

References type_scale_.

180 { return type_scale_; }
const unsigned type_scale_
template<class T >
T RexLiteral::getVal ( ) const
inline

Definition at line 166 of file RelAlgDagBuilder.h.

References CHECK, and literal_.

166  {
167  const auto ptr = boost::get<T>(&literal_);
168  CHECK(ptr);
169  return *ptr;
170  }
const boost::variant< int64_t, double, std::string, bool, void * > literal_
#define CHECK(condition)
Definition: Logger.h:206
size_t RexLiteral::toHash ( ) const
inlineoverridevirtual

Implements Rex.

Definition at line 195 of file RelAlgDagBuilder.h.

References Rex::hash_, kNULLT, literal_, RexLiteral(), target_type_, Rex::toString(), and type_.

195  {
196  if (!hash_) {
197  hash_ = typeid(RexLiteral).hash_code();
198  boost::hash_combine(*hash_, boost::lexical_cast<std::string>(literal_));
199  boost::hash_combine(*hash_, type_ == kNULLT ? "n" : ::toString(type_));
200  boost::hash_combine(*hash_,
201  target_type_ == kNULLT ? "n" : ::toString(target_type_));
202  }
203  return *hash_;
204  }
std::string toString() const override
const boost::variant< int64_t, double, std::string, bool, void * > literal_
std::optional< size_t > hash_
const SQLTypes type_
const SQLTypes target_type_
RexLiteral(const int64_t val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned type_scale, const unsigned type_precision)

+ Here is the call graph for this function:

std::string RexLiteral::toString ( ) const
inlineoverridevirtual

Implements Rex.

Definition at line 184 of file RelAlgDagBuilder.h.

References cat(), kNULLT, literal_, target_type_, Rex::toString(), type_, and typeName().

184  {
185  return cat(::typeName(this),
186  "(",
187  boost::lexical_cast<std::string>(literal_),
188  ", type=",
189  (type_ == kNULLT ? "null" : ::toString(type_)),
190  ", target_type=",
191  (target_type_ == kNULLT ? "null" : ::toString(target_type_)),
192  ")");
193  }
std::string toString() const override
std::string cat(Ts &&...args)
const boost::variant< int64_t, double, std::string, bool, void * > literal_
const SQLTypes type_
std::string typeName(const T *v)
Definition: toString.h:85
const SQLTypes target_type_

+ Here is the call graph for this function:

Member Data Documentation

const boost::variant<int64_t, double, std::string, bool, void*> RexLiteral::literal_
private

Definition at line 238 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), getVal(), toHash(), and toString().

const unsigned RexLiteral::precision_
private

Definition at line 242 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), and getPrecision().

const unsigned RexLiteral::scale_
private

Definition at line 241 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), and getScale().

const SQLTypes RexLiteral::target_type_
private

Definition at line 240 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), getTargetType(), toHash(), and toString().

const SQLTypes RexLiteral::type_
private

Definition at line 239 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), getType(), toHash(), and toString().

const unsigned RexLiteral::type_precision_
private

Definition at line 244 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), and getTypePrecision().

const unsigned RexLiteral::type_scale_
private

Definition at line 243 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), and getTypeScale().


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