K
- The key type of the elements in the BroadcastState
.V
- The value type of the elements in the BroadcastState
.@PublicEvolving public interface BroadcastState<K,V> extends ReadOnlyBroadcastState<K,V>
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.
Modifier and Type | Method and Description |
---|---|
Iterable<Map.Entry<K,V>> |
entries()
Returns all the mappings in the state.
|
Iterator<Map.Entry<K,V>> |
iterator()
Iterates over all the mappings in the state.
|
void |
put(K key,
V value)
Associates a new value with the given key.
|
void |
putAll(Map<K,V> map)
Copies all of the mappings from the given map into the state.
|
void |
remove(K key)
Deletes the mapping of the given key.
|
contains, get, immutableEntries
void put(K key, V value) throws Exception
key
- The key of the mappingvalue
- The new value of the mappingException
- Thrown if the system cannot access the state.void putAll(Map<K,V> map) throws Exception
map
- The mappings to be stored in this stateException
- Thrown if the system cannot access the state.void remove(K key) throws Exception
key
- The key of the mappingException
- Thrown if the system cannot access the state.Iterator<Map.Entry<K,V>> iterator() throws Exception
Exception
- Thrown if the system cannot access the state.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.