acelyc111 commented on code in PR #1825: URL: https://github.com/apache/incubator-pegasus/pull/1825#discussion_r1445687533
########## src/runtime/test/host_port_test.cpp: ########## @@ -100,6 +102,9 @@ TEST(host_port_test, operators) std::string hp_str2 = "pegasus:8080"; ASSERT_FALSE(hp4.from_string(hp_str2)); ASSERT_TRUE(hp4.is_invalid()); + + host_port hp5("localhost", 8081); + ASSERT_TRUE(hp < hp5); Review Comment: ```suggestion ASSERT_LT(hp, hp5); ``` ########## src/utils/fixed_size_buffer_pool.h: ########## @@ -28,8 +28,8 @@ /// /// A simple buffer pool designed for efficiently formatting -/// frequently used types (like gpid, rpc_address) into string, -/// without dynamic memory allocation. +/// frequently used types (like gpid, rpc_address, host_port) +/// into string, without dynamic memory allocation. Review Comment: ```suggestion /// into string, without dynamic memory allocation. ``` ########## src/runtime/rpc/rpc_host_port.h: ########## @@ -118,6 +130,22 @@ inline bool operator==(const host_port &hp1, const host_port &hp2) inline bool operator!=(const host_port &hp1, const host_port &hp2) { return !(hp1 == hp2); } +inline bool operator<(const host_port &hp1, const host_port &hp2) +{ + if (hp1.type() != hp2.type()) { + return hp1.type() < hp2.type(); + } + + switch (hp1.type()) { + case HOST_TYPE_IPV4: + return hp1.host() < hp2.host() || (hp1.host() == hp2.host() && hp1.port() < hp2.port()); + case HOST_TYPE_GROUP: + return reinterpret_cast<uint64_t>(hp1.group_host_port().get()) < + reinterpret_cast<uint64_t>(hp2.group_host_port().get()); Review Comment: Can be replaced by this? ```suggestion return hp1.group_host_port().get() < hp2.group_host_port().get(); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@pegasus.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pegasus.apache.org For additional commands, e-mail: dev-h...@pegasus.apache.org