OmniSciDB  343343d194
 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 484 of file ExpressionRange.cpp.

References Datum::doubleval, Datum::floatval, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kDOUBLE, and ChunkStats::max.

Referenced by getLeafColumnRange().

484  {
485  return col_ti.get_type() == kDOUBLE ? stats.max.doubleval : stats.max.floatval;
486 }
float floatval
Definition: sqltypes.h:128
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:324
double doubleval
Definition: sqltypes.h:129

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

References Datum::doubleval, Datum::floatval, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kDOUBLE, and ChunkStats::min.

Referenced by getLeafColumnRange().

480  {
481  return col_ti.get_type() == kDOUBLE ? stats.min.doubleval : stats.min.floatval;
482 }
float floatval
Definition: sqltypes.h:128
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:324
double doubleval
Definition: sqltypes.h:129

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

References CHECK, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), ExpressionRange::hasNulls(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_fp(), kFLOAT, ExpressionRange::makeDoubleRange(), and ExpressionRange::makeFloatRange().

Referenced by getExpressionRange().

693  {
694  CHECK(target_ti.is_fp());
695  if (target_ti.get_type() == kFLOAT) {
697  static_cast<float>(arg_range.getIntMin()) / scale,
698  static_cast<float>(arg_range.getIntMax()) / scale,
699  arg_range.hasNulls());
700  }
702  static_cast<double>(arg_range.getIntMin()) / scale,
703  static_cast<double>(arg_range.getIntMax()) / scale,
704  arg_range.hasNulls());
705 }
bool is_fp() const
Definition: sqltypes.h:476
int64_t getIntMin() const
static ExpressionRange makeFloatRange(const float fp_min, const float fp_max, const bool has_nulls)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:324
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:187

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

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

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

488  {
489  const int64_t day_seconds{24 * 3600};
490  const int64_t year_days{365};
491  switch (datetrunc_field) {
492  case dtYEAR:
493  return year_days * day_seconds;
494  case dtQUARTER:
495  return 90 * day_seconds; // 90 is least number of days in any quater
496  case dtMONTH:
497  return 28 * day_seconds;
498  case dtDAY:
499  return day_seconds;
500  case dtHOUR:
501  return 3600;
502  case dtMINUTE:
503  return 60;
504  case dtMILLENNIUM:
505  return 1000 * year_days * day_seconds;
506  case dtCENTURY:
507  return 100 * year_days * day_seconds;
508  case dtDECADE:
509  return 10 * year_days * day_seconds;
510  case dtWEEK:
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 707 of file ExpressionRange.cpp.

References CHECK, DateTruncate(), DateTruncateAlterPrecisionScaleDown(), DateTruncateAlterPrecisionScaleUp(), dtDAY, field(), get_conservative_datetrunc_bucket(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_dimension(), DateTimeUtils::get_timestamp_precision_scale(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), ExpressionRange::hasNulls(), and ExpressionRange::makeIntRange().

Referenced by getExpressionRange().

709  {
710  if (oper_ti.is_timestamp() && target_ti.is_date()) {
711  const auto field = dtDAY;
712  const int64_t scale =
713  oper_ti.is_high_precision_timestamp()
715  : 1;
716  const int64_t min_ts = oper_ti.is_high_precision_timestamp()
717  ? DateTruncate(field, arg_range.getIntMin() / scale)
718  : DateTruncate(field, arg_range.getIntMin());
719  const int64_t max_ts = oper_ti.is_high_precision_timestamp()
720  ? DateTruncate(field, arg_range.getIntMax() / scale)
721  : DateTruncate(field, arg_range.getIntMax());
722  const int64_t bucket = get_conservative_datetrunc_bucket(field);
723 
724  return ExpressionRange::makeIntRange(min_ts, max_ts, bucket, arg_range.hasNulls());
725  }
726 
727  const int32_t ti_dimen = target_ti.get_dimension();
728  const int32_t oper_dimen = oper_ti.get_dimension();
729  CHECK(oper_dimen != ti_dimen);
730  const int64_t scale =
731  DateTimeUtils::get_timestamp_precision_scale(abs(oper_dimen - ti_dimen));
732  const int64_t min_ts =
733  ti_dimen > oper_dimen
734  ? DateTruncateAlterPrecisionScaleUp(arg_range.getIntMin(), scale)
735  : DateTruncateAlterPrecisionScaleDown(arg_range.getIntMin(), scale);
736  const int64_t max_ts =
737  ti_dimen > oper_dimen
738  ? DateTruncateAlterPrecisionScaleUp(arg_range.getIntMax(), scale)
739  : DateTruncateAlterPrecisionScaleDown(arg_range.getIntMax(), scale);
740 
741  return ExpressionRange::makeIntRange(min_ts, max_ts, 0, arg_range.hasNulls());
742 }
NEVER_INLINE DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t getIntMin() const
DEVICE int64_t DateTruncateAlterPrecisionScaleUp(const int64_t timeval, const int64_t scale)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
DEVICE int64_t DateTruncateAlterPrecisionScaleDown(const int64_t timeval, const int64_t scale)
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:326
int64_t getIntMax() const
#define CHECK(condition)
Definition: Logger.h:187
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:48

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

References exp_to_scale(), and SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale().

Referenced by getExpressionRange().

363  {
364  return endpoint * static_cast<int64_t>(exp_to_scale(ti.get_scale()));
365 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:329
uint64_t exp_to_scale(const unsigned exp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: