OmniSciDB  c1a53651b2
 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)
 
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
 
size_t toHash () const override
 
std::unique_ptr< RexLiteraldeepCopy () const
 
- Public Member Functions inherited from Rex
virtual ~Rex ()
 

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
 

Additional Inherited Members

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

Detailed Description

Definition at line 100 of file RelAlgDag.h.

Constructor & Destructor Documentation

RexLiteral::RexLiteral ( )
inline

Definition at line 103 of file RelAlgDag.h.

Referenced by toHash().

unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
unsigned target_precision_
Definition: RelAlgDag.h:247

+ Here is the caller graph for this function:

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 106 of file RelAlgDag.h.

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

113  : literal_(val)
114  , type_(type)
115  , target_type_(target_type)
116  , scale_(scale)
117  , precision_(precision)
118  , target_scale_(target_scale)
119  , target_precision_(target_precision) {
122  type == kINT);
123  }
SQLTypes target_type_
Definition: RelAlgDag.h:243
unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
unsigned target_precision_
Definition: RelAlgDag.h:247
#define CHECK(condition)
Definition: Logger.h:291
SQLTypes type_
Definition: RelAlgDag.h:242
Definition: sqltypes.h:62
constexpr auto is_datetime(SQLTypes type)
Definition: sqltypes.h:315

+ 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 125 of file RelAlgDag.h.

References CHECK_EQ, and kDOUBLE.

