UK
- Type of the keys in the state.UV
- Type of the values in the state.@PublicEvolving public interface MapState<UK,UV> extends State
State
interface for partitioned key-value state. The key-value pair can be added, updated
and retrieved.
The state is accessed and modified by user functions, and checkpointed consistently by the system as part of the distributed snapshots.
The state is only accessible by functions applied on a KeyedStream
. The key is
automatically supplied by the system, so the function always sees the value mapped to the key of
the current element. That way, the system can handle stream and state partitioning consistently
together.
Modifier and Type | Method and Description |
---|---|
boolean |
contains(UK key)
Returns whether there exists the given mapping.
|
Iterable<Map.Entry<UK,UV>> |
entries()
Returns all the mappings in the state.
|
UV |
get(UK key)
Returns the current value associated with the given key.
|
boolean |
isEmpty()
Returns true if this state contains no key-value mappings, otherwise false.
|
Iterator<Map.Entry<UK,UV>> |
iterator()
Iterates over all the mappings in the state.
|
Iterable<UK> |
keys()
Returns all the keys in the state.
|
void |
put(UK key,
UV value)
Associates a new value with the given key.
|
void |
putAll(Map<UK,UV> map)
Copies all of the mappings from the given map into the state.
|
void |
remove(UK key)
Deletes the mapping of the given key.
|
Iterable<UV> |
values()
Returns all the values in the state.
|
UV get(UK key) throws Exception
key
- The key of the mappingException
- Thrown if the system cannot access the state.void put(UK key, UV 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<UK,UV> map) throws Exception
map
- The mappings to be stored in this stateException
- Thrown if the system cannot access the state.void remove(UK key) throws Exception
key
- The key of the mappingException
- Thrown if the system cannot access the state.boolean contains(UK key) throws Exception
key
- The key of the mappingException
- Thrown if the system cannot access the state.Iterable<Map.Entry<UK,UV>> entries() throws Exception
Exception
- Thrown if the system cannot access the state.Iterable<UK> keys() throws Exception
Exception
- Thrown if the system cannot access the state.Iterable<UV> values() throws Exception
Exception
- Thrown if the system cannot access the state.Iterator<Map.Entry<UK,UV>> iterator() throws Exception
Exception
- Thrown if the system cannot access the state.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.