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

Functions

int64_t scale_up_interval_endpoint (const int64_t endpoint, const SQLTypeInfo &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

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

Definition at line 750 of file ExpressionRange.cpp.

References CHECK, SQLTypeInfo::get_type(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), ExpressionRange::hasNulls(), SQLTypeInfo::is_fp(), kFLOAT, ExpressionRange::makeDoubleRange(), and ExpressionRange::makeFloatRange().

Referenced by getExpressionRange().

752  {
753  CHECK(target_ti.is_fp());
754  if (target_ti.get_type() == kFLOAT) {
756  static_cast<float>(arg_range.getIntMin()) / scale,
757  static_cast<float>(arg_range.getIntMax()) / scale,
758  arg_range.hasNulls());
759  }
761  static_cast<double>(arg_range.getIntMin()) / scale,
762  static_cast<double>(arg_range.getIntMax()) / scale,
763  arg_range.hasNulls());
764 }
int64_t getIntMin() const
bool is_fp() const
Definition: sqltypes.h:571
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
static ExpressionRange makeFloatRange(const float fp_min, const float fp_max, const bool has_nulls)
bool hasNulls() const
static ExpressionRange makeDoubleRange(const double fp_min, const double fp_max, const bool has_nulls)
int64_t getIntMax() const
#define CHECK(condition)
Definition: Logger.h:291

+ 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 486 of file ExpressionRange.cpp.

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

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

486  {
487  const int64_t day_seconds{24 * 3600};
488  const int64_t year_days{365};
489  switch (datetrunc_field) {
490  case dtYEAR:
491  return year_days * day_seconds;
492  case dtQUARTER:
493  return 90 * day_seconds; // 90 is least number of days in any quater
494  case dtMONTH:
495  return 28 * day_seconds;
496  case dtDAY:
497  return day_seconds;
498  case dtHOUR:
499  return 3600;
500  case dtMINUTE:
501  return 60;
502  case dtMILLENNIUM:
503  return 1000 * year_days * day_seconds;
504  case dtCENTURY:
505  return 100 * year_days * day_seconds;
506  case dtDECADE:
507  return 10 * year_days * day_seconds;
508  case dtWEEK:
509  case dtWEEK_SUNDAY:
510  case dtWEEK_SATURDAY:
511  return 7 * day_seconds;
512  case dtQUARTERDAY:
513  return 4 * 60 * 50;
514  default:
515  return 0;
516  }
517 }

+ 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 766 of file ExpressionRange.cpp.

References CHECK, DateTruncate(), dtDAY, field(), get_conservative_datetrunc_bucket(), DateTimeUtils::get_datetime_scaled_epoch(), SQLTypeInfo::get_dimension(), DateTimeUtils::get_timestamp_precision_scale(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), ExpressionRange::hasNulls(), SQLTypeInfo::is_any(), SQLTypeInfo::is_date(), SQLTypeInfo::is_high_precision_timestamp(), SQLTypeInfo::is_timestamp(), kSecsPerDay, kTIME, ExpressionRange::makeIntRange(), DateTimeUtils::ScaleDown, and DateTimeUtils::ScaleUp.

Referenced by getExpressionRange().

768  {
769  if (oper_ti.is_timestamp() && target_ti.is_date()) {
770  const auto field = dtDAY;
771  const int64_t scale =
774  : 1;
775  const int64_t min_ts = oper_ti.is_high_precision_timestamp()
776  ? DateTruncate(field, arg_range.getIntMin() / scale)
777  : DateTruncate(field, arg_range.getIntMin());
778  const int64_t max_ts = oper_ti.is_high_precision_timestamp()
779  ? DateTruncate(field, arg_range.getIntMax() / scale)
780  : DateTruncate(field, arg_range.getIntMax());
781  const int64_t bucket = get_conservative_datetrunc_bucket(field);
782 
783  return ExpressionRange::makeIntRange(min_ts, max_ts, bucket, arg_range.hasNulls());
784  }
785 
786  if (oper_ti.is_timestamp() && target_ti.is_any<kTIME>()) {
787  // The min and max TS wouldn't make sense here, so return a range covering the whole
788  // day
789  return ExpressionRange::makeIntRange(0, kSecsPerDay, 0, arg_range.hasNulls());
790  }
791 
792  const int32_t ti_dimen = target_ti.get_dimension();
793  const int32_t oper_dimen = oper_ti.get_dimension();
794  CHECK(oper_dimen != ti_dimen);
795  const int64_t min_ts =
796  ti_dimen > oper_dimen
798  arg_range.getIntMin(),
799  abs(oper_dimen - ti_dimen))
802  arg_range.getIntMin(),
803  abs(oper_dimen - ti_dimen));
804  const int64_t max_ts =
805  ti_dimen > oper_dimen
807  arg_range.getIntMax(),
808  abs(oper_dimen - ti_dimen))
811  arg_range.getIntMax(),
812  abs(oper_dimen - ti_dimen));
813 
814  return ExpressionRange::makeIntRange(min_ts, max_ts, 0, arg_range.hasNulls());
815 }
static constexpr int64_t kSecsPerDay
int64_t getIntMin() const
Definition: sqltypes.h:76
bool is_timestamp() const
Definition: sqltypes.h:1044
DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
constexpr int64_t get_datetime_scaled_epoch(const ScalingType direction, const int64_t epoch, const int32_t dimen)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:33
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:393
int64_t getIntMax() const
#define CHECK(condition)
Definition: Logger.h:291
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
bool is_high_precision_timestamp() const
Definition: sqltypes.h:1034
bool is_any() const
Definition: sqltypes.h:556
bool is_date() const
Definition: sqltypes.h:1026

+ 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 367 of file ExpressionRange.cpp.

References exp_to_scale(), and SQLTypeInfo::get_scale().

Referenced by getExpressionRange().

367  {
368  return endpoint * static_cast<int64_t>(exp_to_scale(ti.get_scale()));
369 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:396
uint64_t exp_to_scale(const unsigned exp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: