OmniSciDB  04ee39c94c
ExpressionRange Class Reference

#include <ExpressionRange.h>

Public Member Functions

int64_t getIntMin () const
 
int64_t getIntMax () const
 
double getFpMin () const
 
double getFpMax () const
 
void setIntMin (const int64_t int_min)
 
void setIntMax (const int64_t int_max)
 
void setIntInvalidRange ()
 
void setFpMin (const double fp_min)
 
void setFpMax (const double fp_max)
 
ExpressionRangeType getType () const
 
int64_t getBucket () const
 
bool hasNulls () const
 
void setHasNulls ()
 
ExpressionRange operator+ (const ExpressionRange &other) const
 
ExpressionRange operator- (const ExpressionRange &other) const
 
ExpressionRange operator* (const ExpressionRange &other) const
 
ExpressionRange operator/ (const ExpressionRange &other) const
 
ExpressionRange operator|| (const ExpressionRange &other) const
 
bool operator== (const ExpressionRange &other) const
 

Static Public Member Functions

static ExpressionRange makeIntRange (const int64_t int_min, const int64_t int_max, const int64_t bucket, const bool has_nulls)
 
static ExpressionRange makeDoubleRange (const double fp_min, const double fp_max, const bool has_nulls)
 
static ExpressionRange makeFloatRange (const float fp_min, const float fp_max, const bool has_nulls)
 
static ExpressionRange makeNullRange ()
 
static ExpressionRange makeInvalidRange ()
 

Private Member Functions

 ExpressionRange (const int64_t int_min_in, const int64_t int_max_in, const int64_t bucket, const bool has_nulls_in)
 
 ExpressionRange (const ExpressionRangeType type, const double fp_min_in, const double fp_max_in, const bool has_nulls_in)
 
 ExpressionRange ()
 
 ExpressionRange (const ExpressionRangeType type)
 
template<class T , class BinOp >
ExpressionRange binOp (const ExpressionRange &other, const BinOp &bin_op) const
 

Private Attributes

ExpressionRangeType type_
 
bool has_nulls_
 
union {
   int64_t   int_min_
 
   double   fp_min_
 
}; 
 
union {
   int64_t   int_max_
 
   double   fp_max_
 
}; 
 
int64_t bucket_
 

Detailed Description

Definition at line 47 of file ExpressionRange.h.

Constructor & Destructor Documentation

◆ ExpressionRange() [1/4]

ExpressionRange::ExpressionRange ( const int64_t  int_min_in,
const int64_t  int_max_in,
const int64_t  bucket,
const bool  has_nulls_in 
)
inlineprivate

Definition at line 143 of file ExpressionRange.h.

148  , has_nulls_(has_nulls_in)
149  , int_min_(int_min_in)
150  , int_max_(int_max_in)
151  , bucket_(bucket) {}
ExpressionRangeType type_

◆ ExpressionRange() [2/4]

ExpressionRange::ExpressionRange ( const ExpressionRangeType  type,
const double  fp_min_in,
const double  fp_max_in,
const bool  has_nulls_in 
)
inlineprivate

Definition at line 153 of file ExpressionRange.h.

References CHECK, Double, and Float.

