- class BroadcastState(*args, **kwds)[source]#
A type of state that can be created to store the state of a
BroadcastStream. This state assumes that the same elements are sent to all instances of an operator. CAUTION: the user has to guarantee that all task instances store the same elements in this type of state. Each operator instance individually maintains and stores elements in the broadcast state. The fact that the incoming stream is a broadcast one guarantees that all instances see all the elements. Upon recovery or re-scaling, the same state is given to each of the instances. To avoid hotspots, each task reads its previous partition, and if there are more tasks (scale up ), then the new instances read from the old instances in a round-robin fashion. This is why each instance has to guarantee that it stores the same elements as the rest. If not, upon recovery or rescaling you may have unpredictable redistribution of the partitions, thus unpredictable results.
Removes the value mapped under the current key.
Returns whether there exists the given mapping.
Returns the current value associated with the given key.
Returns true if this state contains no key-value mappings, otherwise false.
Returns all the mappings in the state.
Returns all the keys in the state.
Associates a new value with the given key.
Copies all of the mappings from the given map into the state.
Deletes the mapping of the given key.
Returns all the values in the state.