Reputation: 1213
Lets assume that I have a job with max.parallelism=4
and a RichFlatMapFunction
which is working with MapState
. What is the best way to create the MapStateDescriptor
? into the RichFlatMapFunction
which means that for each instance of this class I will have a descriptor, or create a single instance of the descriptor, for example: public static MapStateDescriptor descriptor
in a single class and call it from the RichFlatMapFunction
? Because doing it on this way I will have just one MapStateDescriptor
instead of 4, or did I misunderstood something?
Kind regards!
Upvotes: 2
Views: 363
Reputation: 9245
A few points...
RichFlatMapFunction
sub-tasks can be running in a different JVM on a different server, how would they share a static MapStateDescriptor
?MapStateDescriptor
doesn't store state. It tells Flink how to create the state. In your RichFlatMapFunction
operator's open()
call is where you'll be creating the state using the state descriptor.So net-net is don't bother using a static MapStateDescriptor
, it won't help. Just create your state (as per many examples) in your open()
method.
Upvotes: 2