Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/2110#discussion_r68076977
--- Diff:
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/OperatorChain.java
---
@@ -306,8 +306,9 @@ public ChainingOutput(OneInputStreamOperator<T, ?>
operator) {
@Override
public void collect(StreamRecord<T> record) {
try {
- operator.setKeyContextElement1(record);
- operator.processElement(record);
+ StreamRecord<T> shallowCopy =
record.copy(record.getValue());
+ operator.setKeyContextElement1(shallowCopy);
+ operator.processElement(shallowCopy);
--- End diff --
Actually I'm wondering whether the `ChainingOutput` is the right place to
do this copying. Wouldn't it make more sense to do it in the
`BroadcastingOutputCollector`, because only if we have a branching chained data
flow we have to make sure that every down stream operator get his own copy of
the record. For simple chaining it should be correct to reuse the stream record.
So I would adapt the `collect` method of `BroadcastingOutputCollector` the
following way:
```
public void collect(StreamRecord<T> record) {
for (int i = 0; i < outputs.length - 1; i++) {
StreamRecord<T> shallowCopy = record.copy(record.getValue());
outputs[i].collect(shallowCopy);
}
outputs[outputs.length - 1].collect(record);
}
```
---
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 [email protected] or file a JIRA ticket
with INFRA.
---