lizhimins commented on code in PR #6783:
URL: https://github.com/apache/rocketmq/pull/6783#discussion_r1247358914


##########
store/src/main/java/org/apache/rocketmq/store/queue/ConsumeQueueStore.java:
##########
@@ -314,50 +315,42 @@ public ConsumeQueueInterface 
findOrCreateConsumeQueue(String topic, int queueId)
         return doFindOrCreateConsumeQueue(topic, queueId);
     }
 
+    /**
+     * Finds or creates a ConsumeQueueInterface for the given topic and queue 
ID.
+     *
+     * @param topic   The topic for which the ConsumeQueueInterface.
+     * @param queueId The ID of the queue for which the ConsumeQueueInterface.
+     * @return The found or newly created ConsumeQueueInterface.
+     */
     private ConsumeQueueInterface doFindOrCreateConsumeQueue(String topic, int 
queueId) {
-        ConcurrentMap<Integer, ConsumeQueueInterface> map = 
consumeQueueTable.get(topic);
-        if (null == map) {
-            ConcurrentMap<Integer, ConsumeQueueInterface> newMap = new 
ConcurrentHashMap<>(128);
-            ConcurrentMap<Integer, ConsumeQueueInterface> oldMap = 
consumeQueueTable.putIfAbsent(topic, newMap);
-            if (oldMap != null) {
-                map = oldMap;
-            } else {
-                map = newMap;
-            }
-        }
 
+        ConcurrentMap<Integer, ConsumeQueueInterface> map = 
ConcurrentHashMapUtils.computeIfAbsent(consumeQueueTable, topic, k -> new 
ConcurrentHashMap<>(128));

Review Comment:
   jdk8 的 computeIfAbsent 性能有问题



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

Reply via email to