OmniSciDB  471d68cefb
 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)
 
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 503 of file ExpressionRange.cpp.

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

Referenced by getLeafColumnRange().

503  {
504  return col_ti.get_type() == kDOUBLE ? stats.max.doubleval : stats.max.floatval;
505 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
float floatval
Definition: sqltypes.h:216
double doubleval
Definition: sqltypes.h:217

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

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

Referenced by getLeafColumnRange().

499  {
500  return col_ti.get_type() == kDOUBLE ? stats.min.doubleval : stats.min.floatval;
501 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
float floatval
Definition: sqltypes.h:216
double doubleval
Definition: sqltypes.h:217

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

714  {
715  CHECK(target_ti.is_fp());
716  if (target_ti.get_type() == kFLOAT) {
718  static_cast<float>(arg_range.getIntMin()) / scale,
719  static_cast<float>(arg_range.getIntMax()) / scale,
720  arg_range.hasNulls());
721  }
723  static_cast<double>(arg_range.getIntMin()) / scale,
724  static_cast<double>(arg_range.getIntMax()) / scale,
725  arg_range.hasNulls());
726 }
int64_t getIntMin() const
bool is_fp() const
Definition: sqltypes.h:513
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:209

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

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

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

730  {
731  if (oper_ti.is_timestamp() && target_ti.is_date()) {
732  const auto field = dtDAY;
733  const int64_t scale =
736  : 1;
737  const int64_t min_ts = oper_ti.is_high_precision_timestamp()
738  ? DateTruncate(field, arg_range.getIntMin() / scale)
739  : DateTruncate(field, arg_range.getIntMin());
740  const int64_t max_ts = oper_ti.is_high_precision_timestamp()
741  ? DateTruncate(field, arg_range.getIntMax() / scale)
742  : DateTruncate(field, arg_range.getIntMax());
743  const int64_t bucket = get_conservative_datetrunc_bucket(field);
744 
745  return ExpressionRange::makeIntRange(min_ts, max_ts, bucket, arg_range.hasNulls());
746  }
747 
748  const int32_t ti_dimen = target_ti.get_dimension();
749  const int32_t oper_dimen = oper_ti.get_dimension();
750  CHECK(oper_dimen != ti_dimen);
751  const int64_t min_ts =
752  ti_dimen > oper_dimen
754  arg_range.getIntMin(),
755  abs(oper_dimen - ti_dimen))
758  arg_range.getIntMin(),
759  abs(oper_dimen - ti_dimen));
760  const int64_t max_ts =
761  ti_dimen > oper_dimen
763  arg_range.getIntMax(),
764  abs(oper_dimen - ti_dimen))
767  arg_range.getIntMax(),
768  abs(oper_dimen - ti_dimen));
769 
770  return ExpressionRange::makeIntRange(min_ts, max_ts, 0, arg_range.hasNulls());
771 }
int64_t getIntMin() const
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
bool is_timestamp() const
Definition: sqltypes.h:880
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:209
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
bool is_high_precision_timestamp() const
Definition: sqltypes.h:870
bool is_date() const
Definition: sqltypes.h:868

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

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

Referenced by getExpressionRange().

382  {
383  return endpoint * static_cast<int64_t>(exp_to_scale(ti.get_scale()));
384 }
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: