OmniSciDB  c0231cc57d
 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
 
std::string toString () const
 

Public Attributes

int64_t time
 

Detailed Description

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

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

Definition at line 287 of file heavydbTypes.h.

References time.

287  {
288  time = dateTimeParse<kTIMESTAMP>(str, 9);
289  }
int64_t time
Definition: heavydbTypes.h:280

Member Function Documentation

DEVICE ALWAYS_INLINE int64_t Timestamp::getDay ( ) const
inline

Definition at line 408 of file heavydbTypes.h.

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

408  {
410  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 405 of file heavydbTypes.h.

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

405  {
407  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 391 of file heavydbTypes.h.

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

391  {
393  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 395 of file heavydbTypes.h.

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

395  {
397  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 402 of file heavydbTypes.h.

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

402  {
404  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 411 of file heavydbTypes.h.

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

411  {
413  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 387 of file heavydbTypes.h.

References ExtractFromTime(), kNANOSECOND, and time.

387  {
389  }
int64_t time
Definition: heavydbTypes.h:280
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 399 of file heavydbTypes.h.

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

399  {
401  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 414 of file heavydbTypes.h.

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

414  {
416  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
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 346 of file heavydbTypes.h.

References operator==().

346  {
347  return !operator==(other);
348  }
DEVICE ALWAYS_INLINE bool operator==(const Timestamp &other) const
Definition: heavydbTypes.h:342

+ Here is the call graph for this function:

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

Definition at line 331 of file heavydbTypes.h.

References time, and Timestamp().

331  {
332 #ifndef __CUDACC__
333  uint64_t overflow_test =
334  static_cast<uint64_t>(time) * static_cast<uint64_t>(multiplier);
335  if (time != 0 && overflow_test / time != static_cast<uint64_t>(multiplier)) {
336  throw std::runtime_error("Overflow in Timestamp multiplication!");
337  }
338 #endif
339  return Timestamp(time * multiplier);
340  }
int64_t time
Definition: heavydbTypes.h:280
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 292 of file heavydbTypes.h.

References time, and Timestamp().

292  {
293 #ifndef __CUDACC__
294  if (other.time > 0) {
295  if (time > (std::numeric_limits<int64_t>::max() - other.time)) {
296  throw std::underflow_error("Underflow in Timestamp addition!");
297  }
298  } else {
299  if (time < (std::numeric_limits<int64_t>::min() - other.time)) {
300  throw std::overflow_error("Overflow in Timestamp addition!");
301  }
302  }
303 #endif
304  return Timestamp(time + other.time);
305  }
int64_t time
Definition: heavydbTypes.h:280
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 307 of file heavydbTypes.h.

References time, and Timestamp().

307  {
308 #ifndef __CUDACC__
309  if (other.time > 0) {
310  if (time < (std::numeric_limits<int64_t>::min() + other.time)) {
311  throw std::underflow_error("Underflow in Timestamp substraction!");
312  }
313  } else {
314  if (time > (std::numeric_limits<int64_t>::max() + other.time)) {
315  throw std::overflow_error("Overflow in Timestamp substraction!");
316  }
317  }
318 #endif
319  return Timestamp(time - other.time);
320  }
int64_t time
Definition: heavydbTypes.h:280
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 322 of file heavydbTypes.h.

References time.

322  {
323 #ifndef __CUDACC__
324  if (other.time == 0) {
325  throw std::runtime_error("Timestamp division by zero!");
326  }
327 #endif
328  return time / other.time;
329  }
int64_t time
Definition: heavydbTypes.h:280
DEVICE ALWAYS_INLINE bool Timestamp::operator< ( const Timestamp other) const
inline

Definition at line 350 of file heavydbTypes.h.

References time.

350  {
351  return time < other.time;
352  }
int64_t time
Definition: heavydbTypes.h:280
DEVICE ALWAYS_INLINE bool Timestamp::operator== ( const Timestamp other) const
inline

Definition at line 342 of file heavydbTypes.h.

References time.

Referenced by operator!=().

342  {
343  return time == other.time;
344  }
int64_t time
Definition: heavydbTypes.h:280

+ Here is the caller graph for this function:

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

Definition at line 418 of file heavydbTypes.h.

References time, and typeName().

418  {
419  return ::typeName(this) + "(time=" + ::toString(time) + ")";
420  }
int64_t time
Definition: heavydbTypes.h:280
std::string toString() const
Definition: heavydbTypes.h:418
std::string typeName(const T *v)
Definition: toString.h:103

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToDay ( ) const
inline

Definition at line 375 of file heavydbTypes.h.

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

375  {
377  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToHours ( ) const
inline

Definition at line 371 of file heavydbTypes.h.

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

371  {
373  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMicroseconds ( ) const
inline

Definition at line 354 of file heavydbTypes.h.

References kMilliSecsPerSec, time, and Timestamp().

354  {
356  }
int64_t time
Definition: heavydbTypes.h:280
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 358 of file heavydbTypes.h.

References kMicroSecsPerSec, time, and Timestamp().

358  {
360  }
int64_t time
Definition: heavydbTypes.h:280
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 367 of file heavydbTypes.h.

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

367  {
369  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToMonth ( ) const
inline

Definition at line 379 of file heavydbTypes.h.

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

379  {
381  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToSeconds ( ) const
inline

Definition at line 362 of file heavydbTypes.h.

References kNanoSecsPerSec, time, and Timestamp().

362  {
364  }
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
Timestamp()=default

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE Timestamp Timestamp::truncateToYear ( ) const
inline

Definition at line 383 of file heavydbTypes.h.

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

383  {
385  }
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
static constexpr int64_t kNanoSecsPerSec
int64_t time
Definition: heavydbTypes.h:280
Timestamp()=default

+ Here is the call graph for this function:

Member Data Documentation


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