OmniSciDB  dfae7c3b14
DateTimeTranslator Class Reference

#include <DateTimeTranslator.h>

+ Inheritance diagram for DateTimeTranslator:

Static Public Member Functions

static int64_t getExtractFromTimeConstantValue (const int64_t &timeval, const ExtractField &field, const SQLTypeInfo &ti)
 
static int64_t getDateTruncConstantValue (const int64_t &timeval, const DatetruncField &field, const SQLTypeInfo &ti)
 

Static Protected Member Functions

static std::shared_ptr< Analyzer::ConstantgetNumericConstant (const int64_t scale)
 

Detailed Description

Definition at line 29 of file DateTimeTranslator.h.

Member Function Documentation

◆ getDateTruncConstantValue()

static int64_t DateTimeTranslator::getDateTruncConstantValue ( const int64_t &  timeval,
const DatetruncField field,
const SQLTypeInfo ti 
)
inlinestatic

Definition at line 54 of file DateTimeTranslator.h.

References DateTruncate(), floor_div(), DateTimeUtils::get_datetrunc_high_precision_scale(), SQLTypeInfo::get_dimension(), DateTimeUtils::get_timestamp_precision_scale(), SQLTypeInfo::is_high_precision_timestamp(), DateTimeUtils::is_subsecond_datetrunc_field(), run_benchmark_import::result, and unsigned_mod().

Referenced by getExpressionRange().

56  {
57  if (ti.is_high_precision_timestamp()) {
59  int64_t date_truncate = DateTruncate(field, timeval);
61  if (result != -1) {
62  date_truncate -= unsigned_mod(date_truncate, result);
63  }
64  return date_truncate;
65  } else {
66  const int64_t scale = get_timestamp_precision_scale(ti.get_dimension());
67  return DateTruncate(field, floor_div(timeval, scale)) * scale;
68  }
69  }
70  return DateTruncate(field, timeval);
71  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
bool is_high_precision_timestamp() const
Definition: sqltypes.h:644
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
constexpr bool is_subsecond_datetrunc_field(const DatetruncField field)
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:261
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
const int64_t get_datetrunc_high_precision_scale(const DatetruncField &field, const int32_t dimen)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExtractFromTimeConstantValue()

static int64_t DateTimeTranslator::getExtractFromTimeConstantValue ( const int64_t &  timeval,
const ExtractField field,
const SQLTypeInfo ti 
)
inlinestatic

Definition at line 31 of file DateTimeTranslator.h.

References ExtractFromTime(), floor_div(), SQLTypeInfo::get_dimension(), DateTimeUtils::get_extract_high_precision_adjusted_scale(), DateTimeUtils::get_extract_timestamp_precision_scale(), DateTimeUtils::get_timestamp_precision_scale(), SQLTypeInfo::is_high_precision_timestamp(), DateTimeUtils::is_subsecond_extract_field(), kDIVIDE, and run_benchmark_import::result.

33  {
34  if (ti.is_high_precision_timestamp()) {
36  const auto result =
38  return result.second ? ExtractFromTime(field,
39  result.first == kDIVIDE
40  ? floor_div(timeval, result.second)
41  : timeval * result.second)
42  : ExtractFromTime(field, timeval);
43  } else {
44  return ExtractFromTime(
46  }
47  } else if (is_subsecond_extract_field(field)) {
48  return ExtractFromTime(field,
50  }
51  return ExtractFromTime(field, timeval);
52  }
constexpr int64_t get_extract_timestamp_precision_scale(const ExtractField field)
Definition: DateTimeUtils.h:81
bool is_high_precision_timestamp() const
Definition: sqltypes.h:644
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
const std::pair< SQLOps, int64_t > get_extract_high_precision_adjusted_scale(const ExtractField &field, const int32_t dimen)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:261
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
constexpr bool is_subsecond_extract_field(const ExtractField &field)
Definition: DateTimeUtils.h:95
+ Here is the call graph for this function:

◆ getNumericConstant()

static std::shared_ptr<Analyzer::Constant> DateTimeTranslator::getNumericConstant ( const int64_t  scale)
inlinestaticprotected

Definition at line 74 of file DateTimeTranslator.h.

References Datum::bigintval, and kBIGINT.

75  {
76  Datum d{0};
77  d.bigintval = scale;
78  return makeExpr<Analyzer::Constant>(SQLTypeInfo(kBIGINT, false), false, d);
79  }
int64_t bigintval
Definition: sqltypes.h:138

The documentation for this class was generated from the following file: