OmniSciDB  06b3bd477c
 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 492 of file ExpressionRange.cpp.

References Datum::doubleval, Datum::floatval, SQLTypeInfo::get_type(), kDOUBLE, and ChunkStats::max.

Referenced by getLeafColumnRange().

492  {
493  return col_ti.get_type() == kDOUBLE ? stats.max.doubleval : stats.max.floatval;
494 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:258
float floatval
Definition: sqltypes.h:138
double doubleval
Definition: sqltypes.h:139

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

References Datum::doubleval, Datum::floatval, SQLTypeInfo::get_type(), kDOUBLE, and ChunkStats::min.

Referenced by getLeafColumnRange().

488  {
489  return col_ti.get_type() == kDOUBLE ? stats.min.doubleval : stats.min.floatval;
490 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:258
float floatval
Definition: sqltypes.h:138
double doubleval
Definition: sqltypes.h:139

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

701  {
702  CHECK(target_ti.is_fp());
703  if (target_ti.get_type() == kFLOAT) {
705  static_cast<float>(arg_range.getIntMin()) / scale,
706  static_cast<float>(arg_range.getIntMax()) / scale,
707  arg_range.hasNulls());
708  }
710  static_cast<double>(arg_range.getIntMin()) / scale,
711  static_cast<double>(arg_range.getIntMax()) / scale,
712  arg_range.hasNulls());
713 }
int64_t getIntMin() const
bool is_fp() const
Definition: sqltypes.h:419
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:258
static ExpressionRange makeFloatRange(const float fp_min, const float fp_max, const bool has_nulls)
CHECK(cgen_state)
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 496 of file ExpressionRange.cpp.

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

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

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

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

717  {
718  if (oper_ti.is_timestamp() && target_ti.is_date()) {
719  const auto field = dtDAY;
720  const int64_t scale =
723  : 1;
724  const int64_t min_ts = oper_ti.is_high_precision_timestamp()
725  ? DateTruncate(field, arg_range.getIntMin() / scale)
726  : DateTruncate(field, arg_range.getIntMin());
727  const int64_t max_ts = oper_ti.is_high_precision_timestamp()
728  ? DateTruncate(field, arg_range.getIntMax() / scale)
729  : DateTruncate(field, arg_range.getIntMax());
730  const int64_t bucket = get_conservative_datetrunc_bucket(field);
731 
732  return ExpressionRange::makeIntRange(min_ts, max_ts, bucket, arg_range.hasNulls());
733  }
734 
735  const int32_t ti_dimen = target_ti.get_dimension();
736  const int32_t oper_dimen = oper_ti.get_dimension();
737  CHECK(oper_dimen != ti_dimen);
738  const int64_t min_ts =
739  ti_dimen > oper_dimen
741  arg_range.getIntMin(),
742  abs(oper_dimen - ti_dimen))
745  arg_range.getIntMin(),
746  abs(oper_dimen - ti_dimen));
747  const int64_t max_ts =
748  ti_dimen > oper_dimen
750  arg_range.getIntMax(),
751  abs(oper_dimen - ti_dimen))
754  arg_range.getIntMax(),
755  abs(oper_dimen - ti_dimen));
756 
757  return ExpressionRange::makeIntRange(min_ts, max_ts, 0, arg_range.hasNulls());
758 }
NEVER_INLINE DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t getIntMin() const
bool is_timestamp() const
Definition: sqltypes.h:652
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
CHECK(cgen_state)
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:260
int64_t getIntMax() const
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
bool is_high_precision_timestamp() const
Definition: sqltypes.h:642
bool is_date() const
Definition: sqltypes.h:640

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

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

Referenced by getExpressionRange().

371  {
372  return endpoint * static_cast<int64_t>(exp_to_scale(ti.get_scale()));
373 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:263
uint64_t exp_to_scale(const unsigned exp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: