From f4dfafdb20784ad6a9ab844b424bf96756756110 Mon Sep 17 00:00:00 2001 From: zy-kkk Date: Wed, 24 Apr 2024 11:04:11 +0800 Subject: [PATCH] [fix][compile] Resolve time_point type mismatch on MacOS and Linux --- be/src/util/s3_rate_limiter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/be/src/util/s3_rate_limiter.cpp b/be/src/util/s3_rate_limiter.cpp index e39c8a54c46129..44099ab1438da8 100644 --- a/be/src/util/s3_rate_limiter.cpp +++ b/be/src/util/s3_rate_limiter.cpp @@ -24,6 +24,12 @@ #include "util/s3_util.h" #include "util/spinlock.h" #include "util/time.h" +#if defined(__APPLE__) +#include +#define CURRENT_TIME std::chrono::system_clock::now() +#else +#define CURRENT_TIME std::chrono::high_resolution_clock::now() +#endif namespace doris { // Just 10^6. @@ -51,8 +57,7 @@ std::pair S3RateLimiter::_update_remain_token( int64_t S3RateLimiter::add(size_t amount) { // Values obtained under lock to be checked after release - auto [count_value, tokens_value] = - _update_remain_token(std::chrono::high_resolution_clock::now(), amount); + auto [count_value, tokens_value] = _update_remain_token(CURRENT_TIME, amount); if (_limit && count_value > _limit) { // CK would throw exception