OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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

DEVICE 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

DEVICE int64_t DateTruncate ( DatetruncField  field,
const int64_t  timeval 
)

Definition at line 242 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(), DateTimeTranslator::getDateTruncConstantValue(), Timestamp::truncateToDay(), Timestamp::truncateToHours(), Timestamp::truncateToMinutes(), Timestamp::truncateToMonth(), and Timestamp::truncateToYear().

242  {
243  switch (field) {
244  case dtNANOSECOND:
245  case dtMICROSECOND:
246  case dtMILLISECOND:
247  case dtSECOND:
248  return timeval;
249  case dtMINUTE:
250  return datetrunc_minute(timeval);
251  case dtHOUR:
252  return datetrunc_hour(timeval);
253  case dtQUARTERDAY:
254  return datetrunc_quarterday(timeval);
255  case dtDAY:
256  return datetrunc_day(timeval);
257  case dtWEEK:
258  return datetrunc_week_monday(timeval);
259  case dtWEEK_SUNDAY:
260  return datetrunc_week_sunday(timeval);
261  case dtWEEK_SATURDAY:
262  return datetrunc_week_saturday(timeval);
263  case dtMONTH:
264  return datetrunc_month(timeval);
265  case dtQUARTER:
266  return datetrunc_quarter(timeval);
267  case dtYEAR:
268  return datetrunc_year(timeval);
269  case dtDECADE:
270  return datetrunc_decade(timeval);
271  case dtCENTURY:
272  return datetrunc_century(timeval);
273  case dtMILLENNIUM:
274  return datetrunc_millennium(timeval);
275  default:
276 #ifdef __CUDACC__
277  return std::numeric_limits<int64_t>::min();
278 #else
279  abort();
280 #endif
281  }
282 }
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:33
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 286 of file DateTruncate.cpp.

References floor_div(), and kSecsPerDay.

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

286  {
287  return floor_div(timeval, scale * kSecsPerDay) * kSecsPerDay;
288 }
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().