Github user dawidwys commented on a diff in the pull request:
https://github.com/apache/flink/pull/3963#discussion_r118050667
--- Diff:
flink-libraries/flink-cep-scala/src/main/scala/org/apache/flink/cep/scala/PatternStream.scala
---
@@ -296,25 +294,94 @@ class PatternStream[T](jPatternStream:
JPatternStream[T]) {
* timeout events wrapped in a [[Either]] type.
*/
def flatSelect[L: TypeInformation, R: TypeInformation](
- patternFlatTimeoutFunction: (mutable.Map[String, JList[T]], Long,
Collector[L]) => Unit) (
- patternFlatSelectFunction: (mutable.Map[String, JList[T]],
Collector[R]) => Unit)
+ patternFlatTimeoutFunction: (Map[String, Iterable[T]], Long,
Collector[L]) => Unit) (
+ patternFlatSelectFunction: (Map[String, Iterable[T]], Collector[R])
=> Unit)
: DataStream[Either[L, R]] = {
val cleanSelectFun = cleanClosure(patternFlatSelectFunction)
val cleanTimeoutFun = cleanClosure(patternFlatTimeoutFunction)
val patternFlatSelectFun = new PatternFlatSelectFunction[T, R] {
- override def flatSelect(pattern: JMap[String, JList[T]], out:
Collector[R]): Unit = {
- cleanSelectFun(pattern.asScala, out)
+ override def flatSelect(pattern: JMap[String, JList[T]], out:
Collector[R]): Unit =
+ cleanSelectFun(mapToScala(pattern), out)
+ }
+
+ val patternFlatTimeoutFun = new PatternFlatTimeoutFunction[T, L] {
+ override def timeout(
+ pattern: JMap[String, JList[T]],
+ timeoutTimestamp: Long, out: Collector[L])
+ : Unit = {
+ cleanTimeoutFun(mapToScala(pattern), timeoutTimestamp, out)
}
}
--- End diff --
This is the scala way of applying `flatFunction`. We also provide both of
those alternatives for e.g. `DataStream#flatMap`.
---
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.
---