OmniSciDB  a47db9e897
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{ExpressionRange.cpp} Namespace Reference

Functions

int64_t scale_up_interval_endpoint (const int64_t endpoint, const SQLTypeInfo &ti)
 
double extract_min_stat_double (const ChunkStats &stats, const SQLTypeInfo &col_ti)
 
double extract_max_stat_double (const ChunkStats &stats, const SQLTypeInfo &col_ti)
 
int64_t get_conservative_datetrunc_bucket (const DatetruncField datetrunc_field)
 
ExpressionRange fpRangeFromDecimal (const ExpressionRange &arg_range, const int64_t scale, const SQLTypeInfo &target_ti)
 
ExpressionRange getDateTimePrecisionCastRange (const ExpressionRange &arg_range, const SQLTypeInfo &oper_ti, const SQLTypeInfo &target_ti)
 

Function Documentation

double anonymous_namespace{ExpressionRange.cpp}::extract_max_stat_double ( const ChunkStats stats,
const SQLTypeInfo col_ti 
)

Definition at line 497 of file ExpressionRange.cpp.

References Datum::doubleval, Datum::floatval, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kDOUBLE, and ChunkStats::max.

Referenced by getLeafColumnRange().

497  {
498  return col_ti.get_type() == kDOUBLE ? stats.max.doubleval : stats.max.floatval;
499 }
float floatval
Definition: sqltypes.h:130
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
double doubleval
Definition: sqltypes.h:131

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double anonymous_namespace{ExpressionRange.cpp}::extract_min_stat_double ( const ChunkStats stats,
const SQLTypeInfo col_ti 
)

Definition at line 493 of file ExpressionRange.cpp.

References Datum::doubleval, Datum::floatval, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kDOUBLE, and ChunkStats::min.

Referenced by getLeafColumnRange().

493  {
494  return col_ti.get_type() == kDOUBLE ? stats.min.doubleval : stats.min.floatval;
495 }
float floatval
Definition: sqltypes.h:130
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
double doubleval
Definition: sqltypes.h:131

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExpressionRange anonymous_namespace{ExpressionRange.cpp}::fpRangeFromDecimal ( const ExpressionRange arg_range,
const int64_t  scale,
const SQLTypeInfo target_ti 
)

Definition at line 704 of file ExpressionRange.cpp.

References CHECK(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), ExpressionRange::hasNulls(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_fp(), kFLOAT, ExpressionRange::makeDoubleRange(), and ExpressionRange::makeFloatRange().

Referenced by getExpressionRange().

706  {
707  CHECK(target_ti.is_fp());
708  if (target_ti.get_type() == kFLOAT) {
710  static_cast<float>(arg_range.getIntMin()) / scale,
711  static_cast<float>(arg_range.getIntMax()) / scale,
712  arg_range.hasNulls());
713  }
715  static_cast<double>(arg_range.getIntMin()) / scale,
716  static_cast<double>(arg_range.getIntMax()) / scale,
717  arg_range.hasNulls());
718 }
bool is_fp() const
Definition: sqltypes.h:481
int64_t getIntMin() const
static ExpressionRange makeFloatRange(const float fp_min, const float fp_max, const bool has_nulls)
CHECK(cgen_state)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
bool hasNulls() const
static ExpressionRange makeDoubleRange(const double fp_min, const double fp_max, const bool has_nulls)
int64_t getIntMax() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t anonymous_namespace{ExpressionRange.cpp}::get_conservative_datetrunc_bucket ( const DatetruncField  datetrunc_field)

Definition at line 501 of file ExpressionRange.cpp.

References dtCENTURY, dtDAY, dtDECADE, dtHOUR, dtMILLENNIUM, dtMINUTE, dtMONTH, dtQUARTER, dtQUARTERDAY, dtWEEK, and dtYEAR.

Referenced by getDateTimePrecisionCastRange(), getExpressionRange(), and getLeafColumnRange().

