Class WriteOnlyMapImpl<K,V>
- All Implemented Interfaces:
AutoCloseable
,FunctionalMap<K,
,V> FunctionalMap.WriteOnlyMap<K,
V>
- Direct Known Subclasses:
SimpleWriteOnlyMapImpl
- Since:
- 8.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.functional.FunctionalMap
FunctionalMap.ReadOnlyMap<K,
V>, FunctionalMap.ReadWriteMap<K, V>, FunctionalMap.WriteOnlyMap<K, V> -
Field Summary
Modifier and TypeFieldDescriptionprotected final FunctionalMapImpl
<K, V> protected final DataConversion
protected final Params
protected final DataConversion
-
Constructor Summary
ModifierConstructorDescriptionprotected
WriteOnlyMapImpl
(Params params, FunctionalMapImpl<K, V> functionalMap) -
Method Summary
Modifier and TypeMethodDescriptioncache()
void
close()
static <K,
V> FunctionalMap.WriteOnlyMap <K, V> create
(FunctionalMapImpl<K, V> functionalMap) protected Map
<?, ?> encodeEntries
(Map<? extends K, ?> entries) protected Set
<?> encodeKeys
(Set<? extends K> keys) Evaluate a write-onlyConsumer
operation with aEntryView.WriteEntryView
of the value associated with the key, and return aCompletableFuture
which will be completed with the object returned by the operation.<T> CompletableFuture
<Void> eval
(K key, T argument, BiConsumer<T, EntryView.WriteEntryView<K, V>> f) Evaluate a write-onlyBiConsumer
operation, with an argument passed in and aEntryView.WriteEntryView
of the value associated with the key, and return aCompletableFuture
which will be completed when the operation completes.Evaluate a write-onlyConsumer
operation with theEntryView.WriteEntryView
of the value associated with the key, for all existing keys in functional map, and returns aCompletableFuture
that will be completed when the write-only operation has been executed against all the entries.<T> CompletableFuture
<Void> evalMany
(Map<? extends K, ? extends T> arguments, BiConsumer<T, EntryView.WriteEntryView<K, V>> f) Evaluate a write-onlyBiConsumer
operation, with an argument passed in and aEntryView.WriteEntryView
of the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuture
that will be completed when the write-only operation has been executed against all the entries.Evaluate a write-onlyConsumer
operation with theEntryView.WriteEntryView
of the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuture
that will be completed when the write-only operation has been executed against all the entries.protected InvocationContext
getInvocationContext
(boolean isWrite, int keyCount) getName()
Functional map's name.Functional map's status.protected <T> CompletableFuture
<T> invokeAsync
(InvocationContext ctx, VisitableCommand cmd) Allows to write-only listeners to be registered.truncate()
Truncate the contents of the cache, returning aCompletableFuture
that will be completed when the truncate process completes.withParams
(Param<?>... ps) Tweak write-only functional map executions providingParam
instances.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.AutoCloseable
close
Methods inherited from interface org.infinispan.functional.FunctionalMap
cache, getName, getStatus, isEncoded
-
Field Details
-
fmap
-
params
-
keyDataConversion
-
valueDataConversion
-
-
Constructor Details
-
WriteOnlyMapImpl
-
-
Method Details
-
create
-
eval
Description copied from interface:FunctionalMap.WriteOnlyMap
Evaluate a write-onlyConsumer
operation with aEntryView.WriteEntryView
of the value associated with the key, and return aCompletableFuture
which will be completed with the object returned by the operation.Since this is a write-only operation, no entry attributes can be queried, hence the only reasonable thing can be returned is Void.
This operation can be used to either remove a cached entry, or to write a constant value along with optional metadata parameters.
- Specified by:
eval
in interfaceFunctionalMap.WriteOnlyMap<K,
V> - Parameters:
key
- the key associated with theEntryView.WriteEntryView
to be passed to the operationf
- operation that takes aEntryView.WriteEntryView
associated with the key and writes to the it without returning anything- Returns:
- a
CompletableFuture
which will be completed when the operation completes
-
eval
public <T> CompletableFuture<Void> eval(K key, T argument, BiConsumer<T, EntryView.WriteEntryView<K, V>> f) Description copied from interface:FunctionalMap.WriteOnlyMap
Evaluate a write-onlyBiConsumer
operation, with an argument passed in and aEntryView.WriteEntryView
of the value associated with the key, and return aCompletableFuture
which will be completed when the operation completes.Since this is a write-only operation, no entry attributes can be queried, hence the only reasonable thing can be returned is Void.
This method can be used to implement single-key write-only operations which do not need to query the previous value.
This operation is very similar to
FunctionalMap.WriteOnlyMap.eval(Object, Consumer)
and in fact, the functionality provided by this function could indeed be implemented withFunctionalMap.WriteOnlyMap.eval(Object, Consumer)
, but there's a crucial difference. If you want to store a value and reference the value to be stored from the passed in operation,FunctionalMap.WriteOnlyMap.eval(Object, Consumer)
needs to capture that value. Capturing means that each time the operation is called, a new lambda needs to be instantiated. By offering aBiConsumer
that takes user provided value as first parameter, the operation does not capture any external objects when implementing simple operations, and hence, theBiConsumer
could be cached and reused each time it's invoked.Note that when
encoders
are in place despite the argument type and value type don't have to match the argument will use value encoding.- Specified by:
eval
in interfaceFunctionalMap.WriteOnlyMap<K,
V> - Parameters:
key
- the key associated with theEntryView.WriteEntryView
to be passed to the operationargument
- argument passed in as first parameter to theBiConsumer
operation.f
- operation that takes a user defined value, and aEntryView.WriteEntryView
associated with the key, and writes to theEntryView.WriteEntryView
passed in without returning anything- Returns:
- a
CompletableFuture
which will be completed when the operation completes
-
evalMany
public <T> CompletableFuture<Void> evalMany(Map<? extends K, ? extends T> arguments, BiConsumer<T, EntryView.WriteEntryView<K, V>> f) Description copied from interface:FunctionalMap.WriteOnlyMap
Evaluate a write-onlyBiConsumer
operation, with an argument passed in and aEntryView.WriteEntryView
of the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuture
that will be completed when the write-only operation has been executed against all the entries.These kind of operations are preferred to traditional end user iterations because the internal logic can often iterate more efficiently since it knows more about the system.
Since this is a write-only operation, no entry attributes can be queried, hence the only reasonable thing can be returned is Void.
Note that when
encoders
are in place despite the argument type and value type don't have to match the argument will use value encoding.- Specified by:
evalMany
in interfaceFunctionalMap.WriteOnlyMap<K,
V> - Parameters:
arguments
- the key/value pairs associated with each of theEntryView.WriteEntryView
passed in the function callbacksf
- operation that consumes a value associated with a key in the entries collection and theEntryView.WriteEntryView
associated with that key in the cache- Returns:
- a
CompletableFuture
which will be completed when theBiConsumer
operation has been executed against all entries
-
evalMany
public CompletableFuture<Void> evalMany(Set<? extends K> keys, Consumer<EntryView.WriteEntryView<K, V>> f) Description copied from interface:FunctionalMap.WriteOnlyMap
Evaluate a write-onlyConsumer
operation with theEntryView.WriteEntryView
of the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuture
that will be completed when the write-only operation has been executed against all the entries.These kind of operations are preferred to traditional end user iterations because the internal logic can often iterate more efficiently since it knows more about the system.
Since this is a write-only operation, no entry attributes can be queried, hence the only reasonable thing can be returned is Void.
- Specified by:
evalMany
in interfaceFunctionalMap.WriteOnlyMap<K,
V> - Parameters:
keys
- the keys associated with each of theEntryView.WriteEntryView
passed in the function callbacksf
- operation that theEntryView.WriteEntryView
associated with one of the keys passed in- Returns:
- a
CompletableFuture
which will be completed when theConsumer
operation has been executed against all entries
-
evalAll
Description copied from interface:FunctionalMap.WriteOnlyMap
Evaluate a write-onlyConsumer
operation with theEntryView.WriteEntryView
of the value associated with the key, for all existing keys in functional map, and returns aCompletableFuture
that will be completed when the write-only operation has been executed against all the entries.- Specified by:
evalAll
in interfaceFunctionalMap.WriteOnlyMap<K,
V> - Parameters:
f
- operation that theEntryView.WriteEntryView
associated with one of the keys passed in- Returns:
- a
CompletableFuture
which will be completed when theConsumer
operation has been executed against all entries
-
truncate
Description copied from interface:FunctionalMap.WriteOnlyMap
Truncate the contents of the cache, returning aCompletableFuture
that will be completed when the truncate process completes. This method can be used to implement:- Specified by:
truncate
in interfaceFunctionalMap.WriteOnlyMap<K,
V> - Returns:
- a
CompletableFuture
that completes when the truncat has finished
-
withParams
Description copied from interface:FunctionalMap.WriteOnlyMap
Tweak write-only functional map executions providingParam
instances.- Specified by:
withParams
in interfaceFunctionalMap<K,
V> - Specified by:
withParams
in interfaceFunctionalMap.WriteOnlyMap<K,
V>
-
listeners
Description copied from interface:FunctionalMap.WriteOnlyMap
Allows to write-only listeners to be registered.- Specified by:
listeners
in interfaceFunctionalMap.WriteOnlyMap<K,
V>
-
getName
Description copied from interface:FunctionalMap
Functional map's name.- Specified by:
getName
in interfaceFunctionalMap<K,
V>
-
getStatus
Description copied from interface:FunctionalMap
Functional map's status.- Specified by:
getStatus
in interfaceFunctionalMap<K,
V>
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
cache
- Specified by:
cache
in interfaceFunctionalMap<K,
V>
-
getInvocationContext
-
invokeAsync
-
encodeKeys
-
encodeEntries
-