sashidhar commented on a change in pull request #7764: #7316 Use 
Map.putIfAbsent() instead of containsKey() + put()
URL: https://github.com/apache/incubator-druid/pull/7764#discussion_r288209148
 
 

 ##########
 File path: 
indexing-service/src/main/java/org/apache/druid/indexing/appenderator/ActionBasedUsedSegmentChecker.java
 ##########
 @@ -50,9 +50,7 @@ public ActionBasedUsedSegmentChecker(TaskActionClient 
taskActionClient)
     // Group by dataSource
     final Map<String, Set<SegmentIdWithShardSpec>> identifiersByDataSource = 
new TreeMap<>();
     for (SegmentIdWithShardSpec identifier : identifiers) {
-      if (!identifiersByDataSource.containsKey(identifier.getDataSource())) {
-        identifiersByDataSource.put(identifier.getDataSource(), new 
HashSet<>());
-      }
+      identifiersByDataSource.putIfAbsent(identifier.getDataSource(), new 
HashSet<>());
 
 Review comment:
   Done.

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


With regards,
Apache Git Services

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

Reply via email to