OmniSciDB  c1a53651b2
 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
 

Public Attributes

int64_t time
 

Detailed Description

Definition at line 340 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 345 of file heavydbTypes.h.

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

Definition at line 351 of file heavydbTypes.h.

References time.

351  {
352  time = dateTimeParse<kTIMESTAMP>(str, 9);
353  }
int64_t time
Definition: heavydbTypes.h:341

Member Function Documentation

DEVICE ALWAYS_INLINE int64_t Timestamp::getDay ( ) const
inline

Definition at line 470 of file heavydbTypes.h.

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

470  {
472  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 467 of file heavydbTypes.h.

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

467  {
469  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 453 of file heavydbTypes.h.

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

453  {
455  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 457 of file heavydbTypes.h.

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

457  {
459  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 464 of file heavydbTypes.h.

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

464  {
466  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 473 of file heavydbTypes.h.

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

Referenced by YearMonthTimeInterval::numStepsBetween().

473  {
475  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 449 of file heavydbTypes.h.

References ExtractFromTime(), kNANOSECOND, and time.

449  {
451  }
int64_t time
Definition: heavydbTypes.h:341
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 461 of file heavydbTypes.h.

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

461  {
463  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 476 of file heavydbTypes.h.

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

Referenced by YearMonthTimeInterval::numStepsBetween().

476  {
478  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
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 409 of file heavydbTypes.h.

References operator==().

409  {
410  return !operator==(other);
411  }
DEVICE ALWAYS_INLINE bool operator==(const Timestamp &other) const
Definition: heavydbTypes.h:405

+ Here is the call graph for this function:

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

Definition at line 395 of file heavydbTypes.h.

References time, and Timestamp().

395  {
396 #ifndef __CUDACC__
397  int64_t overflow_test = static_cast<int64_t>(time) * static_cast<int64_t>(multiplier);
398  if (time != 0 && overflow_test / time != static_cast<int64_t>(multiplier)) {
399  throw std::overflow_error("Overflow in Timestamp multiplication!");
400  }
401 #endif
402  return Timestamp(time * multiplier);
403  }
int64_t time
Definition: heavydbTypes.h:341
Timestamp()=default

+ Here is the call graph for this function:

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

Definition at line 579 of file heavydbTypes.h.

580  {
581  return interval + *this;
582 }
DEVICE ALWAYS_INLINE Timestamp Timestamp::operator+ ( const YearMonthTimeInterval interval) const
inline

Definition at line 584 of file heavydbTypes.h.

585  {
586  return interval + *this;
587 }
DEVICE ALWAYS_INLINE const Timestamp Timestamp::operator+ ( const Timestamp other) const
inline

Definition at line 356 of file heavydbTypes.h.

References time, and Timestamp().

356  {
357 #ifndef __CUDACC__
358  if (other.time > 0) {
359  if (time > (std::numeric_limits<int64_t>::max() - other.time)) {
360  throw std::underflow_error("Underflow in Timestamp addition!");
361  }
362  } else {
363  if (time < (std::numeric_limits<int64_t>::min() - other.time)) {
364  throw std::overflow_error("Overflow in Timestamp addition!");
365  }
366  }
367 #endif
368  return Timestamp(time + other.time);
369  }
int64_t time
Definition: heavydbTypes.h:341
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 371 of file heavydbTypes.h.

References time, and Timestamp().

371  {
372 #ifndef __CUDACC__
373  if (other.time > 0) {
374  if (time < (std::numeric_limits<int64_t>::min() + other.time)) {
375  throw std::underflow_error("Underflow in Timestamp substraction!");
376  }
377  } else {
378  if (time > (std::numeric_limits<int64_t>::max() + other.time)) {
379  throw std::overflow_error("Overflow in Timestamp substraction!");
380  }
381  }
382 #endif
383  return Timestamp(time - other.time);
384  }
int64_t time
Definition: heavydbTypes.h:341
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 386 of file heavydbTypes.h.

References time.

386  {
387 #ifndef __CUDACC__
388  if (other.time == 0) {
389  throw std::runtime_error("Timestamp division by zero!");
390  }
391 #endif
392  return time / other.time;
393  }
int64_t time
Definition: heavydbTypes.h:341
DEVICE ALWAYS_INLINE bool Timestamp::operator< ( const Timestamp other) const
inline

Definition at line 413 of file heavydbTypes.h.

References time.

413  {
414  return time < other.time;
415  }
int64_t time
Definition: heavydbTypes.h:341
DEVICE ALWAYS_INLINE bool Timestamp::operator== ( const Timestamp other) const
inline

Definition at line 405 of file heavydbTypes.h.

References time.

Referenced by operator!=().

405  {
406  return time == other.time;
407  }
int64_t time
Definition: heavydbTypes.h:341

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToDay ( ) const
inline

Definition at line 437 of file heavydbTypes.h.

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

437  {
439  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToHours ( ) const
inline

Definition at line 433 of file heavydbTypes.h.

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

433  {
435  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMicroseconds ( ) const
inline

Definition at line 417 of file heavydbTypes.h.

References kMilliSecsPerSec, time, and Timestamp().

417  {
419  }
int64_t time
Definition: heavydbTypes.h:341
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 421 of file heavydbTypes.h.

References kMicroSecsPerSec, time, and Timestamp().

421  {
423  }
int64_t time
Definition: heavydbTypes.h:341
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 429 of file heavydbTypes.h.

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

429  {
431  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMonth ( ) const
inline

Definition at line 441 of file heavydbTypes.h.

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

441  {
443  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToSeconds ( ) const
inline

Definition at line 425 of file heavydbTypes.h.

References kNanoSecsPerSec, time, and Timestamp().

425  {
427  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToYear ( ) const
inline

Definition at line 445 of file heavydbTypes.h.

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

445  {
447  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:341
Timestamp()=default

+ Here is the call graph for this function:

Member Data Documentation


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