You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2020/10/20 21:49:50 UTC

[GitHub] [accumulo] ctubbsii commented on a change in pull request #1744: Use newer map methods in TabletGroupWatcher

ctubbsii commented on a change in pull request #1744:
URL: https://github.com/apache/accumulo/pull/1744#discussion_r508861282



##########
File path: server/manager/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
##########
@@ -214,14 +214,8 @@ public void run() {
           TableId tableId = tls.extent.tableId();
           TableConfiguration tableConf = this.master.getContext().getTableConfiguration(tableId);
 
-          MergeStats mergeStats = mergeStatsCache.get(tableId);
-          if (mergeStats == null) {
-            mergeStats = currentMerges.get(tableId);
-            if (mergeStats == null) {
-              mergeStats = new MergeStats(new MergeInfo());
-            }
-            mergeStatsCache.put(tableId, mergeStats);
-          }
+          MergeStats mergeStats = mergeStatsCache.computeIfAbsent(tableId,
+              k -> currentMerges.getOrDefault(k, new MergeStats(new MergeInfo())));

Review comment:
       This always constructs the the 'default' `new MergeStats(new MergeInfo()))`, even if already exists in `currentMerges`. To avoid that, you could use the following instead of `getOrDefault`:
   
   ```suggestion
                 k -> {
                   var mergeStats = currentMerges.get(k);
                   return mergeStats != null ? mergeStats : new MergeStats(new MergeInfo());
                 });
   ```




----------------------------------------------------------------
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.

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