rpuch commented on code in PR #5612:
URL: https://github.com/apache/ignite-3/pull/5612#discussion_r2039727217


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -3069,13 +3068,15 @@ public void 
setStreamerReceiverRunner(StreamerReceiverRunner runner) {
     }
 
     public Set<TableImpl> zoneTables(int zoneId) {
-        return tablesPerZone.computeIfAbsent(zoneId, id -> new HashSet<>());
+        // Using a concurrent set as a value as it can be read (and iterated 
over) without any synchronization by external callers.
+        return tablesPerZone.computeIfAbsent(zoneId, id -> 
ConcurrentHashMap.newKeySet());

Review Comment:
   If the zone has no tables, 10 calls with `getOrDefault()` will produce 10 
instances of an empty set, while for `computeIfAbsent()` it will be just 1 
instance. On the other hand, if we have a million empty zones, `getOrAbsent()` 
will hog less memory.
   
   Both cases seem to be almost identical in real life. Does `getOrDefault()` 
have any significant advantages?



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to