OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DateTimeUtils Namespace Reference

Functions

constexpr int64_t get_timestamp_precision_scale (const int32_t dimen)
 
constexpr int64_t get_dateadd_timestamp_precision_scale (const DateaddField field)
 
constexpr int64_t get_extract_timestamp_precision_scale (const ExtractField field)
 
constexpr bool is_subsecond_extract_field (const ExtractField &field)
 
constexpr bool is_subsecond_dateadd_field (const DateaddField field)
 
constexpr bool is_subsecond_datetrunc_field (const DatetruncField field)
 
const std::pair< SQLOps, int64_t > get_dateadd_high_precision_adjusted_scale (const DateaddField field, int32_t dimen)
 
const std::pair< SQLOps, int64_t > get_extract_high_precision_adjusted_scale (const ExtractField &field, const int32_t dimen)
 
const int64_t get_datetrunc_high_precision_scale (const DatetruncField &field, const int32_t dimen)
 

Function Documentation

const std::pair<SQLOps, int64_t> DateTimeUtils::get_dateadd_high_precision_adjusted_scale ( const DateaddField  field,
int32_t  dimen 
)
inline

Definition at line 104 of file DateTimeUtils.h.

References daMICROSECOND, daMILLISECOND, daNANOSECOND, kDIVIDE, kMicroSecsPerSec, kMilliSecsPerSec, kMULTIPLY, and to_string().

Referenced by RelAlgTranslator::translateDateadd().

106  {
107  switch (field) {
108  case daNANOSECOND:
109  switch (dimen) {
110  case 9:
111  return {};
112  case 6:
113  return {kDIVIDE, kMilliSecsPerSec};
114  case 3:
115  return {kDIVIDE, kMicroSecsPerSec};
116  default:
117  throw std::runtime_error("Unknown dimen = " + std::to_string(dimen));
118  }
119  case daMICROSECOND:
120  switch (dimen) {
121  case 9:
122  return {kMULTIPLY, kMilliSecsPerSec};
123  case 6:
124  return {};
125  case 3:
126  return {kDIVIDE, kMilliSecsPerSec};
127  default:
128  throw std::runtime_error("Unknown dimen = " + std::to_string(dimen));
129  }
130  case daMILLISECOND:
131  switch (dimen) {
132  case 9:
133  return {kMULTIPLY, kMicroSecsPerSec};
134  case 6:
135  return {kMULTIPLY, kMilliSecsPerSec};
136  case 3:
137  return {};
138  default:
139  throw std::runtime_error("Unknown dimen = " + std::to_string(dimen));
140  }
141  default:
142  throw std::runtime_error("Unknown field = " + std::to_string(field));
143  }
144  return {};
145 }
std::string to_string(char const *&&v)
static constexpr int64_t kMilliSecsPerSec
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
static constexpr int64_t kMicroSecsPerSec

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

constexpr int64_t DateTimeUtils::get_dateadd_timestamp_precision_scale ( const DateaddField  field)
inline

Definition at line 64 of file DateTimeUtils.h.

References daMICROSECOND, daMILLISECOND, daNANOSECOND, kMicroSecsPerSec, kMilliSecsPerSec, kNanoSecsPerSec, and to_string().

Referenced by RelAlgTranslator::translateDateadd().

64  {
65  switch (field) {
66  case daMILLISECOND:
67  return kMilliSecsPerSec;
68  case daMICROSECOND:
69  return kMicroSecsPerSec;
70  case daNANOSECOND:
71  return kNanoSecsPerSec;
72  default:
73  throw std::runtime_error("Unknown field = " + std::to_string(field));
74  }
75  return -1;
76 }
static constexpr int64_t kNanoSecsPerSec
std::string to_string(char const *&&v)
static constexpr int64_t kMilliSecsPerSec
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
static constexpr int64_t kMicroSecsPerSec

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int64_t DateTimeUtils::get_datetrunc_high_precision_scale ( const DatetruncField field,
const int32_t  dimen 
)
inline

Definition at line 157 of file DateTimeUtils.h.

References anonymous_namespace{DateTimeUtils.h}::datetrunc_precision_lookup, and run_benchmark_import::result.

Referenced by CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), and DateTimeTranslator::getDateTruncConstantValue().

158  {
159  const auto result = datetrunc_precision_lookup.find(std::make_pair(dimen, field));
160  if (result != datetrunc_precision_lookup.end()) {
161  return result->second;
162  }
163  return -1;
164 }
static const std::map< std::pair< int32_t, DatetruncField >, int64_t > datetrunc_precision_lookup
Definition: DateTimeUtils.h:40
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the caller graph for this function:

