Skip to content

Commit 3e5d6a3

Browse files
author
Cai Yufei (INST/ECS1)
committed
StatisticsActor: simplify Map usage
Signed-off-by: Cai Yufei (INST/ECS1) <[email protected]>
1 parent c312c12 commit 3e5d6a3

File tree

1 file changed

+4
-9
lines changed
  • services/gateway/proxy/src/main/java/org/eclipse/ditto/services/gateway/proxy/actors

1 file changed

+4
-9
lines changed

services/gateway/proxy/src/main/java/org/eclipse/ditto/services/gateway/proxy/actors/StatisticsActor.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,10 @@ private void becomeStatisticsDetailsAwaiting(final Consumer<StatisticsDetails> s
282282
retrieveStatisticsDetailsResponse.getStatisticsDetails().getValue(shardRegion)
283283
.map(JsonValue::asObject)
284284
.map(JsonObject::stream)
285-
.ifPresent(namespaceEntries -> namespaceEntries.forEach(field -> {
286-
if (shardStatistics.hotnessMap.containsKey(field.getKeyName())) {
287-
shardStatistics.hotnessMap.put(field.getKeyName(),
288-
shardStatistics.hotnessMap.get(field.getKeyName()) +
289-
field.getValue().asLong());
290-
} else {
291-
shardStatistics.hotnessMap.put(field.getKeyName(), field.getValue().asLong());
292-
}
293-
}));
285+
.ifPresent(namespaceEntries -> namespaceEntries.forEach(field ->
286+
shardStatistics.hotnessMap
287+
.merge(field.getKeyName(), field.getValue().asLong(), Long::sum)
288+
));
294289
}
295290
})
296291
.match(AskTimeoutException.class, askTimeout -> {

0 commit comments

Comments
 (0)