Interface MapState<UK,UV>
-
- Type Parameters:
UK
- Type of the keys in the state.UV
- Type of the values in the state.
- All Superinterfaces:
State
- All Known Subinterfaces:
InternalMapState<K,N,UK,UV>
- All Known Implementing Classes:
ImmutableMapState
@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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
get
UV get(UK key) throws Exception
Returns the current value associated with the given key.- Parameters:
key
- The key of the mapping- Returns:
- The value of the mapping with the given key
- Throws:
Exception
- Thrown if the system cannot access the state.
-
put
void put(UK key, UV value) throws Exception
Associates a new value with the given key.- Parameters:
key
- The key of the mappingvalue
- The new value of the mapping- Throws:
Exception
- Thrown if the system cannot access the state.
-
putAll
void putAll(Map<UK,UV> map) throws Exception
Copies all of the mappings from the given map into the state.- Parameters:
map
- The mappings to be stored in this state- Throws:
Exception
- Thrown if the system cannot access the state.
-
remove
void remove(UK key) throws Exception
Deletes the mapping of the given key.- Parameters:
key
- The key of the mapping- Throws:
Exception
- Thrown if the system cannot access the state.
-
contains
boolean contains(UK key) throws Exception
Returns whether there exists the given mapping.- Parameters:
key
- The key of the mapping- Returns:
- True if there exists a mapping whose key equals to the given key
- Throws:
Exception
- Thrown if the system cannot access the state.
-
entries
Iterable<Map.Entry<UK,UV>> entries() throws Exception
Returns all the mappings in the state.- Returns:
- An iterable view of all the key-value pairs in the state.
- Throws:
Exception
- Thrown if the system cannot access the state.
-
keys
Iterable<UK> keys() throws Exception
Returns all the keys in the state.- Returns:
- An iterable view of all the keys in the state.
- Throws:
Exception
- Thrown if the system cannot access the state.
-
values
Iterable<UV> values() throws Exception
Returns all the values in the state.- Returns:
- An iterable view of all the values in the state.
- Throws:
Exception
- Thrown if the system cannot access the state.
-
iterator
Iterator<Map.Entry<UK,UV>> iterator() throws Exception
Iterates over all the mappings in the state.- Returns:
- An iterator over all the mappings in the state
- Throws:
Exception
- Thrown if the system cannot access the state.
-
-