flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GJL <...@git.apache.org>
Subject [GitHub] flink pull request #5236: [FLINK-8322] support getting number of existing ti...
Date Wed, 03 Jan 2018 16:11:33 GMT
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`
      


---

Mime
View raw message