flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dawidwys <...@git.apache.org>
Subject [GitHub] flink pull request #3644: [FLINK-6205] [FLINK-6069] [cep] Correct watermark/...
Date Wed, 29 Mar 2017 17:51:31 GMT
Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3644#discussion_r108741567
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/operator/AbstractKeyedCEPPatternOperator.java
---
    @@ -196,19 +213,45 @@ public void processElement(StreamRecord<IN> element) throws
Exception {
     			updateNFA(nfa);
     
     		} else {
    -			getInternalWatermarkCallbackService().registerKeyForWatermarkCallback(keySelector.getKey(element.getValue()));
     
    -			PriorityQueue<StreamRecord<IN>> priorityQueue = getPriorityQueue();
    +			// In event-time processing we assume correctness of the watermark.
    +			// Events with timestamp smaller than the last seen watermark are considered late.
    +			// Late events are put in a dedicated side output, if the user has specified one.
    +
    +			if (element.getTimestamp() >= lastWatermark) {
     
    -			// event time processing
    -			// we have to buffer the elements until we receive the proper watermark
    -			if (getExecutionConfig().isObjectReuseEnabled()) {
    -				// copy the StreamRecord so that it cannot be changed
    -				priorityQueue.offer(new StreamRecord<IN>(inputSerializer.copy(element.getValue()),
element.getTimestamp()));
    +				// we have an event with a valid timestamp, so
    +				// we buffer it until we receive the proper watermark.
    +
    +				getInternalWatermarkCallbackService().registerKeyForWatermarkCallback(keySelector.getKey(element.getValue()));
    +
    +				PriorityQueue<StreamRecord<IN>> priorityQueue = getPriorityQueue();
    +				if (getExecutionConfig().isObjectReuseEnabled()) {
    +					// copy the StreamRecord so that it cannot be changed
    +					priorityQueue.offer(new StreamRecord<>(inputSerializer.copy(element.getValue()),
element.getTimestamp()));
    +				} else {
    +					priorityQueue.offer(element);
    +				}
    +				updatePriorityQueue(priorityQueue);
     			} else {
    -				priorityQueue.offer(element);
    +				sideOutputLateElement(element);
     			}
    -			updatePriorityQueue(priorityQueue);
    +		}
    +	}
    +
    +	private void updateLastSeenWatermark(Watermark watermark) {
    +		this.lastWatermark = watermark.getTimestamp();
    --- End diff --
    
    Shouldn't the lastWatermark be stored in a StateBackend? How will it behave after restoring
from a checkpoint?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message