Skip to content

Commit

Permalink
#187 Documents state migration (#188)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
arnaud-daroussin and novakov-alexey authored Dec 20, 2024
1 parent 3f43f86 commit ec4b405
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ This project is a community-maintained fork of official Apache Flink Scala API,
`flink-scala-api` uses a different package name for all api-related classes like `DataStream`, so you can do
gradual migration of a big project and use both upstream and this versions of scala API in the same project.

### API

The actual migration should be straightforward and simple, replace old import to the new ones:
```scala
// original api import
Expand All @@ -24,6 +26,27 @@ import org.apache.flinkx.api._
import org.apache.flinkx.api.serializers._
```

### State

Ensure to replace state descriptor constructors using `Class[T]` param with constructors using `TypeInformation[T]` or `TypeSerializer[T]` param:
```scala mdoc
import org.apache.flink.api.common.state.ValueStateDescriptor
import org.apache.flink.api.common.typeinfo.TypeInformation

// state using Kryo
val eventStateDescriptor = new ValueStateDescriptor[Option[String]]("event",
classOf[Option[String]])
```
```scala mdoc:reset-object
import org.apache.flinkx.api.serializers._
import org.apache.flink.api.common.state.ValueStateDescriptor
import org.apache.flink.api.common.typeinfo.TypeInformation

// state using flink-scala-api
val eventStateDescriptor = new ValueStateDescriptor[Option[String]]("event",
implicitly[TypeInformation[Option[String]]])
```

## 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 ec4b405

Please sign in to comment.