132  : literal_(val)
133  , type_(type)
134  , target_type_(target_type)
135  , scale_(scale)
136  , precision_(precision)
137  , target_scale_(target_scale)
138  , target_precision_(target_precision) {
140  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
SQLTypes target_type_
Definition: RelAlgDag.h:243
unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
unsigned target_precision_
Definition: RelAlgDag.h:247
SQLTypes type_
Definition: RelAlgDag.h:242
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 142 of file RelAlgDag.h.

References CHECK_EQ, and kTEXT.

149  : literal_(val)
150  , type_(type)
151  , target_type_(target_type)
152  , scale_(scale)
153  , precision_(precision)
154  , target_scale_(target_scale)
155  , target_precision_(target_precision) {
156  CHECK_EQ(kTEXT, type);
157  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
SQLTypes target_type_
Definition: RelAlgDag.h:243
unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
Definition: sqltypes.h:69
unsigned target_precision_
Definition: RelAlgDag.h:247
SQLTypes type_
Definition: RelAlgDag.h:242
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 159 of file RelAlgDag.h.

References CHECK_EQ, and kBOOLEAN.

166  : literal_(val)
167  , type_(type)
168  , target_type_(target_type)
169  , scale_(scale)
170  , precision_(precision)
171  , target_scale_(target_scale)
172  , target_precision_(target_precision) {
174  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
SQLTypes target_type_
Definition: RelAlgDag.h:243
unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
unsigned target_precision_
Definition: RelAlgDag.h:247
SQLTypes type_
Definition: RelAlgDag.h:242
RexLiteral::RexLiteral ( const SQLTypes  target_type)
inline

Definition at line 176 of file RelAlgDag.h.

177  : literal_()
178  , type_(kNULLT)
179  , target_type_(target_type)
180  , scale_(0)
181  , precision_(0)
182  , target_scale_(0)
183  , target_precision_(0) {}
SQLTypes target_type_
Definition: RelAlgDag.h:243
unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
unsigned target_precision_
Definition: RelAlgDag.h:247
SQLTypes type_
Definition: RelAlgDag.h:242

Member Function Documentation

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

Definition at line 236 of file RelAlgDag.h.

236  {
237  return std::make_unique<RexLiteral>(*this);
238  }
unsigned RexLiteral::getPrecision ( ) const
inline

Definition at line 198 of file RelAlgDag.h.

References precision_.

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

Definition at line 196 of file RelAlgDag.h.

References scale_.

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

Definition at line 202 of file RelAlgDag.h.

References target_precision_.

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

Definition at line 200 of file RelAlgDag.h.

References target_scale_.

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

Definition at line 194 of file RelAlgDag.h.

References target_type_.

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

Definition at line 192 of file RelAlgDag.h.

References type_.

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

Definition at line 186 of file RelAlgDag.h.

References CHECK, and literal_.

186  {
187  const auto ptr = boost::get<T>(&literal_);
188  CHECK(ptr);
189  return *ptr;
190  }
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
#define CHECK(condition)
Definition: Logger.h:291
size_t RexLiteral::toHash ( ) const
inlineoverridevirtual

Implements Rex.

Definition at line 213 of file RelAlgDag.h.

References Rex::hash_, literal_, precision_, RexLiteral(), scale_, heavydb.dtypes::T, target_precision_, target_scale_, target_type_, and type_.

213  {
214  if (!hash_) {
215  hash_ = typeid(RexLiteral).hash_code();
216  boost::apply_visitor(
217  [this](auto&& current_val) {
218  using T = std::decay_t<decltype(current_val)>;
219  if constexpr (!std::is_same_v<boost::blank, T>) {
220  static_assert(std::is_same_v<int64_t, T> || std::is_same_v<double, T> ||
221  std::is_same_v<std::string, T> || std::is_same_v<bool, T>);
222  boost::hash_combine(*hash_, current_val);
223  }
224  },
225  literal_);
226  boost::hash_combine(*hash_, type_);
227  boost::hash_combine(*hash_, target_type_);
228  boost::hash_combine(*hash_, scale_);
229  boost::hash_combine(*hash_, precision_);
230  boost::hash_combine(*hash_, target_scale_);
231  boost::hash_combine(*hash_, target_precision_);
232  }
233  return *hash_;
234  }
SQLTypes target_type_
Definition: RelAlgDag.h:243
unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
std::optional< size_t > hash_
Definition: RelAlgDag.h:62
unsigned target_precision_
Definition: RelAlgDag.h:247
SQLTypes type_
Definition: RelAlgDag.h:242

+ Here is the call graph for this function:

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

Implements Rex.

Definition at line 204 of file RelAlgDag.h.

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

205  {
206  std::ostringstream oss;
207  oss << "RexLiteral(" << literal_ << " type=" << type_ << '(' << precision_ << ','
208  << scale_ << ") target_type=" << target_type_ << '(' << target_precision_ << ','
209  << target_scale_ << "))";
210  return oss.str();
211  }
SQLTypes target_type_
Definition: RelAlgDag.h:243
unsigned target_scale_
Definition: RelAlgDag.h:246
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
Definition: RelAlgDag.h:241
unsigned precision_
Definition: RelAlgDag.h:245
unsigned scale_
Definition: RelAlgDag.h:244
unsigned target_precision_
Definition: RelAlgDag.h:247
SQLTypes type_
Definition: RelAlgDag.h:242

Friends And Related Function Documentation

friend struct RelAlgDagSerializer
friend

Definition at line 249 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 241 of file RelAlgDag.h.

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

unsigned RexLiteral::precision_
private

Definition at line 245 of file RelAlgDag.h.

Referenced by getPrecision(), toHash(), and toString().

unsigned RexLiteral::scale_
private

Definition at line 244 of file RelAlgDag.h.

Referenced by getScale(), toHash(), and toString().

unsigned RexLiteral::target_precision_
private

Definition at line 247 of file RelAlgDag.h.

Referenced by getTargetPrecision(), toHash(), and toString().

unsigned RexLiteral::target_scale_
private

Definition at line 246 of file RelAlgDag.h.

Referenced by getTargetScale(), toHash(), and toString().

SQLTypes RexLiteral::target_type_
private

Definition at line 243 of file RelAlgDag.h.

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

SQLTypes RexLiteral::type_
private

Definition at line 242 of file RelAlgDag.h.

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


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