OmniSciDB  cde582ebc3
 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 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 212 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 217 of file heavydbTypes.h.

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

Definition at line 220 of file heavydbTypes.h.

References time.

220  {
221  time = dateTimeParse<kTIMESTAMP>(str, 9);
222  }
int64_t time
Definition: heavydbTypes.h:213

Member Function Documentation

DEVICE ALWAYS_INLINE int64_t Timestamp::getDay ( ) const
inline

Definition at line 341 of file heavydbTypes.h.

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

341  {
343  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
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 338 of file heavydbTypes.h.

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

338  {
340  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
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 324 of file heavydbTypes.h.

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

324  {
326  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
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 328 of file heavydbTypes.h.

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

328  {
330  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
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 335 of file heavydbTypes.h.

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

335  {
337  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
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 344 of file heavydbTypes.h.

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

344  {
346  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE int64_t Timestamp::getNanoseconds ( ) const
inline

Definition at line 320 of file heavydbTypes.h.

References ExtractFromTime(), kNANOSECOND, and time.

320  {
322  }
int64_t time
Definition: heavydbTypes.h:213
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 332 of file heavydbTypes.h.

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

332  {
334  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
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 347 of file heavydbTypes.h.

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

347  {
349  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
DEVICE int64_t ExtractFromTime(ExtractField field, const int64_t timeval)

+ Here is the call graph for this function:

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

Definition at line 279 of file heavydbTypes.h.

References operator==().

279  {
280  return !operator==(other);
281  }
DEVICE ALWAYS_INLINE bool operator==(const Timestamp &other) const
Definition: heavydbTypes.h:275

+ Here is the call graph for this function:

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

Definition at line 264 of file heavydbTypes.h.

References time, and Timestamp().

264  {
265 #ifndef __CUDACC__
266  uint64_t overflow_test =
267  static_cast<uint64_t>(time) * static_cast<uint64_t>(multiplier);
268  if (time != 0 && overflow_test / time != static_cast<uint64_t>(multiplier)) {
269  throw std::runtime_error("Overflow in Timestamp multiplication!");
270  }
271 #endif
272  return Timestamp(time * multiplier);
273  }
int64_t time
Definition: heavydbTypes.h:213
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 225 of file heavydbTypes.h.

References time, and Timestamp().

225  {
226 #ifndef __CUDACC__
227  if (other.time > 0) {
228  if (time > (std::numeric_limits<int64_t>::max() - other.time)) {
229  throw std::underflow_error("Underflow in Timestamp addition!");
230  }
231  } else {
232  if (time < (std::numeric_limits<int64_t>::min() - other.time)) {
233  throw std::overflow_error("Overflow in Timestamp addition!");
234  }
235  }
236 #endif
237  return Timestamp(time + other.time);
238  }
int64_t time
Definition: heavydbTypes.h:213
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 240 of file heavydbTypes.h.

References time, and Timestamp().

240  {
241 #ifndef __CUDACC__
242  if (other.time > 0) {
243  if (time < (std::numeric_limits<int64_t>::min() + other.time)) {
244  throw std::underflow_error("Underflow in Timestamp substraction!");
245  }
246  } else {
247  if (time > (std::numeric_limits<int64_t>::max() + other.time)) {
248  throw std::overflow_error("Overflow in Timestamp substraction!");
249  }
250  }
251 #endif
252  return Timestamp(time - other.time);
253  }
int64_t time
Definition: heavydbTypes.h:213
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 255 of file heavydbTypes.h.

References time.

255  {
256 #ifndef __CUDACC__
257  if (other.time == 0) {
258  throw std::runtime_error("Timestamp division by zero!");
259  }
260 #endif
261  return time / other.time;
262  }
int64_t time
Definition: heavydbTypes.h:213
DEVICE ALWAYS_INLINE bool Timestamp::operator< ( const Timestamp other) const
inline

Definition at line 283 of file heavydbTypes.h.

References time.

283  {
284  return time < other.time;
285  }
int64_t time
Definition: heavydbTypes.h:213
DEVICE ALWAYS_INLINE bool Timestamp::operator== ( const Timestamp other) const
inline

Definition at line 275 of file heavydbTypes.h.

References time.

Referenced by operator!=().

275  {
276  return time == other.time;
277  }
int64_t time
Definition: heavydbTypes.h:213

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToDay ( ) const
inline

Definition at line 308 of file heavydbTypes.h.

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

308  {
310  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToHours ( ) const
inline

Definition at line 304 of file heavydbTypes.h.

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

304  {
306  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMicroseconds ( ) const
inline

Definition at line 287 of file heavydbTypes.h.

References kMilliSecsPerSec, time, and Timestamp().

287  {
289  }
int64_t time
Definition: heavydbTypes.h:213
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 291 of file heavydbTypes.h.

References kMicroSecsPerSec, time, and Timestamp().

291  {
293  }
int64_t time
Definition: heavydbTypes.h:213
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 300 of file heavydbTypes.h.

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

300  {
302  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMonth ( ) const
inline

Definition at line 312 of file heavydbTypes.h.

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

312  {
314  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToSeconds ( ) const
inline

Definition at line 295 of file heavydbTypes.h.

References kNanoSecsPerSec, time, and Timestamp().

295  {
297  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:213
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToYear ( ) const
inline

Definition at line 316 of file heavydbTypes.h.

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

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

+ Here is the call graph for this function:

Member Data Documentation


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