flink-extended / flink-scala-api

Flink Scala API is a thin wrapper on top of Flink Java API which support Scala Types for serialisation as well the latest Scala version
Apache License 2.0
62 stars 14 forks source link

Review Java Code #127

Closed novakov-alexey closed 4 months ago

novakov-alexey commented 4 months ago

There are several Java classes in this library: https://github.com/flink-extended/flink-scala-api/tree/master/src/main/java/org/apache/flink/serializer

Investigate whether they can be rewritten in Scala.

novakov-alexey commented 4 months ago

After careful review, I see it makes sense to leave them until some Flink 2.x, where all Scala API is going to be removed from Apache Flink:

  1. src/main/java/org/apache/flink/api/serializer/ScalaCaseClassSerializerSnapshot.java
  2. src/main/java/org/apache/flink/api/serializer/ScalaEitherSerializerSnapshot.java
  3. src/main/java/org/apache/flink/api/serializer/ScalaOptionSerializerSnapshot.java

Currently, it is hard to rewrite all above Java classes as they are using different super constructors to instantiate super class. This is not supported by Scala inherently. In Scala we have to chain all constructors. And in Scala we can only have one super constructor which is defined in the class definition.

It could be possible to get rid one of the constructor, but according to original code comments, one of them is used via Java Reflection. That makes dangerous to remove it.