You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/07/23 13:22:26 UTC

[GitHub] [flink] aljoscha commented on a change in pull request #12945: [FLINK-18629] Add type to ConnectedStreams#keyBy

aljoscha commented on a change in pull request #12945:
URL: https://github.com/apache/flink/pull/12945#discussion_r459443786



##########
File path: flink-streaming-scala/src/main/scala/org/apache/flink/streaming/api/scala/ConnectedStreams.scala
##########
@@ -300,19 +300,22 @@ class ConnectedStreams[IN1, IN2](javaStream: JavaCStream[IN1, IN2]) {
    * @param fun2 The second stream's key function
    * @return The key-grouped connected streams
    */
-  def keyBy[K1: TypeInformation, K2: TypeInformation](fun1: IN1 => K1, fun2: IN2 => K2):
+  def keyBy[KEY: TypeInformation](fun1: IN1 => KEY, fun2: IN2 => KEY):
       ConnectedStreams[IN1, IN2] = {
 
-    val keyType1 = implicitly[TypeInformation[K1]]
-    val keyType2 = implicitly[TypeInformation[K2]]
-    
+    val keyType = implicitly[TypeInformation[KEY]]
+
     val cleanFun1 = clean(fun1)
     val cleanFun2 = clean(fun2)
-    
-    val keyExtractor1 = new KeySelectorWithType[IN1, K1](cleanFun1, keyType1)
-    val keyExtractor2 = new KeySelectorWithType[IN2, K2](cleanFun2, keyType2)
-    
-    asScalaStream(javaStream.keyBy(keyExtractor1, keyExtractor2))
+
+    val keyExtractor1 = new KeySelector[IN1, KEY] {

Review comment:
       nit: I like the simplicity of the code but I think stacktraces are harder to parse with anonymous classes thrown in the mix. Just a thought, though.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org