Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/4320#discussion_r132446724
--- Diff:
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/PatternStream.java
---
@@ -163,14 +251,34 @@
null,
false);
+ final OutputTag<L> outputTag = new
OutputTag<L>("dummy-timeouted", leftTypeInfo);
+
+ final SingleOutputStreamOperator<R> mainStream =
CEPOperatorUtils.createTimeoutPatternStream(
+ inputStream,
+ pattern,
+ clean(patternSelectFunction),
+ rightTypeInfo,
+ outputTag,
+ clean(patternTimeoutFunction));
+
+ final DataStream<L> timeoutedStream =
mainStream.getSideOutput(outputTag);
+
TypeInformation<Either<L, R>> outTypeInfo = new
EitherTypeInfo<>(leftTypeInfo, rightTypeInfo);
- return patternStream.map(
- new PatternSelectTimeoutMapper<>(
-
patternStream.getExecutionEnvironment().clean(patternSelectFunction),
-
patternStream.getExecutionEnvironment().clean(patternTimeoutFunction)
- )
- ).returns(outTypeInfo);
+ return mainStream.connect(timeoutedStream).map(new
CoMapFunction<R, L, Either<L, R>>() {
--- End diff --
I think using an anonymous inner class here can be problematic because it
will capture the `PatternStream` in it's closure, if I'm not mistaken.
---
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.
---