OmniSciDB  085a039ca4
 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 766 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().

768  {
769  CHECK(target_ti.is_fp());
770  if (target_ti.get_type() == kFLOAT) {
772  static_cast<float>(arg_range.getIntMin()) / scale,
773  static_cast<float>(arg_range.getIntMax()) / scale,
774  arg_range.hasNulls());
775  }
777  static_cast<double>(arg_range.getIntMin()) / scale,
778  static_cast<double>(arg_range.getIntMax()) / scale,
779  arg_range.hasNulls());
780 }
int64_t getIntMin() const
bool is_fp() const
Definition: sqltypes.h:514
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
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:223

+ 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 509 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().

509  {
510  const int64_t day_seconds{24 * 3600};
511  const int64_t year_days{365};
512  switch (datetrunc_field) {
513  case dtYEAR:
514  return year_days * day_seconds;
515  case dtQUARTER:
516  return 90 * day_seconds; // 90 is least number of days in any quater
517  case dtMONTH:
518  return 28 * day_seconds;
519  case dtDAY:
520  return day_seconds;
521  case dtHOUR:
522  return 3600;
523  case dtMINUTE:
524  return 60;
525  case dtMILLENNIUM:
526  return 1000 * year_days * day_seconds;
527  case dtCENTURY:
528  return 100 * year_days * day_seconds;
529  case dtDECADE:
530  return 10 * year_days * day_seconds;
531  case dtWEEK:
532  case dtWEEK_SUNDAY:
533  case dtWEEK_SATURDAY:
534  return 7 * day_seconds;
535  case dtQUARTERDAY:
536  return 4 * 60 * 50;
537  default:
538  return 0;
539  }
540 }

+ 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 782 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_date(), SQLTypeInfo::is_high_precision_timestamp(), SQLTypeInfo::is_timestamp(), ExpressionRange::makeIntRange(), DateTimeUtils::ScaleDown, and DateTimeUtils::ScaleUp.

Referenced by getExpressionRange().

784  {
785  if (oper_ti.is_timestamp() && target_ti.is_date()) {
786  const auto field = dtDAY;
787  const int64_t scale =
790  : 1;
791  const int64_t min_ts = oper_ti.is_high_precision_timestamp()
792  ? DateTruncate(field, arg_range.getIntMin() / scale)
793  : DateTruncate(field, arg_range.getIntMin());
794  const int64_t max_ts = oper_ti.is_high_precision_timestamp()
795  ? DateTruncate(field, arg_range.getIntMax() / scale)
796  : DateTruncate(field, arg_range.getIntMax());
797  const int64_t bucket = get_conservative_datetrunc_bucket(field);
798 
799  return ExpressionRange::makeIntRange(min_ts, max_ts, bucket, arg_range.hasNulls());
800  }
801 
802  const int32_t ti_dimen = target_ti.get_dimension();
803  const int32_t oper_dimen = oper_ti.get_dimension();
804  CHECK(oper_dimen != ti_dimen);
805  const int64_t min_ts =
806  ti_dimen > oper_dimen
808  arg_range.getIntMin(),
809  abs(oper_dimen - ti_dimen))
812  arg_range.getIntMin(),
813  abs(oper_dimen - ti_dimen));
814  const int64_t max_ts =
815  ti_dimen > oper_dimen
817  arg_range.getIntMax(),
818  abs(oper_dimen - ti_dimen))
821  arg_range.getIntMax(),
822  abs(oper_dimen - ti_dimen));
823 
824  return ExpressionRange::makeIntRange(min_ts, max_ts, 0, arg_range.hasNulls());
825 }
int64_t getIntMin() const
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
bool is_timestamp() const
Definition: sqltypes.h:895
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:31
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:331
int64_t getIntMax() const
#define CHECK(condition)
Definition: Logger.h:223
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
bool is_high_precision_timestamp() const
Definition: sqltypes.h:885
bool is_date() const
Definition: sqltypes.h:883

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

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

Referenced by getExpressionRange().

390  {
391  return endpoint * static_cast<int64_t>(exp_to_scale(ti.get_scale()));
392 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:334
uint64_t exp_to_scale(const unsigned exp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: