Search code examples
apache-flinkflink-streaming

Can Flink keyed process function have multiple state descriptors?


I'm using Keyed process function to use RocksDB state backend. I want to hold two different states for the same key;

  • State 1 type: ValueState[String]
  • State 2 type: MapState[String, Long]

In this case, i have to create two state descriptors in the same keyed process function. Is that possible in flink?


Solution

  • Yes, you can have as many state descriptors in a keyed process function as you want. Each must have a unique name (scoped to the operator/function).

    See the solution to the Rides and Fares training exercise for an example.