Github user GJL commented on a diff in the pull request:
https://github.com/apache/flink/pull/5236#discussion_r159461777
--- Diff:
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/HeapInternalTimerService.java
---
@@ -442,23 +458,15 @@ public int numEventTimeTimers() {
}
public int numProcessingTimeTimers(N namespace) {
- int count = 0;
- for (InternalTimer<K, N> timer : processingTimeTimersQueue) {
- if (timer.getNamespace().equals(namespace)) {
- count++;
- }
- }
- return count;
+ return
processingTimeNumberTimers.column(namespace).keySet().stream()
--- End diff --
How about something like:
```
public int numProcessingTimeTimers(N namespace) {
return processingTimeNumberTimers.column(namespace)
.entrySet()
.stream()
.mapToInt(Map.Entry::getValue)
.sum();
}
```
It avoids the additional key lookup in `mapToInt`
---