wu-sheng commented on a change in pull request #6066:
URL: https://github.com/apache/skywalking/pull/6066#discussion_r548976656



##########
File path: 
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
##########
@@ -209,18 +211,11 @@ private void loadFromStorage(List<Metrics> metrics) 
throws IOException {
             context.clear();
         }
 
-        List<String> notInCacheIds = new ArrayList<>();
-        for (Metrics metric : metrics) {
-            if (!context.containsKey(metric)) {
-                notInCacheIds.add(metric.id());
-            }
-        }
-
-        if (notInCacheIds.size() > 0) {
-            List<Metrics> metricsList = metricsDAO.multiGet(model, 
notInCacheIds);
-            for (Metrics metric : metricsList) {
-                context.put(metric, metric);
-            }
+        List<Metrics> noInCacheMetrics = metrics.stream()
+                                                .filter(m -> 
!context.containsKey(m))
+                                                .collect(Collectors.toList());
+        if (!noInCacheMetrics.isEmpty()) {
+            metricsDAO.multiGet(model, noInCacheMetrics).forEach(m -> 
context.put(m, m));

Review comment:
       Look like the codes back to double loops?




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


Reply via email to