Skip to content

Commit

Permalink
add more information on kryo trap
Browse files Browse the repository at this point in the history
  • Loading branch information
novakov-alexey authored Dec 30, 2024
1 parent 29a2ed9 commit 57741c3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import org.apache.flink.api.common.typeinfo.TypeInformation
val eventStateDescriptor = new ValueStateDescriptor[Option[String]]("event",
classOf[Option[String]])
```
Although `flink-scala-api` does fallback to Kryo silently, above code example will eventually use Kryo. This may happen when old flink-scala-api is already disabled, but this Flink Scala API is not yet properly used: no serializers are used or imported from `org.apache.flinkx.api.serializers._`.
Below code example is the right way to use Scala serializers coming from this library: it completely prevents Kryo from being used. Even if `implicitly` cannot find an appropriate TypeInformation instance for your type `T`, it will fail in compile time.

```scala mdoc:reset-object
import org.apache.flinkx.api.serializers._
import org.apache.flink.api.common.state.ValueStateDescriptor
Expand All @@ -47,6 +50,8 @@ val eventStateDescriptor = new ValueStateDescriptor[Option[String]]("event",
implicitly[TypeInformation[Option[String]]])
```

See more on Java types serilization here: [java-types](README.md#java-types)

## Usage

`flink-scala-api` is released to Maven-central for 2.13 and 3. For SBT, add this snippet to `build.sbt`:
Expand Down

0 comments on commit 57741c3

Please sign in to comment.