OmniSciDB  85c2d10cdc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DateTruncate.h File Reference
#include <array>
#include <cstdint>
#include "../Shared/funcannotations.h"
#include "ExtractFromTime.h"
+ Include dependency graph for DateTruncate.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  DatetruncField {
  dtYEAR = 0, dtQUARTER, dtMONTH, dtDAY,
  dtHOUR, dtMINUTE, dtSECOND, dtMILLISECOND,
  dtMICROSECOND, dtNANOSECOND, dtMILLENNIUM, dtCENTURY,
  dtDECADE, dtWEEK, dtWEEK_SUNDAY, dtWEEK_SATURDAY,
  dtQUARTERDAY, dtINVALID
}
 

Functions

int64_t DateTruncate (DatetruncField field, const int64_t timeval)
 
RUNTIME_EXPORT DEVICE int64_t DateTruncateHighPrecisionToDate (const int64_t timeval, const int64_t scale)
 

Variables

constexpr std::array< char
const *, dtINVALID
datetrunc_fname_lookup
 

Enumeration Type Documentation

Enumerator
dtYEAR 
dtQUARTER 
dtMONTH 
dtDAY 
dtHOUR 
dtMINUTE 
dtSECOND 
dtMILLISECOND 
dtMICROSECOND 
dtNANOSECOND 
dtMILLENNIUM 
dtCENTURY 
dtDECADE 
dtWEEK 
dtWEEK_SUNDAY 
dtWEEK_SATURDAY 
dtQUARTERDAY 
dtINVALID 

Definition at line 27 of file DateTruncate.h.

Function Documentation

int64_t DateTruncate ( DatetruncField  field,
const int64_t  timeval 
)

Definition at line 241 of file DateTruncate.cpp.

References datetrunc_century(), datetrunc_day(), datetrunc_decade(), datetrunc_hour(), datetrunc_millennium(), datetrunc_minute(), datetrunc_month(), datetrunc_quarter(), datetrunc_quarterday(), datetrunc_week_monday(), datetrunc_week_saturday(), datetrunc_week_sunday(), datetrunc_year(), dtCENTURY, dtDAY, dtDECADE, dtHOUR, dtMICROSECOND, dtMILLENNIUM, dtMILLISECOND, dtMINUTE, dtMONTH, dtNANOSECOND, dtQUARTER, dtQUARTERDAY, dtSECOND, dtWEEK, dtWEEK_SATURDAY, dtWEEK_SUNDAY, and dtYEAR.

Referenced by Analyzer::Constant::do_cast(), anonymous_namespace{ExpressionRange.cpp}::getDateTimePrecisionCastRange(), and DateTimeTranslator::getDateTruncConstantValue().

241  {
242  switch (field) {
243  case dtNANOSECOND:
244  case dtMICROSECOND:
245  case dtMILLISECOND:
246  case dtSECOND:
247  return timeval;
248  case dtMINUTE:
249  return datetrunc_minute(timeval);
250  case dtHOUR:
251  return datetrunc_hour(timeval);
252  case dtQUARTERDAY:
253  return datetrunc_quarterday(timeval);
254  case dtDAY:
255  return datetrunc_day(timeval);
256  case dtWEEK:
257  return datetrunc_week_monday(timeval);
258  case dtWEEK_SUNDAY:
259  return datetrunc_week_sunday(timeval);
260  case dtWEEK_SATURDAY:
261  return datetrunc_week_saturday(timeval);
262  case dtMONTH:
263  return datetrunc_month(timeval);
264  case dtQUARTER:
265  return datetrunc_quarter(timeval);
266  case dtYEAR:
267  return datetrunc_year(timeval);
268  case dtDECADE:
269  return datetrunc_decade(timeval);
270  case dtCENTURY:
271  return datetrunc_century(timeval);
272  case dtMILLENNIUM:
273  return datetrunc_millennium(timeval);
274  default:
275 #ifdef __CUDACC__
276  return std::numeric_limits<int64_t>::min();
277 #else
278  abort();
279 #endif
280  }
281 }
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_millennium(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_quarter(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_quarterday(int64_t timeval)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_day(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_century(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_decade(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_week_saturday(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_hour(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_month(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_week_sunday(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_minute(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_week_monday(int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t datetrunc_year(int64_t timeval)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RUNTIME_EXPORT DEVICE int64_t DateTruncateHighPrecisionToDate ( const int64_t  timeval,
const int64_t  scale 
)

Definition at line 285 of file DateTruncate.cpp.

References floor_div(), and kSecsPerDay.

Referenced by DateTruncateHighPrecisionToDateNullable(), and Analyzer::Constant::do_cast().

285  {
286  return floor_div(timeval, scale * kSecsPerDay) * kSecsPerDay;
287 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

constexpr std::array<char const*, dtINVALID> datetrunc_fname_lookup
Initial value:
{"datetrunc_year",
"datetrunc_quarter",
"datetrunc_month",
"datetrunc_day",
"datetrunc_hour",
"datetrunc_minute",
"datetrunc_second",
"datetrunc_millisecond",
"datetrunc_microsecond",
"datetrunc_nanosecond",
"datetrunc_millennium",
"datetrunc_century",
"datetrunc_decade",
"datetrunc_week_monday",
"datetrunc_week_sunday",
"datetrunc_week_saturday",
"datetrunc_quarterday"}}

Definition at line 49 of file DateTruncate.h.

Referenced by CodeGenerator::codegen(), and CodeGenerator::codegenDateTruncHighPrecisionTimestamps().