K
- the type of the key in this tableV
- the type of the value in this tableU
- the type of the update@InterfaceStability.Unstable public interface TableWriteFunction<K,V,U> extends TableFunction
Instances of TableWriteFunction
are meant to be serializable. ie. any non-serializable state
(eg: network sockets) should be marked as transient and recreated inside readObject().
Implementations are expected to be thread-safe.
Modifier and Type | Method and Description |
---|---|
default void |
delete(K key)
Delete the
record with specified key from the remote store. |
default void |
deleteAll(java.util.Collection<K> keys)
Delete all
records with the specified keys from the remote store
The default implementation calls deleteAllAsync and blocks on the completion afterwards. |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteAllAsync(java.util.Collection<K> keys)
Asynchronously delete all
records with the specified keys from the remote store. |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteAllAsync(java.util.Collection<K> keys,
java.lang.Object... args)
Asynchronously delete all
records with the specified keys and additional arguments from
the remote store. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteAsync(K key)
Asynchronously delete the
record with specified key from the remote store |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteAsync(K key,
java.lang.Object... args)
Asynchronously delete the
record with specified key and additional arguments from the remote store |
default void |
flush()
Flush the remote store (optional)
|
default void |
put(K key,
V record)
Store single table
record with specified key . |
default void |
putAll(java.util.List<Entry<K,V>> records)
Store the table
records with specified keys . |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
putAllAsync(java.util.Collection<Entry<K,V>> records)
Asynchronously store the table
records with specified keys . |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
putAllAsync(java.util.Collection<Entry<K,V>> records,
java.lang.Object... args)
Asynchronously store the table
records with specified keys and additional arguments. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
putAsync(K key,
V record)
Asynchronously store single table
record with specified key . |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
putAsync(K key,
V record,
java.lang.Object... args)
Asynchronously store single table
record with specified key and additional arguments. |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
updateAllAsync(java.util.Collection<Entry<K,U>> updates)
Asynchronously updates the table with multiple
updates . |
java.util.concurrent.CompletableFuture<java.lang.Void> |
updateAsync(K key,
U update)
Asynchronously update the resource for a given
key with the update . |
default <T> java.util.concurrent.CompletableFuture<T> |
writeAsync(int opId,
java.lang.Object... args)
Asynchronously write data to table for specified
opId and additional arguments. |
init, isRetriable
close
default void put(K key, V record)
record
with specified key
. This method must be thread-safe.
The default implementation calls putAsync and blocks on the completion afterwards.key
- key for the table recordrecord
- table record to be writtenjava.util.concurrent.CompletableFuture<java.lang.Void> putAsync(K key, V record)
record
with specified key
. This method must be thread-safe.key
- key for the table recordrecord
- table record to be writtendefault java.util.concurrent.CompletableFuture<java.lang.Void> putAsync(K key, V record, java.lang.Object... args)
record
with specified key
and additional arguments.
This method must be thread-safe.key
- key for the table recordrecord
- table record to be writtenargs
- additional argumentsdefault void putAll(java.util.List<Entry<K,V>> records)
records
with specified keys
. This method must be thread-safe.
The default implementation calls putAllAsync and blocks on the completion afterwards.records
- table records to be writtendefault java.util.concurrent.CompletableFuture<java.lang.Void> putAllAsync(java.util.Collection<Entry<K,V>> records)
records
with specified keys
. This method must be thread-safe.
The default implementation calls putAsync for each entry and return a combined future.records
- table records to be writtendefault java.util.concurrent.CompletableFuture<java.lang.Void> putAllAsync(java.util.Collection<Entry<K,V>> records, java.lang.Object... args)
records
with specified keys
and additional arguments.
This method must be thread-safe.records
- table records to be writtenargs
- additional argumentsjava.util.concurrent.CompletableFuture<java.lang.Void> updateAsync(K key, U update)
key
with the update
.
This method must be thread-safe.
If the update operation failed due to the update being applied to a non-existent resource, the update
implementation can return a future completed exceptionally with a RecordNotFoundException
. This will
allow the MessageStream.sendTo(Table, org.apache.samza.operators.UpdateOptions)
}
to Put a default resource, if one is provided in the UpdateMessage
.key
- key for the table recordupdate
- update record for the given keydefault java.util.concurrent.CompletableFuture<java.lang.Void> updateAllAsync(java.util.Collection<Entry<K,U>> updates)
updates
. This method must be thread-safe.
The default implementation calls updateAsync for each entry and return a combined future.updates
- updates for the tabledefault void delete(K key)
record
with specified key
from the remote store.
The default implementation calls deleteAsync and blocks on the completion afterwards.key
- key to the table record to be deletedjava.util.concurrent.CompletableFuture<java.lang.Void> deleteAsync(K key)
record
with specified key
from the remote storekey
- key to the table record to be deleteddefault java.util.concurrent.CompletableFuture<java.lang.Void> deleteAsync(K key, java.lang.Object... args)
record
with specified key
and additional arguments from the remote storekey
- key to the table record to be deletedargs
- additional argumentsdefault void deleteAll(java.util.Collection<K> keys)
records
with the specified keys
from the remote store
The default implementation calls deleteAllAsync and blocks on the completion afterwards.keys
- keys for the table records to be writtendefault java.util.concurrent.CompletableFuture<java.lang.Void> deleteAllAsync(java.util.Collection<K> keys)
records
with the specified keys
from the remote store.
The default implementation calls deleteAsync for each key and return a combined future.keys
- keys for the table records to be writtendefault java.util.concurrent.CompletableFuture<java.lang.Void> deleteAllAsync(java.util.Collection<K> keys, java.lang.Object... args)
records
with the specified keys
and additional arguments from
the remote store.keys
- keys for the table records to be writtenargs
- additional argumentsdefault <T> java.util.concurrent.CompletableFuture<T> writeAsync(int opId, java.lang.Object... args)
opId
and additional arguments.
This method must be thread-safe.T
- return typeopId
- operation identifierargs
- additional argumentsdefault void flush()