OmniSciDB  1dac507f6e
 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 47 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 145 of file ExpressionRange.h.

150  , has_nulls_(has_nulls_in)
151  , int_min_(int_min_in)
152  , int_max_(int_max_in)
153  , 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 155 of file ExpressionRange.h.

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

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

+ Here is the call graph for this function:

ExpressionRange::ExpressionRange ( )
inlineprivate

Definition at line 167 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 170 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 176 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_.

176  {
177  CHECK(type_ == other.type_);
178  try {
179  std::vector<T> limits{bin_op(getMin<T>(*this), getMin<T>(other)),
180  bin_op(getMin<T>(*this), getMax<T>(other)),
181  bin_op(getMax<T>(*this), getMin<T>(other)),
182  bin_op(getMax<T>(*this), getMax<T>(other))};
184  result.type_ = type_;
185  result.has_nulls_ = has_nulls_ || other.has_nulls_;
186  switch (result.type_) {
188  result.int_min_ = *std::min_element(limits.begin(), limits.end());
189  result.int_max_ = *std::max_element(limits.begin(), limits.end());
190  break;
191  }
194  result.fp_min_ = *std::min_element(limits.begin(), limits.end());
195  result.fp_max_ = *std::max_element(limits.begin(), limits.end());
196  break;
197  }
198  default:
199  CHECK(false);
200  }
201  return result;
202  } catch (...) {
204  }
205  }
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 122 of file ExpressionRange.h.

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

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

122  {
124  return bucket_;
125  }
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 89 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 84 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 74 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::initHashTableForDevice(), JoinHashTable::initHashTableOnCpu(), JoinHashTable::initOneToManyHashTable(), and JoinHashTable::initOneToManyHashTableOnCpu().

74  {
76  return int_min_;
77  }
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 120 of file ExpressionRange.h.

References type_.

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:

bool ExpressionRange::hasNulls ( ) const
inline

Definition at line 127 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().

127  {
129  return has_nulls_;
130  }
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 56 of file ExpressionRange.h.

References Double, and ExpressionRange().

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

References ExpressionRange(), and 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 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 49 of file ExpressionRange.h.

References ExpressionRange().

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 call graph for this function:

+ Here is the caller graph for this function:

static ExpressionRange ExpressionRange::makeInvalidRange ( )
inlinestatic

Definition at line 72 of file ExpressionRange.h.

References ExpressionRange().

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

72 { 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 68 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 }
bool g_null_div_by_zero
Definition: Execute.cpp:75
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:

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 115 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 110 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 132 of file ExpressionRange.h.

References has_nulls_.

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

Definition at line 104 of file ExpressionRange.h.

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

104  {
106  int_max_ = -1;
107  int_min_ = 0;
108  }
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 99 of file ExpressionRange.h.

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

Referenced by apply_int_qual().

99  {
101  int_max_ = int_max;
102  }
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 94 of file ExpressionRange.h.

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

Referenced by apply_int_qual().

94  {
96  int_min_ = int_min;
97  }
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 SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_elem_type(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_array(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_boolean(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_number(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_string(), SQLTypeInfoCore< TYPE_FACET_PACK >::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_boolean() const
Definition: sqltypes.h:484
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
bool is_number() const
Definition: sqltypes.h:482
bool is_array() const
Definition: sqltypes.h:485
bool is_time() const
Definition: sqltypes.h:483
bool is_string() const
Definition: sqltypes.h:477
static bool typeSupportsRange(const SQLTypeInfo &ti)
SQLTypeInfoCore get_elem_type() const
Definition: sqltypes.h:659

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

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

double ExpressionRange::fp_max_

Definition at line 215 of file ExpressionRange.h.

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

double ExpressionRange::fp_min_

Definition at line 211 of file ExpressionRange.h.

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

bool ExpressionRange::has_nulls_
private

Definition at line 208 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: