pyflink.datastream.state.BroadcastState#
- 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.Methods
clear
()Removes the value mapped under the current key.
contains
(key)Returns whether there exists the given mapping.
get
(key)Returns the current value associated with the given key.
is_empty
()Returns true if this state contains no key-value mappings, otherwise false.
items
()Returns all the mappings in the state.
keys
()Returns all the keys in the state.
put
(key, value)Associates a new value with the given key.
put_all
(dict_value)Copies all of the mappings from the given map into the state.
remove
(key)Deletes the mapping of the given key.
values
()Returns all the values in the state.