OmniSciDB  dfae7c3b14
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, 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 
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 214 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(), datetrunc_year(), DEVICE, dtCENTURY, dtDAY, dtDECADE, dtHOUR, dtMICROSECOND, dtMILLENNIUM, dtMILLISECOND, dtMINUTE, dtMONTH, dtNANOSECOND, dtQUARTER, dtQUARTERDAY, dtSECOND, dtWEEK, and dtYEAR.

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

214  {
215  switch (field) {
216  case dtNANOSECOND:
217  case dtMICROSECOND:
218  case dtMILLISECOND:
219  case dtSECOND:
220  return timeval;
221  case dtMINUTE:
222  return datetrunc_minute(timeval);
223  case dtHOUR:
224  return datetrunc_hour(timeval);
225  case dtQUARTERDAY:
226  return datetrunc_quarterday(timeval);
227  case dtDAY:
228  return datetrunc_day(timeval);
229  case dtWEEK:
230  return datetrunc_week(timeval);
231  case dtMONTH:
232  return datetrunc_month(timeval);
233  case dtQUARTER:
234  return datetrunc_quarter(timeval);
235  case dtYEAR:
236  return datetrunc_year(timeval);
237  case dtDECADE:
238  return datetrunc_decade(timeval);
239  case dtCENTURY:
240  return datetrunc_century(timeval);
241  case dtMILLENNIUM:
242  return datetrunc_millennium(timeval);
243  default:
244 #ifdef __CUDACC__
245  return std::numeric_limits<int64_t>::min();
246 #else
247  abort();
248 #endif
249  }
250 }
ALWAYS_INLINE DEVICE int64_t datetrunc_week(int64_t timeval)
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_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_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 254 of file DateTruncate.cpp.

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

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

254  {
255  return floor_div(timeval, scale * kSecsPerDay) * kSecsPerDay;
256 }
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",
"datetrunc_quarterday"}}

Definition at line 46 of file DateTruncate.h.

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