OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::anonymous_namespace{RefreshTimeCalculator.cpp} Namespace Reference

Functions

int64_t get_interval_duration (const std::string &interval)
 

Function Documentation

int64_t foreign_storage::anonymous_namespace{RefreshTimeCalculator.cpp}::get_interval_duration ( const std::string &  interval)

Gets the interval duration in seconds.

Parameters
interval- interval string with format of {interval_count}{interval_type} (e.g. 5H for "every 5 hours")
Returns
internal duration in seconds

Definition at line 33 of file RefreshTimeCalculator.cpp.

References UNREACHABLE.

Referenced by foreign_storage::RefreshTimeCalculator::getNextRefreshTime().

33  {
34  int interval_count = std::stoi(interval.substr(0, interval.length() - 1));
35  auto interval_type = std::tolower(interval[interval.length() - 1]);
36  int64_t duration{0};
37  if (interval_type == 's') {
38  duration = interval_count;
39  } else if (interval_type == 'h') {
40  duration = interval_count * 60 * 60;
41  } else if (interval_type == 'd') {
42  duration = interval_count * 60 * 60 * 24;
43  } else {
44  UNREACHABLE();
45  }
46  return duration;
47 }
#define UNREACHABLE()
Definition: Logger.h:255

+ Here is the caller graph for this function: