krummas commented on code in PR #3363:
URL: https://github.com/apache/cassandra/pull/3363#discussion_r1634988357


##########
src/java/org/apache/cassandra/locator/LocalStrategy.java:
##########
@@ -56,16 +59,36 @@ public ReplicationFactor getReplicationFactor()
         return RF;
     }
 
+    private EntireRange getRange(IPartitioner partitioner)
+    {
+        // No need to synchronize here. In the unlikely event of a race, it's
+        // safe and cheap to create duplicates and overwrite in the cache.
+        EntireRange range = perPartitionerRanges.get(partitioner);

Review Comment:
   this block could be: 
   `return perPartitionerRanges.computeIfAbsent(partitioner, EntireRange::new);`



##########
src/java/org/apache/cassandra/locator/LocalStrategy.java:
##########
@@ -33,6 +34,8 @@
 public class LocalStrategy extends SystemStrategy
 {
     private static final ReplicationFactor RF = ReplicationFactor.fullOnly(1);
+    private static Map<IPartitioner, EntireRange> perPartitionerRanges = new 
ConcurrentHashMap<>();

Review Comment:
   I think this should be an IdentityHashMap since we don't have .equals and 
.hashCode on (all) the IPartitioner implementations - better to be explicit 
about what we're caching
   
   it could also be `final`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to