OmniSciDB  fe05a0c208
 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:314
float floatval
Definition: sqltypes.h:210
double doubleval
Definition: sqltypes.h:211

+ 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:314
float floatval
Definition: sqltypes.h:210
double doubleval
Definition: sqltypes.h:211

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

703  {
704  CHECK(target_ti.is_fp());
705  if (target_ti.get_type() == kFLOAT) {
707  static_cast<float>(arg_range.getIntMin()) / scale,
708  static_cast<float>(arg_range.getIntMax()) / scale,
709  arg_range.hasNulls());
710  }
712  static_cast<double>(arg_range.getIntMin()) / scale,
713  static_cast<double>(arg_range.getIntMax()) / scale,
714  arg_range.hasNulls());
715 }
int64_t getIntMin() const
bool is_fp() const
Definition: sqltypes.h:493
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:314
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:203

+ 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, dtWEEK_SATURDAY, dtWEEK_SUNDAY, 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  case dtWEEK_SUNDAY:
520  case dtWEEK_SATURDAY:
521  return 7 * day_seconds;
522  case dtQUARTERDAY:
523  return 4 * 60 * 50;
524  default:
525  return 0;
526  }
527 }

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

719  {
720  if (oper_ti.is_timestamp() && target_ti.is_date()) {
721  const auto field = dtDAY;
722  const int64_t scale =
725  : 1;
726  const int64_t min_ts = oper_ti.is_high_precision_timestamp()
727  ? DateTruncate(field, arg_range.getIntMin() / scale)
728  : DateTruncate(field, arg_range.getIntMin());
729  const int64_t max_ts = oper_ti.is_high_precision_timestamp()
730  ? DateTruncate(field, arg_range.getIntMax() / scale)
731  : DateTruncate(field, arg_range.getIntMax());
732  const int64_t bucket = get_conservative_datetrunc_bucket(field);
733 
734  return ExpressionRange::makeIntRange(min_ts, max_ts, bucket, arg_range.hasNulls());
735  }
736 
737  const int32_t ti_dimen = target_ti.get_dimension();
738  const int32_t oper_dimen = oper_ti.get_dimension();
739  CHECK(oper_dimen != ti_dimen);
740  const int64_t min_ts =
741  ti_dimen > oper_dimen
743  arg_range.getIntMin(),
744  abs(oper_dimen - ti_dimen))
747  arg_range.getIntMin(),
748  abs(oper_dimen - ti_dimen));
749  const int64_t max_ts =
750  ti_dimen > oper_dimen
752  arg_range.getIntMax(),
753  abs(oper_dimen - ti_dimen))
756  arg_range.getIntMax(),
757  abs(oper_dimen - ti_dimen));
758 
759  return ExpressionRange::makeIntRange(min_ts, max_ts, 0, arg_range.hasNulls());
760 }
int64_t getIntMin() const
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
bool is_timestamp() const
Definition: sqltypes.h:743
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:316
int64_t getIntMax() const
#define CHECK(condition)
Definition: Logger.h:203
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
bool is_high_precision_timestamp() const
Definition: sqltypes.h:733
bool is_date() const
Definition: sqltypes.h:731

+ 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:319
uint64_t exp_to_scale(const unsigned exp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: