OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Timestamp Struct Reference

#include <heavydbTypes.h>

Public Member Functions

 Timestamp ()=default
 
DEVICE Timestamp (int64_t timeval)
 
DEVICE ALWAYS_INLINE Timestamp operator+ (const DayTimeInterval &interval) const
 
DEVICE ALWAYS_INLINE Timestamp operator+ (const YearMonthTimeInterval &interval) const
 
DEVICE Timestamp (std::string_view const str)
 
DEVICE ALWAYS_INLINE const
Timestamp 
operator+ (const Timestamp &other) const
 
DEVICE ALWAYS_INLINE const
Timestamp 
operator- (const Timestamp &other) const
 
DEVICE ALWAYS_INLINE int64_t operator/ (const Timestamp &other) const
 
DEVICE ALWAYS_INLINE const
Timestamp 
operator* (const int64_t multiplier) const
 
DEVICE ALWAYS_INLINE bool operator== (const Timestamp &other) const
 
DEVICE ALWAYS_INLINE bool operator!= (const Timestamp &other) const
 
DEVICE ALWAYS_INLINE bool operator< (const Timestamp &other) const
 
DEVICE ALWAYS_INLINE Timestamp truncateToMicroseconds () const
 
DEVICE ALWAYS_INLINE Timestamp truncateToMilliseconds () const
 
DEVICE ALWAYS_INLINE Timestamp truncateToSeconds () const
 
DEVICE ALWAYS_INLINE Timestamp truncateToMinutes () const
 
DEVICE ALWAYS_INLINE Timestamp truncateToHours () const
 
DEVICE ALWAYS_INLINE Timestamp truncateToDay () const
 
DEVICE ALWAYS_INLINE Timestamp truncateToMonth () const
 
DEVICE ALWAYS_INLINE Timestamp truncateToYear () const
 
DEVICE ALWAYS_INLINE int64_t getNanoseconds () const
 
DEVICE ALWAYS_INLINE int64_t getMicroseconds () const
 
DEVICE ALWAYS_INLINE int64_t getMilliseconds () const
 
DEVICE ALWAYS_INLINE int64_t getSeconds () const
 
DEVICE ALWAYS_INLINE int64_t getMinutes () const
 
DEVICE ALWAYS_INLINE int64_t getHours () const
 
DEVICE ALWAYS_INLINE int64_t getDay () const
 
DEVICE ALWAYS_INLINE int64_t getMonth () const
 
DEVICE ALWAYS_INLINE int64_t getYear () const
 
std::string toString () const
 

Public Attributes

int64_t time
 

Detailed Description

Definition at line 315 of file heavydbTypes.h.

Constructor & Destructor Documentation

Timestamp::Timestamp ( )
default

Referenced by operator*(), operator+(), operator-(), truncateToDay(), truncateToHours(), truncateToMicroseconds(), truncateToMilliseconds(), truncateToMinutes(), truncateToMonth(), truncateToSeconds(), and truncateToYear().

+ Here is the caller graph for this function:

DEVICE Timestamp::Timestamp ( int64_t  timeval)
inline

Definition at line 320 of file heavydbTypes.h.

320 : time(timeval) {}
int64_t time
Definition: heavydbTypes.h:316
DEVICE Timestamp::Timestamp ( std::string_view const  str)
inline

Definition at line 326 of file heavydbTypes.h.

References time.

326  {
327  time = dateTimeParse<kTIMESTAMP>(str, 9);
328  }
int64_t time
Definition: heavydbTypes.h:316

Member Function Documentation

DEVICE ALWAYS_INLINE int64_t Timestamp::getDay ( ) const
inline

Definition at line 445 of file heavydbTypes.h.

References ExtractFromTime(), kDAY, kNanoSecsPerSec, and time.

445  {
447  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getHours ( ) const
inline

Definition at line 442 of file heavydbTypes.h.

References ExtractFromTime(), kHOUR, kNanoSecsPerSec, and time.

442  {
444  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getMicroseconds ( ) const
inline

Definition at line 428 of file heavydbTypes.h.

References ExtractFromTime(), kMICROSECOND, kMicroSecsPerSec, kNanoSecsPerSec, and time.

428  {
430  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)
static constexpr int64_t kMicroSecsPerSec

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getMilliseconds ( ) const
inline

Definition at line 432 of file heavydbTypes.h.

References ExtractFromTime(), kMILLISECOND, kMilliSecsPerSec, kNanoSecsPerSec, and time.

432  {
434  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
static constexpr int64_t kMilliSecsPerSec
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getMinutes ( ) const
inline

Definition at line 439 of file heavydbTypes.h.

References ExtractFromTime(), kMINUTE, kNanoSecsPerSec, and time.

439  {
441  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getMonth ( ) const
inline

Definition at line 448 of file heavydbTypes.h.

References ExtractFromTime(), kMONTH, kNanoSecsPerSec, and time.

Referenced by YearMonthTimeInterval::numStepsBetween().

448  {
450  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getNanoseconds ( ) const
inline

Definition at line 424 of file heavydbTypes.h.

References ExtractFromTime(), kNANOSECOND, and time.

424  {
426  }
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getSeconds ( ) const
inline

Definition at line 436 of file heavydbTypes.h.

References ExtractFromTime(), kNanoSecsPerSec, kSECOND, and time.

436  {
438  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getYear ( ) const
inline

Definition at line 451 of file heavydbTypes.h.

References ExtractFromTime(), kNanoSecsPerSec, kYEAR, and time.

Referenced by YearMonthTimeInterval::numStepsBetween().

451  {
453  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool Timestamp::operator!= ( const Timestamp other) const
inline

Definition at line 384 of file heavydbTypes.h.

References operator==().

384  {
385  return !operator==(other);
386  }
DEVICE ALWAYS_INLINE bool operator==(const Timestamp &other) const
Definition: heavydbTypes.h:380

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE const Timestamp Timestamp::operator* ( const int64_t  multiplier) const
inline

Definition at line 370 of file heavydbTypes.h.

References time, and Timestamp().

370  {
371 #ifndef __CUDACC__
372  int64_t overflow_test = static_cast<int64_t>(time) * static_cast<int64_t>(multiplier);
373  if (time != 0 && overflow_test / time != static_cast<int64_t>(multiplier)) {
374  throw std::overflow_error("Overflow in Timestamp multiplication!");
375  }
376 #endif
377  return Timestamp(time * multiplier);
378  }
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::operator+ ( const DayTimeInterval interval) const
inline

Definition at line 554 of file heavydbTypes.h.

555  {
556  return interval + *this;
557 }
DEVICE ALWAYS_INLINE Timestamp Timestamp::operator+ ( const YearMonthTimeInterval interval) const
inline

Definition at line 559 of file heavydbTypes.h.

560  {
561  return interval + *this;
562 }
DEVICE ALWAYS_INLINE const Timestamp Timestamp::operator+ ( const Timestamp other) const
inline

Definition at line 331 of file heavydbTypes.h.

References time, and Timestamp().

331  {
332 #ifndef __CUDACC__
333  if (other.time > 0) {
334  if (time > (std::numeric_limits<int64_t>::max() - other.time)) {
335  throw std::underflow_error("Underflow in Timestamp addition!");
336  }
337  } else {
338  if (time < (std::numeric_limits<int64_t>::min() - other.time)) {
339  throw std::overflow_error("Overflow in Timestamp addition!");
340  }
341  }
342 #endif
343  return Timestamp(time + other.time);
344  }
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE const Timestamp Timestamp::operator- ( const Timestamp other) const
inline

Definition at line 346 of file heavydbTypes.h.

References time, and Timestamp().

346  {
347 #ifndef __CUDACC__
348  if (other.time > 0) {
349  if (time < (std::numeric_limits<int64_t>::min() + other.time)) {
350  throw std::underflow_error("Underflow in Timestamp substraction!");
351  }
352  } else {
353  if (time > (std::numeric_limits<int64_t>::max() + other.time)) {
354  throw std::overflow_error("Overflow in Timestamp substraction!");
355  }
356  }
357 #endif
358  return Timestamp(time - other.time);
359  }
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::operator/ ( const Timestamp other) const
inline

Definition at line 361 of file heavydbTypes.h.

References time.

361  {
362 #ifndef __CUDACC__
363  if (other.time == 0) {
364  throw std::runtime_error("Timestamp division by zero!");
365  }
366 #endif
367  return time / other.time;
368  }
int64_t time
Definition: heavydbTypes.h:316
DEVICE ALWAYS_INLINE bool Timestamp::operator< ( const Timestamp other) const
inline

Definition at line 388 of file heavydbTypes.h.

References time.

388  {
389  return time < other.time;
390  }
int64_t time
Definition: heavydbTypes.h:316
DEVICE ALWAYS_INLINE bool Timestamp::operator== ( const Timestamp other) const
inline

Definition at line 380 of file heavydbTypes.h.

References time.

Referenced by operator!=().

380  {
381  return time == other.time;
382  }
int64_t time
Definition: heavydbTypes.h:316

+ Here is the caller graph for this function:

std::string Timestamp::toString ( ) const
inline

Definition at line 455 of file heavydbTypes.h.

References Datum::bigintval, DatumToString(), kTIMESTAMP, time, and typeName().

455  {
456  Datum d;
457  d.bigintval = time;
458  return ::typeName(this) + "(time=" + ::toString(time) + ")" +
459  ", (formatted= " + DatumToString(d, SQLTypeInfo(kTIMESTAMP, 9, 0, false)) +
460  ")";
461  }
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:458
int64_t time
Definition: heavydbTypes.h:316
std::string toString() const
Definition: heavydbTypes.h:455
int64_t bigintval
Definition: Datum.h:72
std::string typeName(const T *v)
Definition: toString.h:103
Definition: Datum.h:67

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToDay ( ) const
inline

Definition at line 412 of file heavydbTypes.h.

References DateTruncate(), dtDAY, kNanoSecsPerSec, time, and Timestamp().

412  {
414  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToHours ( ) const
inline

Definition at line 408 of file heavydbTypes.h.

References DateTruncate(), dtHOUR, kNanoSecsPerSec, time, and Timestamp().

408  {
410  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMicroseconds ( ) const
inline

Definition at line 392 of file heavydbTypes.h.

References kMilliSecsPerSec, time, and Timestamp().

392  {
394  }
int64_t time
Definition: heavydbTypes.h:316
static constexpr int64_t kMilliSecsPerSec
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMilliseconds ( ) const
inline

Definition at line 396 of file heavydbTypes.h.

References kMicroSecsPerSec, time, and Timestamp().

396  {
398  }
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default
static constexpr int64_t kMicroSecsPerSec

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMinutes ( ) const
inline

Definition at line 404 of file heavydbTypes.h.

References DateTruncate(), dtMINUTE, kNanoSecsPerSec, time, and Timestamp().

404  {
406  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMonth ( ) const
inline

Definition at line 416 of file heavydbTypes.h.

References DateTruncate(), dtMONTH, kNanoSecsPerSec, time, and Timestamp().

416  {
418  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToSeconds ( ) const
inline

Definition at line 400 of file heavydbTypes.h.

References kNanoSecsPerSec, time, and Timestamp().

400  {
402  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToYear ( ) const
inline

Definition at line 420 of file heavydbTypes.h.

References DateTruncate(), dtYEAR, kNanoSecsPerSec, time, and Timestamp().

420  {
422  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:316
Timestamp()=default

+ Here is the call graph for this function:

Member Data Documentation


The documentation for this struct was generated from the following file: