1996fanrui commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1495341757
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/wmassigners/WatermarkAssignerOperator.java:
##########
@@ -100,11 +100,14 @@ public void open() throws Exception {
@Override
public void processElement(StreamRecord<RowData> element) throws Exception
{
- if (idleTimeout > 0 && currentStatus.equals(WatermarkStatus.IDLE)) {
- // mark the channel active
- emitWatermarkStatus(WatermarkStatus.ACTIVE);
+ if (idleTimeout > 0) {
+ if (currentStatus.equals(WatermarkStatus.IDLE)) {
+ // mark the channel active
+ emitWatermarkStatus(WatermarkStatus.ACTIVE);
+ }
lastRecordTime =
getProcessingTimeService().getCurrentProcessingTime();
}
Review Comment:
Thanks @pnowojski for this valuable comment!
> We can not call getProcessingTimeService().getCurrentProcessingTime() per
every record, that's a too costly operation.
Good catch, I didn't notice it before.
> I think we could use a trick to count emitted records here, in the
processElement. Then in WatermarkAssignerOperator#onProcessingTime you could
periodically check if the processed elements count has changed and update
lastRecordTime there if it did. That would loose us a little bit of accuracy,
but not much. For example if processing timer is triggered ~5x more frequently
than idleTimeout, the average accuracy lost would be only ~10%, which is
negligible.
The solution make sense to me.
> If both idleTimeout > 0 && watermarkInterval > 0, we might need to somehow
handle two timers frequencies:
> I guess we could register two different ProcessingTimeCallback with two
different frequencies.
> Or we can ignore the problem and if both idleTimeout > 0 &&
watermarkInterval > 0, we could just have a single timer with watermarkInterval
latency. This option is probably simpler, and might be good enough as usually
(almost always?) watermarkInterval << idleTimeout.
In general, `watermarkInterval << idleTimeout`, but it isn't always right.
Users can set them randomly, we cannot ensure how user set them.
A workaround solution is we only register a timer with `min(idleTimeout,
watermarkInterval)` latency.
> For `watermarkInterval == 0 && idleTimeout > 0`.
We can register a timer with `idleTimeout` latency.
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]