pnowojski commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1494192141
##########
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:
We can not call `getProcessingTimeService().getCurrentProcessingTime()` per
every record, that's a too costly operation.
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.
A couple of extra complications that I see are:
- This operator registers a processing time timer only if periodic
watermarks are enabled (`watermarkInterval > 0`). The code would have to be
adapted to register and fire timers also if `watermarkInterval == 0 &&
idleTimeout > 0`.
- 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`.
Or have I missed something?
--
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]