[
https://issues.apache.org/jira/browse/FLINK-8322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16309857#comment-16309857
]
ASF GitHub Bot commented on FLINK-8322:
---------------------------------------
Github user GJL commented on a diff in the pull request:
https://github.com/apache/flink/pull/5236#discussion_r159464428
--- Diff:
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/HeapInternalTimerService.java
---
@@ -475,4 +483,38 @@ public int getLocalKeyGroupRangeStartIdx() {
public Set<InternalTimer<K, N>>[] getProcessingTimeTimersPerKeyGroup() {
return this.processingTimeTimersByKeyGroup;
}
+
+ private void incrementProcessingTimeTimer(K key, N namespace) {
+ incrementTimeTimer(processingTimeNumberTimers, key, namespace);
+ }
+
+ private void incrementEventTimeTimer(K key, N namespace) {
+ incrementTimeTimer(eventTimeNumberTimers, key, namespace);
+ }
+
+ private void incrementTimeTimer(Table<K, N, Integer> table, K key, N
namespace) {
+ if (table.contains(key, namespace)) {
+ table.put(key, namespace, table.get(key, namespace) +
1);
+ } else {
+ table.put(key, namespace, 1);
+ }
+ }
+
+ private void decrementProcessingTimeTimer(K key, N namespace) {
+ decrementTimeTimer(processingTimeNumberTimers, key, namespace);
+ }
+
+ private void decrementEventTimeTimer(K key, N namespace) {
+ decrementTimeTimer(eventTimeNumberTimers, key, namespace);
+ }
+
+ private void decrementTimeTimer(Table<K, N, Integer> table, K key, N
namespace) {
+ if (table.contains(key, namespace)) {
--- End diff --
Can it actually happen that the `(key, namespace)` is not in the table? If
it should not happen, maybe
a `checkState` is better.
> support getting number of existing timers in TimerService
> ---------------------------------------------------------
>
> Key: FLINK-8322
> URL: https://issues.apache.org/jira/browse/FLINK-8322
> Project: Flink
> Issue Type: Improvement
> Components: DataStream API
> Affects Versions: 1.4.0
> Reporter: Bowen Li
> Assignee: Bowen Li
> Fix For: 1.5.0
>
>
> There are pretty common use cases where users want to use timers as scheduled
> threads - e.g. add a timer to wake up x hours later and do something (reap
> old data usually) only if there's no existing timers, basically we only want
> at most 1 timer exists for the key all the time
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)