You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by kl0u <gi...@git.apache.org> on 2017/05/23 13:10:40 UTC

[GitHub] flink pull request #3963: [FLINK-6658][cep] Use scala Collections in scala C...

Github user kl0u commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3963#discussion_r117985885
  
    --- Diff: flink-libraries/flink-cep-scala/src/main/scala/org/apache/flink/cep/scala/package.scala ---
    @@ -40,7 +44,11 @@ package object scala {
     
       private[flink] def cleanClosure[F <: AnyRef](f: F, checkSerializable: Boolean = true): F = {
         ClosureCleaner.clean(f, checkSerializable)
    -    return f
    +    f
    +  }
    +
    +  private[flink] def mapToScala[T](map: JMap[String, JList[T]]): Map[String, Iterable[T]] = {
    +    map.asScala.mapValues(_.asScala.toIterable).toMap
    --- End diff --
    
    Why not getting rid of the last `.toMap` and return a `collection.Map`? This will avoid an iteration over the elements of the `JMap` which is important given that this method will be invoked at every incoming element. From the rest, I think we are ok as the `asScala`s are just wrappers and the `.mapValues` are lazily evaluated.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---