MCPcopy Create free account
hub / github.com/apache/impala / CompareNetworkAddressPB

Function CompareNetworkAddressPB

be/src/util/network-util.h:116–132  ·  view source on GitHub ↗

Compare function for two NetworkAddressPB. The order is decided first by hostname, then by port, then by uds address.

Source from the content-addressed store, hash-verified

114/// Compare function for two NetworkAddressPB.
115/// The order is decided first by hostname, then by port, then by uds address.
116inline int CompareNetworkAddressPB(
117 const NetworkAddressPB& lhs, const NetworkAddressPB& rhs) {
118 int comp = lhs.hostname().compare(rhs.hostname());
119 if (comp == 0) comp = lhs.port() - rhs.port();
120 if (comp == 0) {
121 if (lhs.has_uds_address()) {
122 if (rhs.has_uds_address()) {
123 comp = lhs.uds_address().compare(rhs.uds_address());
124 } else {
125 comp = 1; // lhs preceed rhs
126 }
127 } else if (rhs.has_uds_address()) {
128 comp = -1; // rhs preceed lhs
129 }
130 }
131 return comp;
132}
133
134/// Return true if two NetworkAddressPB are match.
135inline bool KrpcAddressEqual(const NetworkAddressPB& lhs, const NetworkAddressPB& rhs) {

Callers 4

KrpcAddressEqualFunction · 0.85
TESTFunction · 0.85
CheckTranslationFunction · 0.85

Calls 3

hostnameMethod · 0.80
compareMethod · 0.65
portMethod · 0.45

Tested by 2

TESTFunction · 0.68
CheckTranslationFunction · 0.68