UK
- Type of the keys in the state.UV
- Type of the values in the state.@Experimental 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 |
---|---|
StateFuture<Boolean> |
asyncContains(UK key)
Returns whether there exists the given mapping asynchronously.
|
StateFuture<StateIterator<Map.Entry<UK,UV>>> |
asyncEntries()
Returns the current iterator for all the mappings of this state asynchronously.
|
StateFuture<UV> |
asyncGet(UK key)
Returns the current value associated with the given key asynchronously.
|
StateFuture<Boolean> |
asyncIsEmpty()
Returns whether this state contains no key-value mappings asynchronously.
|
StateFuture<StateIterator<UK>> |
asyncKeys()
Returns the current iterator for all the keys of this state asynchronously.
|
StateFuture<Void> |
asyncPut(UK key,
UV value)
Update the current value associated with the given key asynchronously.
|
StateFuture<Void> |
asyncPutAll(Map<UK,UV> map)
Update all of the mappings from the given map into the state asynchronously.
|
StateFuture<Void> |
asyncRemove(UK key)
Delete the mapping of the given key from the state asynchronously.
|
StateFuture<StateIterator<UV>> |
asyncValues()
Returns the current iterator for all the values of this state asynchronously.
|
asyncClear
StateFuture<UV> asyncGet(UK key)
StateFuture
that will return value corresponding to the current input.
When no corresponding value for this key, the future will return null
.StateFuture<Void> asyncPut(UK key, UV value)
null
value is
provided, the state for the given key will be removed.key
- The key that will be updated.value
- The new value for the key.StateFuture
that will trigger the callback when update finishes.StateFuture<Void> asyncPutAll(Map<UK,UV> map)
null
value is
provided within the map, the state for the corresponding key will be removed.
If an empty map is passed in, the state value remains unchanged.
Null map pointer is not allowed.
map
- The mappings to be stored in this state.StateFuture
that will trigger the callback when update finishes.StateFuture<Void> asyncRemove(UK key)
key
- The key of the mapping.StateFuture
that will trigger the callback when update finishes.StateFuture<Boolean> asyncContains(UK key)
key
- The key of the mapping.StateFuture
that will return true if there exists a mapping whose key
equals to the given key.StateFuture<StateIterator<Map.Entry<UK,UV>>> asyncEntries()
StateFuture
that will return mapping iterator corresponding to the
current input.StateFuture<StateIterator<UK>> asyncKeys()
StateFuture
that will return key iterator corresponding to the current
input.StateFuture<StateIterator<UV>> asyncValues()
StateFuture
that will return value iterator corresponding to the current
input.StateFuture<Boolean> asyncIsEmpty()
StateFuture
that will return true if there is no key-value mapping,
otherwise false.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.