157  : type_(type)
158  , has_nulls_(has_nulls_in)
159  , fp_min_(fp_min_in)
160  , fp_max_(fp_max_in)
161  , bucket_(0) {
163  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187

◆ ExpressionRange() [3/4]

ExpressionRange::ExpressionRange ( )
inlineprivate

◆ ExpressionRange() [4/4]

ExpressionRange::ExpressionRange ( const ExpressionRangeType  type)
inlineexplicitprivate

Definition at line 168 of file ExpressionRange.h.

References CHECK, and Null.

169  : type_(type), has_nulls_(true), bucket_(0) {
171  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187

Member Function Documentation

◆ binOp()

template<class T , class BinOp >
ExpressionRange ExpressionRange::binOp ( const ExpressionRange other,
const BinOp &  bin_op 
) const
inlineprivate

Definition at line 174 of file ExpressionRange.h.

References CHECK, Double, Float, fp_max_, fp_min_, has_nulls_, int_max_, int_min_, Integer, makeInvalidRange(), run-benchmark-import::result, and type_.

174  {
175  CHECK(type_ == other.type_);
176  try {
177  std::vector<T> limits{bin_op(getMin<T>(*this), getMin<T>(other)),
178  bin_op(getMin<T>(*this), getMax<T>(other)),
179  bin_op(getMax<T>(*this), getMin<T>(other)),
180  bin_op(getMax<T>(*this), getMax<T>(other))};
182  result.type_ = type_;
183  result.has_nulls_ = has_nulls_ || other.has_nulls_;
184  switch (result.type_) {
186  result.int_min_ = *std::min_element(limits.begin(), limits.end());
187  result.int_max_ = *std::max_element(limits.begin(), limits.end());
188  break;
189  }
192  result.fp_min_ = *std::min_element(limits.begin(), limits.end());
193  result.fp_max_ = *std::max_element(limits.begin(), limits.end());
194  break;
195  }
196  default:
197  CHECK(false);
198  }
199  return result;
200  } catch (...) {
202  }
203  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
static ExpressionRange makeInvalidRange()
+ Here is the call graph for this function:

◆ getBucket()

int64_t ExpressionRange::getBucket ( ) const
inline

Definition at line 122 of file ExpressionRange.h.

References CHECK, and Invalid.

Referenced by anonymous_namespace{JoinHashTable.cpp}::get_bucketized_hash_entry_info().

122  {
124  return bucket_;
125  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function:

◆ getFpMax()

double ExpressionRange::getFpMax ( ) const
inline

Definition at line 89 of file ExpressionRange.h.

References CHECK, Double, and Float.

◆ getFpMin()

double ExpressionRange::getFpMin ( ) const
inline

Definition at line 84 of file ExpressionRange.h.

References CHECK, Double, and Float.

◆ getIntMax()

◆ getIntMin()

int64_t ExpressionRange::getIntMin ( ) const
inline

Definition at line 74 of file ExpressionRange.h.

References CHECK, and Integer.

Referenced by apply_int_qual(), apply_simple_quals(), anonymous_namespace{ExpressionRange.cpp}::fpRangeFromDecimal(), anonymous_namespace{JoinHashTable.cpp}::get_bucketized_hash_entry_info(), anonymous_namespace{JoinHashTable.cpp}::get_hash_entry_count(), and anonymous_namespace{ExpressionRange.cpp}::getDateTimePrecisionCastRange().

74  {
76  return int_min_;
77  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function:

◆ getType()

ExpressionRangeType ExpressionRange::getType ( ) const
inline

Definition at line 120 of file ExpressionRange.h.

Referenced by apply_simple_quals(), getExpressionRange(), JoinHashTable::JoinHashTable(), and anonymous_namespace{QueryMemoryDescriptor.cpp}::pick_baseline_key_component_width().

120 { return type_; }
ExpressionRangeType type_
+ Here is the caller graph for this function:

◆ hasNulls()

bool ExpressionRange::hasNulls ( ) const
inline

Definition at line 127 of file ExpressionRange.h.

References CHECK, and Invalid.

Referenced by apply_simple_quals(), anonymous_namespace{ExpressionRange.cpp}::fpRangeFromDecimal(), and anonymous_namespace{ExpressionRange.cpp}::getDateTimePrecisionCastRange().

127  {
129  return has_nulls_;
130  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function:

◆ makeDoubleRange()

static ExpressionRange ExpressionRange::makeDoubleRange ( const double  fp_min,
const double  fp_max,
const bool  has_nulls 
)
inlinestatic

Definition at line 56 of file ExpressionRange.h.

References Double.

Referenced by anonymous_namespace{ExpressionRange.cpp}::fpRangeFromDecimal(), getExpressionRange(), and getLeafColumnRange().

58  {
59  return ExpressionRange(ExpressionRangeType::Double, fp_min, fp_max, has_nulls);
60  }
+ Here is the caller graph for this function:

◆ makeFloatRange()

static ExpressionRange ExpressionRange::makeFloatRange ( const float  fp_min,
const float  fp_max,
const bool  has_nulls 
)
inlinestatic

Definition at line 62 of file ExpressionRange.h.

References Float.

Referenced by anonymous_namespace{ExpressionRange.cpp}::fpRangeFromDecimal(), getExpressionRange(), and getLeafColumnRange().

64  {
65  return ExpressionRange(ExpressionRangeType::Float, fp_min, fp_max, has_nulls);
66  }
+ Here is the caller graph for this function:

◆ makeIntRange()

static ExpressionRange ExpressionRange::makeIntRange ( const int64_t  int_min,
const int64_t  int_max,
const int64_t  bucket,
const bool  has_nulls 
)
inlinestatic

Definition at line 49 of file ExpressionRange.h.

Referenced by apply_simple_quals(), anonymous_namespace{ExpressionRange.cpp}::getDateTimePrecisionCastRange(), getExpressionRange(), JoinHashTable::getInstance(), and getLeafColumnRange().

52  {
53  return ExpressionRange(int_min, int_max, bucket, has_nulls);
54  }
+ Here is the caller graph for this function:

◆ makeInvalidRange()

static ExpressionRange ExpressionRange::makeInvalidRange ( )
inlinestatic

Definition at line 72 of file ExpressionRange.h.

Referenced by binOp(), CodeGenerator::checkExpressionRanges(), getExpressionRange(), getLeafColumnRange(), operator/(), and operator||().

72 { return ExpressionRange(); }
+ Here is the caller graph for this function:

◆ makeNullRange()

static ExpressionRange ExpressionRange::makeNullRange ( )
inlinestatic

Definition at line 68 of file ExpressionRange.h.

References Null.

Referenced by getExpressionRange().

+ Here is the caller graph for this function:

◆ operator*()

ExpressionRange ExpressionRange::operator* ( const ExpressionRange other) const

◆ operator+()

ExpressionRange ExpressionRange::operator+ ( const ExpressionRange other) const

◆ operator-()

ExpressionRange ExpressionRange::operator- ( const ExpressionRange other) const

◆ operator/()

ExpressionRange ExpressionRange::operator/ ( const ExpressionRange other) const

Definition at line 211 of file ExpressionRange.cpp.

References g_null_div_by_zero, int_max_, int_min_, Integer, makeInvalidRange(), and type_.

211  {
215  }
216  if (other.int_min_ * other.int_max_ <= 0) {
217  // if the other interval contains 0, the rule is more complicated;
218  // punt for now, we can revisit by splitting the other interval and
219  // taking the convex hull of the resulting two intervals
221  }
222  auto div_range = binOp<int64_t>(other, [](const int64_t x, const int64_t y) {
223  return int64_t(checked_int64_t(x) / y);
224  });
225  if (g_null_div_by_zero) {
226  div_range.setHasNulls();
227  }
228  return div_range;
229 }
bool g_null_div_by_zero
Definition: Execute.cpp:73
ExpressionRangeType type_
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void > > checked_int64_t
static ExpressionRange makeInvalidRange()
+ Here is the call graph for this function:

◆ operator==()

bool ExpressionRange::operator== ( const ExpressionRange other) const

Definition at line 261 of file ExpressionRange.cpp.

References CHECK, Double, Float, fp_max_, fp_min_, getExpressionRange(), has_nulls_, int_max_, int_min_, Integer, Invalid, run-benchmark-import::optional, and type_.

261  {
262  if (type_ != other.type_) {
263  return false;
264  }
265  switch (type_) {
267  return true;
269  return has_nulls_ == other.has_nulls_ && int_min_ == other.int_min_ &&
270  int_max_ == other.int_max_;
271  }
274  return has_nulls_ == other.has_nulls_ && fp_min_ == other.fp_min_ &&
275  fp_max_ == other.fp_max_;
276  }
277  default:
278  CHECK(false);
279  }
280  return false;
281 }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ operator||()

ExpressionRange ExpressionRange::operator|| ( const ExpressionRange other) const

Definition at line 231 of file ExpressionRange.cpp.

References bucket_, CHECK, Double, Float, fp_max_, fp_min_, has_nulls_, int_max_, int_min_, Integer, Invalid, makeInvalidRange(), run-benchmark-import::result, and type_.

231  {
232  if (type_ != other.type_) {
234  }
236  switch (type_) {
241  result.has_nulls_ = has_nulls_ || other.has_nulls_;
242  result.int_min_ = std::min(int_min_, other.int_min_);
243  result.int_max_ = std::max(int_max_, other.int_max_);
244  result.bucket_ = std::min(bucket_, other.bucket_);
245  break;
246  }
249  result.type_ = type_;
250  result.has_nulls_ = has_nulls_ || other.has_nulls_;
251  result.fp_min_ = std::min(fp_min_, other.fp_min_);
252  result.fp_max_ = std::max(fp_max_, other.fp_max_);
253  break;
254  }
255  default:
256  CHECK(false);
257  }
258  return result;
259 }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
static ExpressionRange makeInvalidRange()
+ Here is the call graph for this function:

◆ setFpMax()

void ExpressionRange::setFpMax ( const double  fp_max)
inline

Definition at line 115 of file ExpressionRange.h.

References CHECK, Double, and Float.

115  {
117  fp_max_ = fp_max;
118  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187

◆ setFpMin()

void ExpressionRange::setFpMin ( const double  fp_min)
inline

Definition at line 110 of file ExpressionRange.h.

References CHECK, Double, and Float.

110  {
112  fp_min_ = fp_min;
113  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187

◆ setHasNulls()

void ExpressionRange::setHasNulls ( )
inline

Definition at line 132 of file ExpressionRange.h.

References operator==().

132 { has_nulls_ = true; }
+ Here is the call graph for this function:

◆ setIntInvalidRange()

void ExpressionRange::setIntInvalidRange ( )
inline

Definition at line 104 of file ExpressionRange.h.

References CHECK, and Integer.

104  {
106  int_max_ = -1;
107  int_min_ = 0;
108  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187

◆ setIntMax()

void ExpressionRange::setIntMax ( const int64_t  int_max)
inline

Definition at line 99 of file ExpressionRange.h.

References CHECK, and Integer.

Referenced by apply_int_qual().

99  {
101  int_max_ = int_max;
102  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function:

◆ setIntMin()

void ExpressionRange::setIntMin ( const int64_t  int_min)
inline

Definition at line 94 of file ExpressionRange.h.

References CHECK, and Integer.

Referenced by apply_int_qual().

94  {
96  int_min_ = int_min;
97  }
ExpressionRangeType type_
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function:

Member Data Documentation

◆ @5

union { ... }

◆ @7

union { ... }

◆ bucket_

int64_t ExpressionRange::bucket_
private

Definition at line 215 of file ExpressionRange.h.

Referenced by operator||().

◆ fp_max_

double ExpressionRange::fp_max_

Definition at line 213 of file ExpressionRange.h.

Referenced by binOp(), operator==(), and operator||().

◆ fp_min_

double ExpressionRange::fp_min_

Definition at line 209 of file ExpressionRange.h.

Referenced by binOp(), operator==(), and operator||().

◆ has_nulls_

bool ExpressionRange::has_nulls_
private

Definition at line 206 of file ExpressionRange.h.

Referenced by binOp(), operator==(), and operator||().

◆ int_max_

int64_t ExpressionRange::int_max_

Definition at line 212 of file ExpressionRange.h.

Referenced by binOp(), operator/(), operator==(), and operator||().

◆ int_min_

int64_t ExpressionRange::int_min_

Definition at line 208 of file ExpressionRange.h.

Referenced by binOp(), operator/(), operator==(), and operator||().

◆ type_

ExpressionRangeType ExpressionRange::type_
private

Definition at line 205 of file ExpressionRange.h.

Referenced by binOp(), operator/(), operator==(), and operator||().


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