const std::pair<SQLOps, int64_t> DateTimeUtils::get_extract_high_precision_adjusted_scale ( const ExtractField field,
const int32_t  dimen 
)
inline

Definition at line 147 of file DateTimeUtils.h.

References anonymous_namespace{DateTimeUtils.h}::extract_precision_lookup, and run_benchmark_import::result.

Referenced by CodeGenerator::codegenExtractHighPrecisionTimestamps(), and DateTimeTranslator::getExtractFromTimeConstantValue().

149  {
150  const auto result = extract_precision_lookup.find(std::make_pair(dimen, field));
151  if (result != extract_precision_lookup.end()) {
152  return result->second;
153  }
154  return {};
155 }
static const std::map< std::pair< int32_t, ExtractField >, std::pair< SQLOps, int64_t > > extract_precision_lookup
Definition: DateTimeUtils.h:32
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the caller graph for this function:

constexpr int64_t DateTimeUtils::get_extract_timestamp_precision_scale ( const ExtractField  field)
inline

Definition at line 78 of file DateTimeUtils.h.

References kMICROSECOND, kMicroSecsPerSec, kMILLISECOND, kMilliSecsPerSec, kNANOSECOND, kNanoSecsPerSec, and to_string().

Referenced by CodeGenerator::codegen(), and DateTimeTranslator::getExtractFromTimeConstantValue().

78  {
79  switch (field) {
80  case kMILLISECOND:
81  return kMilliSecsPerSec;
82  case kMICROSECOND:
83  return kMicroSecsPerSec;
84  case kNANOSECOND:
85  return kNanoSecsPerSec;
86  default:
87  throw std::runtime_error("Unknown field = " + std::to_string(field));
88  }
89  return -1;
90 }
static constexpr int64_t kNanoSecsPerSec
std::string to_string(char const *&&v)
static constexpr int64_t kMilliSecsPerSec
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
static constexpr int64_t kMicroSecsPerSec

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

constexpr int64_t DateTimeUtils::get_timestamp_precision_scale ( const int32_t  dimen)
inline

Definition at line 48 of file DateTimeUtils.h.

References kMicroSecsPerSec, kMilliSecsPerSec, kNanoSecsPerSec, and to_string().

Referenced by apply_hpt_qual(), CodeGenerator::codegen(), CodeGenerator::codegenCastBetweenTimestamps(), CodeGenerator::codegenCastTimestampToDate(), Analyzer::Constant::do_cast(), anonymous_namespace{Execute.cpp}::get_hpt_scaled_value(), anonymous_namespace{ExpressionRange.cpp}::getDateTimePrecisionCastRange(), DateTimeTranslator::getDateTruncConstantValue(), getExpressionRange(), and DateTimeTranslator::getExtractFromTimeConstantValue().

48  {
49  switch (dimen) {
50  case 0:
51  return 1;
52  case 3:
53  return kMilliSecsPerSec;
54  case 6:
55  return kMicroSecsPerSec;
56  case 9:
57  return kNanoSecsPerSec;
58  default:
59  throw std::runtime_error("Unknown dimen = " + std::to_string(dimen));
60  }
61  return -1;
62 }
static constexpr int64_t kNanoSecsPerSec
std::string to_string(char const *&&v)
static constexpr int64_t kMilliSecsPerSec
static constexpr int64_t kMicroSecsPerSec

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

constexpr bool DateTimeUtils::is_subsecond_dateadd_field ( const DateaddField  field)
inline

Definition at line 96 of file DateTimeUtils.h.

References daMICROSECOND, daMILLISECOND, and daNANOSECOND.

Referenced by RelAlgTranslator::translateDateadd().

96  {
98 }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the caller graph for this function:

constexpr bool DateTimeUtils::is_subsecond_datetrunc_field ( const DatetruncField  field)
inline

Definition at line 100 of file DateTimeUtils.h.

References dtMICROSECOND, dtMILLISECOND, and dtNANOSECOND.

Referenced by CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), and DateTimeTranslator::getDateTruncConstantValue().

100  {
102 }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the caller graph for this function:

constexpr bool DateTimeUtils::is_subsecond_extract_field ( const ExtractField field)
inline

Definition at line 92 of file DateTimeUtils.h.

References kMICROSECOND, kMILLISECOND, and kNANOSECOND.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenExtractHighPrecisionTimestamps(), and DateTimeTranslator::getExtractFromTimeConstantValue().

92  {
93  return field == kMILLISECOND || field == kMICROSECOND || field == kNANOSECOND;
94 }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the caller graph for this function: