Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use address set
  • Loading branch information
Michael Penick committed Aug 16, 2022
commit 5b35f2dbaa622ea43c31893ce7cb01b40ac5938b
19 changes: 0 additions & 19 deletions src/host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,4 @@ bool remove_host(CopyOnWriteHostVec& hosts, const Address& address);
}}} // namespace datastax::internal::core


namespace std {

#if defined(HASH_IN_TR1) && !defined(_WIN32)
namespace tr1 {
#endif

template <>
struct hash<datastax::internal::core::Host*> {
size_t operator()(const datastax::internal::core::Host* host) const {
return host->address().hash_code();
}
};

#if defined(HASH_IN_TR1) && !defined(_WIN32)
} // namespace tr1
#endif

} // namespace std

#endif
16 changes: 4 additions & 12 deletions src/token_map_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,6 @@ inline bool add_replica(CopyOnWriteHostVec& hosts, const Host::Ptr& host) {
return true;
}

class RawPtrHostSet : public DenseHashSet<Host*> {
public:
RawPtrHostSet() {
set_empty_key(0x0);
set_deleted_key(reinterpret_cast<Host*>(0x1));
}
};

template <class Partitioner>
void ReplicationStrategy<Partitioner>::build_replicas_network_topology(
const TokenHostVec& tokens, const DatacenterMap& datacenters, TokenReplicasVec& result) const {
Expand Down Expand Up @@ -443,7 +435,7 @@ void ReplicationStrategy<Partitioner>::build_replicas_network_topology(
CopyOnWriteHostVec replicas(new HostVec());
replicas->reserve(num_replicas);

RawPtrHostSet replicas_set;
AddressSet replicas_set;
replicas_set.resize(num_replicas);

// Clear datacenter and rack information for the next token
Expand Down Expand Up @@ -487,7 +479,7 @@ void ReplicationStrategy<Partitioner>::build_replicas_network_topology(
// datacenter only then consider hosts in the same rack

if (rack == 0 || racks_observed_this_dc.size() == rack_count_this_dc) {
if (replicas_set.insert(host).second) {
if (replicas_set.insert(host->address()).second) {
replicas->push_back(Host::Ptr(host));
++replica_count_this_dc;
}
Expand All @@ -496,7 +488,7 @@ void ReplicationStrategy<Partitioner>::build_replicas_network_topology(
if (racks_observed_this_dc.count(rack) > 0) {
skipped_endpoints_this_dc.push_back(curr_token_it);
} else {
if (replicas_set.insert(host).second) {
if (replicas_set.insert(host->address()).second) {
replicas->push_back(Host::Ptr(host));
++replica_count_this_dc;
racks_observed_this_dc.insert(rack);
Expand All @@ -507,7 +499,7 @@ void ReplicationStrategy<Partitioner>::build_replicas_network_topology(
if (racks_observed_this_dc.size() == rack_count_this_dc) {
while (!skipped_endpoints_this_dc.empty() &&
replica_count_this_dc < replication_factor) {
if (replicas_set.insert(skipped_endpoints_this_dc.front()->second).second) {
if (replicas_set.insert(skipped_endpoints_this_dc.front()->second->address()).second) {
replicas->push_back(Host::Ptr(skipped_endpoints_this_dc.front()->second));
++replica_count_this_dc;
}
Expand Down