Reputation: 6332
As of the broadcast stream and broad caset state, I have two questions.
public abstract <K, V> BroadcastState<K, V> getBroadcastState(final MapStateDescriptor<K, V> stateDescriptor);
def broadcast(broadcastStateDescriptors: MapStateDescriptor[_, _]*): BroadcastStream[T] = { if (broadcastStateDescriptors == null) { throw new NullPointerException("State Descriptors must not be null.") } javaStream.broadcast(broadcastStateDescriptors: _*) }
I would ask what the arguments broadcastStateDescriptors
used for? Why should I have to provide it so early when broadcasting the stream? I think I can create the descriptor and get the broadcast state when I need it in KeyedBroadcastProcessFunction#processBroadcastElement where the operator receives the broadcasted element and update the broadcast state.
Upvotes: 0
Views: 1181
Reputation: 43409
MapState
is the kind of state (and the only kind of state) that Flink supports for broadcasting. And since broadcast state is always MapState
, a MapStateDescriptor
is what is used to work with it.
Flink needs to know how to serialize the data that is being broadcast; broadcastStateDescriptors
is used by DataStream#broadcast
for this purpose.
Upvotes: 2