ValueState with pure Java class keeping lists/map vs ListState/MapState, which one is a recommended way?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ValueState with pure Java class keeping lists/map vs ListState/MapState, which one is a recommended way?

Elkhan Dadashov
Hi Flinkers,

Was curious about if there is any performance(memory/speed) difference
between these two options:

in window process functions, when keeping state:

*1) Create a single ValueState<MyClass>, and store state in pure Java
objects*

class MyClass {
   List<OtherClass> listOtherClass;
   Map<String, SomeOtherClass> mapKeyToSomeValue;
}

public class MyProcessFunc
      extends KeyedProcessFunction<String, X, Tuple3<Long, Long, Float>> {
...
   ValueState<MyClass> valueState;
...
}

vs

*2) Create ListState and MapState as 2 Flink state variables:*

public class MyProcessFunc
      extends KeyedProcessFunction<String, X, Tuple3<Long, Long, Float>> {
...
   ListState<OtherClass> listState;
   MapState<String, SomeOtherClass> mapState;
...
}

Which option is a recommended way of storing the states?

Thanks.