Skip to content

Commit

Permalink
change int to int64_t
Browse files Browse the repository at this point in the history
  • Loading branch information
pengweisong committed Apr 2, 2022
1 parent 07f0513 commit 60816a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
39 changes: 17 additions & 22 deletions src/kvstore/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
#include <folly/Function.h>
#include <rocksdb/slice.h>

#include <sstream>

#include "common/base/Base.h"
#include "common/datatypes/HostAddr.h"
#include "common/thrift/ThriftTypes.h"
#include "common/time/WallClock.h"
#include "common/utils/Types.h"
#include "interface/gen-cpp2/common_types.h"

DECLARE_int32(balance_expired_sesc);
DECLARE_int64(balance_expired_sesc);

namespace nebula {
namespace kvstore {
Expand Down Expand Up @@ -110,11 +112,11 @@ inline std::ostream& operator<<(std::ostream& os, const Peer& peer) {
struct Peers {
private:
std::map<HostAddr, Peer> peers;
int createdTime;
int64_t createdTime;

public:
Peers() {
createdTime = static_cast<int>(time::WallClock::fastNowInSec());
createdTime = time::WallClock::fastNowInSec();
}
explicit Peers(const std::vector<HostAddr>& addrs) { // from normal peers
for (auto& addr : addrs) {
Expand Down Expand Up @@ -178,8 +180,7 @@ struct Peers {
}

bool isExpired() const {
return static_cast<int>(time::WallClock::fastNowInSec()) - createdTime >
static_cast<int>(FLAGS_balance_expired_sesc);
return time::WallClock::fastNowInSec() - createdTime > FLAGS_balance_expired_sesc;
}

void setCreatedTime(int time) {
Expand All @@ -196,26 +197,20 @@ struct Peers {
return os.str();
}

static std::tuple<int, int, int> extractHeader(const std::string& header) {
auto pos = header.find(":");
if (pos == std::string::npos) {
LOG(INFO) << "Parse version from part peers header error:" << header;
return {0, 0, 0};
}
int version = std::stoi(header.substr(pos + 1));
pos = header.find(":", pos + 1);
if (pos == std::string::npos) {
LOG(INFO) << "Parse count from part peers header error:" << header;
static std::tuple<int, int, int64_t> extractHeader(const std::string& header) {
std::vector<std::string> fields;
folly::split(":", header, fields, true);
if (fields.size() != 4) {
LOG(INFO) << "Parse part peers header error:" << header;
return {0, 0, 0};
}
int count = std::stoi(header.substr(pos + 1));

pos = header.find(":", pos + 1);
if (pos == std::string::npos) {
LOG(INFO) << "Parse created time from part peers header error:" << header;
return {0, 0, 0};
}
int createdTime = std::stoi(header.substr(pos + 1));
int version = std::stoi(fields[1]);
int count = std::stoi(fields[2]);

int64_t createdTime;
std::istringstream iss(fields[3]);
iss >> createdTime;

return {version, count, createdTime};
}
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/RocksEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "kvstore/KVStore.h"

DEFINE_bool(move_files, false, "Move the SST files instead of copy when ingest into dataset");
DEFINE_int32(balance_expired_sesc,
DEFINE_int64(balance_expired_sesc,
86400,
"The expired time of balancing part info persisted in the storaged");

Expand Down

0 comments on commit 60816a5

Please sign in to comment.