Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: clundro <859287553@qq.com>
  • Loading branch information
infdahai committed May 2, 2023
1 parent 2a340e6 commit 5d48663
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ option(PORTABLE "build a portable binary (disable arch-specific optimizations)"
# TODO: set ENABLE_NEW_ENCODING to ON when we are ready
option(ENABLE_NEW_ENCODING "enable new encoding (#1033) for storing 64bit size and expire time in milliseconds" OFF)

set(CMAKE_LINK_DEPENDS_NO_SHARED 1)

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
Expand Down Expand Up @@ -63,6 +61,12 @@ set(DEPS_FETCH_PROXY "" CACHE STRING
"a template URL to proxy the traffic for fetching dependencies, e.g. with DEPS_FETCH_PROXY = https://some-proxy/,
https://example/some-dep.zip -> https://some-proxy/https://example/some-dep.zip")

if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None")
set (CMAKE_BUILD_TYPE "RelWithDebInfo")
message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = ${CMAKE_BUILD_TYPE}")
endif ()
message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if(ENABLE_ASAN AND ENABLE_TSAN)
message(FATAL_ERROR "ASan and TSan cannot be used at the same time")
endif()
Expand Down Expand Up @@ -166,12 +170,6 @@ if ((PROJECT_VERSION STREQUAL "unstable") AND (GIT_SHA STREQUAL ""))
endif ()
configure_file(src/version.h.in ${PROJECT_BINARY_DIR}/version.h)

if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None")
set (CMAKE_BUILD_TYPE "RelWithDebInfo")
message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = ${CMAKE_BUILD_TYPE}")
endif ()
message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")

Expand Down
12 changes: 4 additions & 8 deletions src/cluster/cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ Status Cluster::SetSlot(const std::string &slots_str, const std::string &node_id
// 3. Update the map of slots to nodes.
// remember: The atomicity of the process is based on
// the transactionality of ClearKeysOfSlot().
for (const auto &slot_range : slots) {
int s_start = slot_range.first, s_end = slot_range.second;
for (auto [s_start, s_end] : slots) {
for (int slot = s_start; slot <= s_end; slot++) {
std::shared_ptr<ClusterNode> old_node = slots_nodes_[slot];
if (old_node != nullptr) {
Expand Down Expand Up @@ -660,15 +659,14 @@ Status Cluster::parseSlotRanges(const std::string &slots_str, std::vector<std::p
}

auto valid_range = NumericRange<int>{0, kClusterSlots - 1};
// Parse all slots(include slot ranges)
// Parse all slots (include slot ranges)
for (auto &slot_range : slot_ranges) {
if (slot_range.find('-') == std::string::npos) {
auto parse_result = ParseInt<int>(slot_range, valid_range, 10);
if (!parse_result) {
return {Status::NotOK, errInvalidSlotID};
}
int slot_start = *parse_result;
slots.emplace_back(std::make_pair(slot_start, slot_start));
slots.emplace_back(*parse_result, *parse_result);
continue;
}

Expand All @@ -690,9 +688,7 @@ Status Cluster::parseSlotRanges(const std::string &slots_str, std::vector<std::p
"Invalid slot range: {}. The slot range `int1-int2` needs to satisfy the condition (int1 <= int2).",
slot_range)};
}
int slot_start = *parse_start;
int slot_end = *parse_end;
slots.emplace_back(std::make_pair(slot_start, slot_end));
slots.emplace_back(*parse_start, *parse_end);
}

return Status::OK();
Expand Down
4 changes: 2 additions & 2 deletions src/cluster/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Cluster {
Status SetClusterNodes(const std::string &nodes_str, int64_t version, bool force);
Status GetClusterNodes(std::string *nodes_str);
Status SetNodeId(const std::string &node_id);
Status SetSlot(const std::string& slots_str, const std::string &node_id, int64_t version);
Status SetSlot(const std::string &slots_str, const std::string &node_id, int64_t version);
Status SetSlotMigrated(int slot, const std::string &ip_port);
Status SetSlotImported(int slot);
Status GetSlotsInfo(std::vector<SlotInfo> *slot_infos);
Expand All @@ -104,7 +104,7 @@ class Cluster {
std::string genNodesInfo();
void updateSlotsInfo();
SlotInfo genSlotNodeInfo(int start, int end, const std::shared_ptr<ClusterNode> &n);
static Status parseSlotRanges(const std::string&slots_str,std::vector<std::pair<int,int>> &slots);
static Status parseSlotRanges(const std::string &slots_str, std::vector<std::pair<int, int>> &slots);
static Status parseClusterNodes(const std::string &nodes_str, ClusterNodes *nodes,
std::unordered_map<int, std::string> *slots_nodes);
Server *svr_;
Expand Down

0 comments on commit 5d48663

Please sign in to comment.