501  {
502  const int64_t day_seconds{24 * 3600};
503  const int64_t year_days{365};
504  switch (datetrunc_field) {
505  case dtYEAR:
506  return year_days * day_seconds;
507  case dtQUARTER:
508  return 90 * day_seconds; // 90 is least number of days in any quater
509  case dtMONTH:
510  return 28 * day_seconds;
511  case dtDAY:
512  return day_seconds;
513  case dtHOUR:
514  return 3600;
515  case dtMINUTE:
516  return 60;
517  case dtMILLENNIUM:
518  return 1000 * year_days * day_seconds;
519  case dtCENTURY:
520  return 100 * year_days * day_seconds;
521  case dtDECADE:
522  return 10 * year_days * day_seconds;
523  case dtWEEK:
524  return 7 * day_seconds;
525  case dtQUARTERDAY:
526  return 4 * 60 * 50;
527  default:
528  return 0;
529  }
530 }

+ Here is the caller graph for this function:

ExpressionRange anonymous_namespace{ExpressionRange.cpp}::getDateTimePrecisionCastRange ( const ExpressionRange arg_range,
const SQLTypeInfo oper_ti,
const SQLTypeInfo target_ti 
)

Definition at line 720 of file ExpressionRange.cpp.

References CHECK(), DateTruncate(), DateTruncateAlterPrecisionScaleDown(), DateTruncateAlterPrecisionScaleUp(), dtDAY, field(), get_conservative_datetrunc_bucket(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_dimension(), DateTimeUtils::get_timestamp_precision_scale(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), ExpressionRange::hasNulls(), and ExpressionRange::makeIntRange().

Referenced by getExpressionRange().

722  {
723  if (oper_ti.is_timestamp() && target_ti.is_date()) {
724  const auto field = dtDAY;
725  const int64_t scale =
726  oper_ti.is_high_precision_timestamp()
728  : 1;
729  const int64_t min_ts = oper_ti.is_high_precision_timestamp()
730  ? DateTruncate(field, arg_range.getIntMin() / scale)
731  : DateTruncate(field, arg_range.getIntMin());
732  const int64_t max_ts = oper_ti.is_high_precision_timestamp()
733  ? DateTruncate(field, arg_range.getIntMax() / scale)
734  : DateTruncate(field, arg_range.getIntMax());
735  const int64_t bucket = get_conservative_datetrunc_bucket(field);
736 
737  return ExpressionRange::makeIntRange(min_ts, max_ts, bucket, arg_range.hasNulls());
738  }
739 
740  const int32_t ti_dimen = target_ti.get_dimension();
741  const int32_t oper_dimen = oper_ti.get_dimension();
742  CHECK(oper_dimen != ti_dimen);
743  const int64_t scale =
744  DateTimeUtils::get_timestamp_precision_scale(abs(oper_dimen - ti_dimen));
745  const int64_t min_ts =
746  ti_dimen > oper_dimen
747  ? DateTruncateAlterPrecisionScaleUp(arg_range.getIntMin(), scale)
748  : DateTruncateAlterPrecisionScaleDown(arg_range.getIntMin(), scale);
749  const int64_t max_ts =
750  ti_dimen > oper_dimen
751  ? DateTruncateAlterPrecisionScaleUp(arg_range.getIntMax(), scale)
752  : DateTruncateAlterPrecisionScaleDown(arg_range.getIntMax(), scale);
753 
754  return ExpressionRange::makeIntRange(min_ts, max_ts, 0, arg_range.hasNulls());
755 }
NEVER_INLINE DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t getIntMin() const
DEVICE int64_t DateTruncateAlterPrecisionScaleUp(const int64_t timeval, const int64_t scale)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
DEVICE int64_t DateTruncateAlterPrecisionScaleDown(const int64_t timeval, const int64_t scale)
int64_t get_conservative_datetrunc_bucket(const DatetruncField datetrunc_field)
bool hasNulls() const
static ExpressionRange makeIntRange(const int64_t int_min, const int64_t int_max, const int64_t bucket, const bool has_nulls)
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:328
int64_t getIntMax() const
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t anonymous_namespace{ExpressionRange.cpp}::scale_up_interval_endpoint ( const int64_t  endpoint,
const SQLTypeInfo ti 
)

Definition at line 376 of file ExpressionRange.cpp.

References exp_to_scale(), and SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale().

Referenced by getExpressionRange().

376  {
377  return endpoint * static_cast<int64_t>(exp_to_scale(ti.get_scale()));
378 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:331
uint64_t exp_to_scale(const unsigned exp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: