Github user fhueske commented on the issue:

    https://github.com/apache/flink/pull/3585
  
    I think you can do exactly the same with both approaches, but a single 
timer has the benefit of reduced overhead. If you have records `(id, ts)`
    
    ```
    (1, 1), (2, 2), (3, 5), WM 4, (4, 7), (5, 10), (6, 6), WM 8
    ```
    
    Using timestamp timers would result in
    ```
    processElement((1,1))
    processElement((2,2))
    processElement((3,5))
    onTimer(1)
    onTimer(2)
    processElement((4,7))
    processElement((5,10))
    processElement((6,6))
    onTimer(5)
    onTimer(6)
    onTimer(7)
    ```
    
    Where `onTimer(1)` and `onTimer(2)` (or `onTimer(5)`, `onTimer(6)`, and 
`onTimer(7)`) could share the access to the `MapState`
    
    Using a single watermark timer we would have
    ```
    processElement((1,1))
    processElement((2,2))
    processElement((3,5))
    onTimer(_) // emit all records with ts < current watermark (= 4): (1,1) and 
(2,2)
    processElement((4,7))
    processElement((5,10))
    processElement((6,6))
    onTimer(_) // emit all records with ts < current watermark (= 8): (3,5), 
(6,6), (4,7)
    ```
    
    Since we can check against the current watermark also in this case, we can 
avoid to emit records too early. It should also be possible integrate an 
allowed lateness parameter into this approach in the future. 
    The benefit of processing multiple rows (for different timestamps) by a 
single `onTimer()` call is that we can iterate the list of `Long` keys just 
once.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to