Github user ifesdjeen commented on a diff in the pull request:
https://github.com/apache/cassandra/pull/224#discussion_r197127705
--- Diff:
src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java ---
@@ -102,35 +104,35 @@ protected AbstractReplicationStrategy(String
keyspaceName, TokenMetadata tokenMe
* @param searchPosition the position the natural endpoints are
requested for
* @return a copy of the natural endpoints for the given token
*/
- public ArrayList<InetAddressAndPort> getNaturalEndpoints(RingPosition
searchPosition)
+ public ReplicaList getNaturalReplicas(RingPosition searchPosition)
{
Token searchToken = searchPosition.getToken();
Token keyToken =
TokenMetadata.firstToken(tokenMetadata.sortedTokens(), searchToken);
- ArrayList<InetAddressAndPort> endpoints =
getCachedEndpoints(keyToken);
+ ReplicaList endpoints = getCachedReplicas(keyToken);
if (endpoints == null)
{
TokenMetadata tm = tokenMetadata.cachedOnlyTokenMap();
// if our cache got invalidated, it's possible there is a new
token to account for too
keyToken = TokenMetadata.firstToken(tm.sortedTokens(),
searchToken);
- endpoints = new
ArrayList<InetAddressAndPort>(calculateNaturalEndpoints(searchToken, tm));
- cachedEndpoints.put(keyToken, endpoints);
+ endpoints = calculateNaturalReplicas(searchToken, tm);
+ cachedReplicas.put(keyToken, endpoints);
--- End diff --
It seems that we're only putting here, so here we can have an immutable
collection already, which might spare us a need for copy in `getCachedReplicas`
consumers.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]