wu-sheng commented on a change in pull request #6066:
URL: https://github.com/apache/skywalking/pull/6066#discussion_r548963228
##########
File path:
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
##########
@@ -209,18 +211,9 @@ 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);
- }
+ Stream<Metrics> stream = metrics.stream().filter(m ->
!context.containsKey(m));
+ if (stream.count() > 0) {
Review comment:
I have a feeling, `stream#count` === a whole loop. Could you confirm?
----------------------------------------------------------------
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]