OmniSciDB  0264ff685a
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)
 
DEVICE int64_t DateTruncateHighPrecisionToDate (const int64_t timeval, const int64_t scale)
 

Variables

constexpr std::array< char const *, dtINVALIDdatetrunc_fname_lookup
 

Enumeration Type Documentation

◆ DatetruncField

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

◆ DateTruncate()

int64_t DateTruncate ( DatetruncField  field,
const int64_t  timeval 
)

Definition at line 234 of file DateTruncate.cpp.

References ALWAYS_INLINE, 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(), DEVICE, 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().

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

◆ DateTruncateHighPrecisionToDate()

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

Definition at line 278 of file DateTruncate.cpp.

References ALWAYS_INLINE, DEVICE, floor_div(), and kSecsPerDay.

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

278  {
279  return floor_div(timeval, scale * kSecsPerDay) * kSecsPerDay;
280 }
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

◆ datetrunc_fname_lookup

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 48 of file DateTruncate.h.

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