K
- The type of the key associated with the Operation
V
- The type of the value associated with the Operation
public interface Batch<K,V>
Operation
s, which will be performed as a batch.
A batch can be configured with a maxBatchSize
and/or maxBatchDelay
.
When the number of operations in the batch exceeds the maxBatchSize
or the time window exceeds the maxBatchDelay
, the batch will be performed.Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletableFuture<java.lang.Void> |
addOperation(Operation<K,V> operation)
Add an operation to the batch.
|
void |
close()
Close the bach so that it will not accept more operations.
|
void |
complete()
Change the batch status to be complete.
|
void |
completeExceptionally(java.lang.Throwable throwable)
Change the batch status to be complete with exception.
|
java.time.Duration |
getMaxBatchDelay() |
int |
getMaxBatchSize() |
java.util.Collection<Operation<K,V>> |
getOperations() |
boolean |
isClosed() |
default boolean |
isEmpty() |
int |
size() |
java.util.concurrent.CompletableFuture<java.lang.Void> addOperation(Operation<K,V> operation)
operation
- The operation to be added.CompletableFuture
that indicate the status of the batch.void close()
boolean isClosed()
java.util.Collection<Operation<K,V>> getOperations()
java.time.Duration getMaxBatchDelay()
int getMaxBatchSize()
void complete()
void completeExceptionally(java.lang.Throwable throwable)
int size()
default boolean isEmpty()