OmniSciDB  a5dc49c757
 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 698 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 703 of file heavydbTypes.h.

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

Definition at line 709 of file heavydbTypes.h.

References time.

709  {
710  time = dateTimeParse<kTIMESTAMP>(str, 9);
711  }
int64_t time
Definition: heavydbTypes.h:699

Member Function Documentation

DEVICE ALWAYS_INLINE int64_t Timestamp::getDay ( ) const
inline

Definition at line 828 of file heavydbTypes.h.

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

828  {
830  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 825 of file heavydbTypes.h.

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

825  {
827  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 811 of file heavydbTypes.h.

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

811  {
813  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 815 of file heavydbTypes.h.

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

815  {
817  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 822 of file heavydbTypes.h.

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

822  {
824  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 831 of file heavydbTypes.h.

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

Referenced by YearMonthTimeInterval::numStepsBetween().

831  {
833  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 807 of file heavydbTypes.h.

References ExtractFromTime(), kNANOSECOND, and time.

807  {
809  }
int64_t time
Definition: heavydbTypes.h:699
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 819 of file heavydbTypes.h.

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

819  {
821  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 834 of file heavydbTypes.h.

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

Referenced by YearMonthTimeInterval::numStepsBetween().

834  {
836  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
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 767 of file heavydbTypes.h.

References operator==().

767  {
768  return !operator==(other);
769  }
DEVICE ALWAYS_INLINE bool operator==(const Timestamp &other) const
Definition: heavydbTypes.h:763

+ Here is the call graph for this function:

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

Definition at line 753 of file heavydbTypes.h.

References time, and Timestamp().

753  {
754 #ifndef __CUDACC__
755  int64_t overflow_test = static_cast<int64_t>(time) * static_cast<int64_t>(multiplier);
756  if (time != 0 && overflow_test / time != static_cast<int64_t>(multiplier)) {
757  throw std::overflow_error("Overflow in Timestamp multiplication!");
758  }
759 #endif
760  return Timestamp(time * multiplier);
761  }
int64_t time
Definition: heavydbTypes.h:699
Timestamp()=default

+ Here is the call graph for this function:

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

Definition at line 937 of file heavydbTypes.h.

938  {
939  return interval + *this;
940 }
DEVICE ALWAYS_INLINE Timestamp Timestamp::operator+ ( const YearMonthTimeInterval interval) const
inline

Definition at line 942 of file heavydbTypes.h.

943  {
944  return interval + *this;
945 }
DEVICE ALWAYS_INLINE const Timestamp Timestamp::operator+ ( const Timestamp other) const
inline

Definition at line 714 of file heavydbTypes.h.

References time, and Timestamp().

714  {
715 #ifndef __CUDACC__
716  if (other.time > 0) {
717  if (time > (std::numeric_limits<int64_t>::max() - other.time)) {
718  throw std::underflow_error("Underflow in Timestamp addition!");
719  }
720  } else {
721  if (time < (std::numeric_limits<int64_t>::min() - other.time)) {
722  throw std::overflow_error("Overflow in Timestamp addition!");
723  }
724  }
725 #endif
726  return Timestamp(time + other.time);
727  }
int64_t time
Definition: heavydbTypes.h:699
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 729 of file heavydbTypes.h.

References time, and Timestamp().

729  {
730 #ifndef __CUDACC__
731  if (other.time > 0) {
732  if (time < (std::numeric_limits<int64_t>::min() + other.time)) {
733  throw std::underflow_error("Underflow in Timestamp substraction!");
734  }
735  } else {
736  if (time > (std::numeric_limits<int64_t>::max() + other.time)) {
737  throw std::overflow_error("Overflow in Timestamp substraction!");
738  }
739  }
740 #endif
741  return Timestamp(time - other.time);
742  }
int64_t time
Definition: heavydbTypes.h:699
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 744 of file heavydbTypes.h.

References time.

744  {
745 #ifndef __CUDACC__
746  if (other.time == 0) {
747  throw std::runtime_error("Timestamp division by zero!");
748  }
749 #endif
750  return time / other.time;
751  }
int64_t time
Definition: heavydbTypes.h:699
DEVICE ALWAYS_INLINE bool Timestamp::operator< ( const Timestamp other) const
inline

Definition at line 771 of file heavydbTypes.h.

References time.

771  {
772  return time < other.time;
773  }
int64_t time
Definition: heavydbTypes.h:699
DEVICE ALWAYS_INLINE bool Timestamp::operator== ( const Timestamp other) const
inline

Definition at line 763 of file heavydbTypes.h.

References time.

Referenced by operator!=().

763  {
764  return time == other.time;
765  }
int64_t time
Definition: heavydbTypes.h:699

+ Here is the caller graph for this function:

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

Definition at line 838 of file heavydbTypes.h.

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

838  {
839  Datum d;
840  d.bigintval = time;
841  return ::typeName(this) + "(time=" + ::toString(time) + ")" +
842  ", (formatted= " + DatumToString(d, SQLTypeInfo(kTIMESTAMP, 9, 0, false)) +
843  ")";
844  }
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:460
int64_t time
Definition: heavydbTypes.h:699
std::string toString() const
Definition: heavydbTypes.h:838
int64_t bigintval
Definition: Datum.h:76
std::string typeName(const T *v)
Definition: toString.h:106
Definition: Datum.h:71

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToDay ( ) const
inline

Definition at line 795 of file heavydbTypes.h.

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

795  {
797  }
static constexpr int64_t kNanoSecsPerSec
DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t time
Definition: heavydbTypes.h:699
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToHours ( ) const
inline

Definition at line 791 of file heavydbTypes.h.

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

791  {
793  }
static constexpr int64_t kNanoSecsPerSec
DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t time
Definition: heavydbTypes.h:699
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMicroseconds ( ) const
inline

Definition at line 775 of file heavydbTypes.h.

References kMilliSecsPerSec, time, and Timestamp().

775  {
777  }
int64_t time
Definition: heavydbTypes.h:699
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 779 of file heavydbTypes.h.

References kMicroSecsPerSec, time, and Timestamp().

779  {
781  }
int64_t time
Definition: heavydbTypes.h:699
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 787 of file heavydbTypes.h.

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

787  {
789  }
static constexpr int64_t kNanoSecsPerSec
DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t time
Definition: heavydbTypes.h:699
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMonth ( ) const
inline

Definition at line 799 of file heavydbTypes.h.

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

799  {
801  }
static constexpr int64_t kNanoSecsPerSec
DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t time
Definition: heavydbTypes.h:699
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToSeconds ( ) const
inline

Definition at line 783 of file heavydbTypes.h.

References kNanoSecsPerSec, time, and Timestamp().

783  {
785  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:699
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToYear ( ) const
inline

Definition at line 803 of file heavydbTypes.h.

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

803  {
805  }
static constexpr int64_t kNanoSecsPerSec
DEVICE int64_t DateTruncate(DatetruncField field, const int64_t timeval)
int64_t time
Definition: heavydbTypes.h:699
Timestamp()=default

+ Here is the call graph for this function:

Member Data Documentation


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