OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ()
 
static bool typeSupportsRange (const SQLTypeInfo &ti)
 

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 46 of file ExpressionRange.h.

Constructor & Destructor Documentation

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 144 of file ExpressionRange.h.

149  , has_nulls_(has_nulls_in)
150  , int_min_(int_min_in)
151  , int_max_(int_max_in)
152  , bucket_(bucket) {}
ExpressionRangeType type_
ExpressionRange::ExpressionRange ( const ExpressionRangeType  type,
const double  fp_min_in,
const double  fp_max_in,
const bool  has_nulls_in 
)
inlineprivate

Definition at line 154 of file ExpressionRange.h.

References CHECK(), Double, Float, and type_.

158  : type_(type)
159  , has_nulls_(has_nulls_in)
160  , fp_min_(fp_min_in)
161  , fp_max_(fp_max_in)
162  , bucket_(0) {
164  }
ExpressionRangeType type_
CHECK(cgen_state)

+ Here is the call graph for this function:

ExpressionRange::ExpressionRange ( )
inlineprivate

Definition at line 166 of file ExpressionRange.h.

Referenced by makeDoubleRange(), makeFloatRange(), makeIntRange(), makeInvalidRange(), and makeNullRange().

+ Here is the caller graph for this function:

ExpressionRange::ExpressionRange ( const ExpressionRangeType  type)
inlineexplicitprivate

Definition at line 169 of file ExpressionRange.h.

References CHECK(), Null, and type_.

+ Here is the call graph for this function:

Member Function Documentation

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

Definition at line 175 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_.

175  {
176  CHECK(type_ == other.type_);
177  try {
178  std::vector<T> limits{bin_op(getMin<T>(*this), getMin<T>(other)),
179  bin_op(getMin<T>(*this), getMax<T>(other)),
180  bin_op(getMax<T>(*this), getMin<T>(other)),
181  bin_op(getMax<T>(*this), getMax<T>(other))};
183  result.type_ = type_;
184  result.has_nulls_ = has_nulls_ || other.has_nulls_;
185  switch (result.type_) {
187  result.int_min_ = *std::min_element(limits.begin(), limits.end());
188  result.int_max_ = *std::max_element(limits.begin(), limits.end());
189  break;
190  }
193  result.fp_min_ = *std::min_element(limits.begin(), limits.end());
194  result.fp_max_ = *std::max_element(limits.begin(), limits.end());
195  break;
196  }
197  default:
198  CHECK(false);
199  }
200  return result;
201  } catch (...) {
203  }
204  }
ExpressionRangeType type_
CHECK(cgen_state)
static ExpressionRange makeInvalidRange()

+ Here is the call graph for this function:

int64_t ExpressionRange::getBucket ( ) const
inline

Definition at line 121 of file ExpressionRange.h.

References bucket_, CHECK(), Invalid, and type_.

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

121  {
123  return bucket_;
124  }
ExpressionRangeType type_
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double ExpressionRange::getFpMax ( ) const
inline

Definition at line 88 of file ExpressionRange.h.

References CHECK(), Double, Float, fp_max_, and type_.

+ Here is the call graph for this function:

double ExpressionRange::getFpMin ( ) const
inline

Definition at line 83 of file ExpressionRange.h.

References CHECK(), Double, Float, fp_min_, and type_.

+ Here is the call graph for this function:

int64_t ExpressionRange::getIntMax ( ) const
inline
int64_t ExpressionRange::getIntMin ( ) const
inline

Definition at line 73 of file ExpressionRange.h.

References CHECK(), int_min_, Integer, and type_.

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(), anonymous_namespace{ExpressionRange.cpp}::getDateTimePrecisionCastRange(), JoinHashTable::getHashJoinArgs(), JoinHashTable::initOneToManyHashTable(), JoinHashTable::initOneToManyHashTableOnCpu(), JoinHashTable::initOneToOneHashTable(), and JoinHashTable::initOneToOneHashTableOnCpu().

73  {
75  return int_min_;
76  }
ExpressionRangeType type_
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExpressionRangeType ExpressionRange::getType ( ) const
inline

Definition at line 119 of file ExpressionRange.h.

References type_.

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

119 { return type_; }
ExpressionRangeType type_

+ Here is the caller graph for this function:

bool ExpressionRange::hasNulls ( ) const
inline

Definition at line 126 of file ExpressionRange.h.

References CHECK(), has_nulls_, Invalid, and type_.

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

126  {
128  return has_nulls_;
129  }
ExpressionRangeType type_
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 55 of file ExpressionRange.h.

References Double, and ExpressionRange().

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

57  {
58  return ExpressionRange(ExpressionRangeType::Double, fp_min, fp_max, has_nulls);
59  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 61 of file ExpressionRange.h.

References ExpressionRange(), and Float.

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

63  {
64  return ExpressionRange(ExpressionRangeType::Float, fp_min, fp_max, has_nulls);
65  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 48 of file ExpressionRange.h.

References ExpressionRange().

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

51  {
52  return ExpressionRange(int_min, int_max, bucket, has_nulls);
53  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ExpressionRange ExpressionRange::makeInvalidRange ( )
inlinestatic

Definition at line 71 of file ExpressionRange.h.

References ExpressionRange().

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

71 { return ExpressionRange(); }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ExpressionRange ExpressionRange::makeNullRange ( )
inlinestatic

Definition at line 67 of file ExpressionRange.h.

References ExpressionRange(), and Null.

Referenced by getExpressionRange().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExpressionRange ExpressionRange::operator* ( const ExpressionRange other) const
ExpressionRange ExpressionRange::operator+ ( const ExpressionRange other) const
ExpressionRange ExpressionRange::operator- ( const ExpressionRange other) const
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 }
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void >> checked_int64_t
bool g_null_div_by_zero
Definition: Execute.cpp:76
ExpressionRangeType type_
static ExpressionRange makeInvalidRange()

+ Here is the call graph for this function:

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

Definition at line 261 of file ExpressionRange.cpp.

References CHECK(), Double, Float, fp_max_, fp_min_, has_nulls_, int_max_, int_min_, Integer, Invalid, 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_
CHECK(cgen_state)

+ Here is the call graph for this function:

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_
CHECK(cgen_state)
static ExpressionRange makeInvalidRange()

+ Here is the call graph for this function:

void ExpressionRange::setFpMax ( const double  fp_max)
inline

Definition at line 114 of file ExpressionRange.h.

References CHECK(), Double, Float, fp_max_, and type_.

+ Here is the call graph for this function:

void ExpressionRange::setFpMin ( const double  fp_min)
inline

Definition at line 109 of file ExpressionRange.h.

References CHECK(), Double, Float, fp_min_, and type_.

+ Here is the call graph for this function:

void ExpressionRange::setHasNulls ( )
inline

Definition at line 131 of file ExpressionRange.h.

References has_nulls_.

131 { has_nulls_ = true; }
void ExpressionRange::setIntInvalidRange ( )
inline

Definition at line 103 of file ExpressionRange.h.

References CHECK(), int_max_, int_min_, Integer, and type_.

103  {
105  int_max_ = -1;
106  int_min_ = 0;
107  }
ExpressionRangeType type_
CHECK(cgen_state)

+ Here is the call graph for this function:

void ExpressionRange::setIntMax ( const int64_t  int_max)
inline

Definition at line 98 of file ExpressionRange.h.

References CHECK(), int_max_, Integer, and type_.

Referenced by apply_int_qual().

98  {
100  int_max_ = int_max;
101  }
ExpressionRangeType type_
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ExpressionRange::setIntMin ( const int64_t  int_min)
inline

Definition at line 93 of file ExpressionRange.h.

References CHECK(), int_min_, Integer, and type_.

Referenced by apply_int_qual().

93  {
95  int_min_ = int_min;
96  }
ExpressionRangeType type_
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ExpressionRange::typeSupportsRange ( const SQLTypeInfo ti)
static

Definition at line 283 of file ExpressionRange.cpp.

References SQLTypeInfo::get_compression(), SQLTypeInfo::get_elem_type(), SQLTypeInfo::is_array(), SQLTypeInfo::is_boolean(), SQLTypeInfo::is_number(), SQLTypeInfo::is_string(), SQLTypeInfo::is_time(), and kENCODING_DICT.

Referenced by Executor::computeColRangesCache(), and getExpressionRange().

283  {
284  if (ti.is_array()) {
285  return typeSupportsRange(ti.get_elem_type());
286  } else {
287  return (ti.is_number() || ti.is_boolean() || ti.is_time() ||
288  (ti.is_string() && ti.get_compression() == kENCODING_DICT));
289  }
290 }
bool is_number() const
Definition: sqltypes.h:404
bool is_time() const
Definition: sqltypes.h:405
bool is_boolean() const
Definition: sqltypes.h:406
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256
static bool typeSupportsRange(const SQLTypeInfo &ti)
bool is_string() const
Definition: sqltypes.h:399
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:603
bool is_array() const
Definition: sqltypes.h:407

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

union { ... }
union { ... }
int64_t ExpressionRange::bucket_
private

Definition at line 216 of file ExpressionRange.h.

Referenced by getBucket(), and operator||().

double ExpressionRange::fp_max_

Definition at line 214 of file ExpressionRange.h.

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

double ExpressionRange::fp_min_

Definition at line 210 of file ExpressionRange.h.

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

bool ExpressionRange::has_nulls_
private

Definition at line 207 of file ExpressionRange.h.

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

int64_t ExpressionRange::int_max_
int64_t ExpressionRange::int_min_

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