Skip to content

Commit ec4b405

Browse files
#187 Documents state migration (#188)
* Documents state migration * Update README.md Co-authored-by: Arnaud <[email protected]> * Validates snippets with mdoc * Improves readiness --------- Co-authored-by: novakov-alexey <[email protected]>
1 parent 3f43f86 commit ec4b405

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ This project is a community-maintained fork of official Apache Flink Scala API,
1313
`flink-scala-api` uses a different package name for all api-related classes like `DataStream`, so you can do
1414
gradual migration of a big project and use both upstream and this versions of scala API in the same project.
1515

16+
### API
17+
1618
The actual migration should be straightforward and simple, replace old import to the new ones:
1719
```scala
1820
// original api import
@@ -24,6 +26,27 @@ import org.apache.flinkx.api._
2426
import org.apache.flinkx.api.serializers._
2527
```
2628

29+
### State
30+
31+
Ensure to replace state descriptor constructors using `Class[T]` param with constructors using `TypeInformation[T]` or `TypeSerializer[T]` param:
32+
```scala mdoc
33+
import org.apache.flink.api.common.state.ValueStateDescriptor
34+
import org.apache.flink.api.common.typeinfo.TypeInformation
35+
36+
// state using Kryo
37+
val eventStateDescriptor = new ValueStateDescriptor[Option[String]]("event",
38+
classOf[Option[String]])
39+
```
40+
```scala mdoc:reset-object
41+
import org.apache.flinkx.api.serializers._
42+
import org.apache.flink.api.common.state.ValueStateDescriptor
43+
import org.apache.flink.api.common.typeinfo.TypeInformation
44+
45+
// state using flink-scala-api
46+
val eventStateDescriptor = new ValueStateDescriptor[Option[String]]("event",
47+
implicitly[TypeInformation[Option[String]]])
48+
```
49+
2750
## Usage
2851

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

0 commit comments

Comments
 (0)