Skip to content

Commit

Permalink
[FLINK-34371][runtime] Set OutputOnlyAfterEndOfStream on WindowOperat…
Browse files Browse the repository at this point in the history
…or and StreamSortOperator

This closes #24272
  • Loading branch information
Sxnan authored and xintongsong committed Feb 28, 2024
1 parent 5916aa4 commit 94b5f03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@
import org.apache.flink.streaming.api.operators.InternalTimer;
import org.apache.flink.streaming.api.operators.InternalTimerService;
import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
import org.apache.flink.streaming.api.operators.OperatorAttributes;
import org.apache.flink.streaming.api.operators.OperatorAttributesBuilder;
import org.apache.flink.streaming.api.operators.TimestampedCollector;
import org.apache.flink.streaming.api.operators.Triggerable;
import org.apache.flink.streaming.api.windowing.assigners.GlobalWindows;
import org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner;
import org.apache.flink.streaming.api.windowing.assigners.WindowAssigner;
import org.apache.flink.streaming.api.windowing.triggers.Trigger;
Expand Down Expand Up @@ -527,6 +530,16 @@ && isCleanupTime(triggerContext.window, timer.getTimestamp())) {
}
}

@Override
public OperatorAttributes getOperatorAttributes() {
boolean isOutputOnlyAfterEndOfStream =
windowAssigner instanceof GlobalWindows
&& trigger instanceof GlobalWindows.EndOfStreamTrigger;
return new OperatorAttributesBuilder()
.setOutputOnlyAfterEndOfStream(isOutputOnlyAfterEndOfStream)
.build();
}

/**
* Drops all state for the given window and calls {@link Trigger#clear(Window,
* Trigger.TriggerContext)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.apache.flink.runtime.state.StateInitializationContext;
import org.apache.flink.runtime.state.StateSnapshotContext;
import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
import org.apache.flink.streaming.api.operators.OperatorAttributes;
import org.apache.flink.streaming.api.operators.OperatorAttributesBuilder;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.data.binary.BinaryRowData;
Expand Down Expand Up @@ -153,4 +155,9 @@ public void finish() throws Exception {
}
super.finish();
}

@Override
public OperatorAttributes getOperatorAttributes() {
return new OperatorAttributesBuilder().setOutputOnlyAfterEndOfStream(true).build();
}
}

0 comments on commit 94b5f03

Please sign in to comment.