K - type of the key - Please note that the key have a meaningful Object.hashCode() and
Object.equals(Object) implemented.V - type of the value.public final class PersistedTable<K,V>
extends java.lang.Object
PersistedTable is a table (collection of keys and values) registered within StatefulFunctions and is persisted and maintained by the system for fault-tolerance.
Created persisted tables must be registered by using the Persisted annotation. Please
see the class-level Javadoc of StatefulFunction for an example on how to do that.
StatefulFunction| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears all elements in the persisted buffer.
|
java.lang.Iterable<java.util.Map.Entry<K,V>> |
entries()
Gets an
Iterable over all the entries of the persisted table. |
Expiration |
expiration() |
V |
get(K key)
Returns a persisted table's value.
|
java.lang.Iterable<K> |
keys()
Gets an
Iterable over all keys of the persisted table. |
java.lang.Class<K> |
keyType()
Returns the type of the persisted tables keys.
|
java.lang.String |
name()
Returns the unique name of the persisted table.
|
static <K,V> PersistedTable<K,V> |
of(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Creates a
PersistedTable instance that may be used to access persisted state managed by
the system. |
static <K,V> PersistedTable<K,V> |
of(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType,
Expiration expiration)
Creates a
PersistedTable instance that may be used to access persisted state managed by
the system. |
void |
remove(K key)
Removes the value associated with
key. |
void |
set(K key,
V value)
Updates the persisted table.
|
java.lang.String |
toString() |
java.lang.Iterable<V> |
values()
Gets an
Iterable over all values of the persisted table. |
java.lang.Class<V> |
valueType()
Returns the type of the persisted tables values.
|
public static <K,V> PersistedTable<K,V> of(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
PersistedTable instance that may be used to access persisted state managed by
the system. Access to the persisted table is identified by an unique name, type of the key, and
type of the value. These may not change across multiple executions of the application.K - the type of the state keys.V - the type of the state values.name - the unique name of the persisted state.keyType - the type of the state keys of this PersistedTable.valueType - the type of the state values of this PersistedTale.PersistedTable instance.public static <K,V> PersistedTable<K,V> of(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType, Expiration expiration)
PersistedTable instance that may be used to access persisted state managed by
the system. Access to the persisted table is identified by an unique name, type of the key, and
type of the value. These may not change across multiple executions of the application.K - the type of the state keys.V - the type of the state values.name - the unique name of the persisted state.keyType - the type of the state keys of this PersistedTable.valueType - the type of the state values of this PersistedTale.expiration - state expiration configuration.PersistedTable instance.public java.lang.String name()
public java.lang.Class<K> keyType()
public java.lang.Class<V> valueType()
public Expiration expiration()
public V get(K key)
key.public void set(K key, V value)
key - the to associate the value with.value - the new value.public void remove(K key)
key.key - the key to remove.public java.lang.Iterable<java.util.Map.Entry<K,V>> entries()
Iterable over all the entries of the persisted table.Iterable of the elements of the persisted table.public java.lang.Iterable<K> keys()
Iterable over all keys of the persisted table.Iterable of keys in the persisted table.public java.lang.Iterable<V> values()
Iterable over all values of the persisted table.Iterable of values in the persisted table.public void clear()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.