| 89 | } |
| 90 | |
| 91 | const IpAddr* HashRing::GetNode(uint32_t hash_value) const { |
| 92 | if (hash_to_node_.empty()) return nullptr; |
| 93 | // Find the element that immediately follows this hash value |
| 94 | auto next_elem = hash_to_node_.lower_bound(hash_value); |
| 95 | if (next_elem == hash_to_node_.end()) { |
| 96 | // This is larger than the largest elem. Return the smallest elem |
| 97 | next_elem = hash_to_node_.begin(); |
| 98 | } |
| 99 | NodeIterator node_it = next_elem->second; |
| 100 | return &(*node_it); |
| 101 | } |
| 102 | |
| 103 | void HashRing::GetDistributionMap( |
| 104 | map<IpAddr, uint64_t>* distribution_map) const { |