Class SimpleWriteOnlyMapImpl<K,V>
- All Implemented Interfaces:
AutoCloseable,FunctionalMap<K,,V> FunctionalMap.WriteOnlyMap<K,V>
WriteOnlyMapImpl that works with a simple cache.- Since:
- 15.0
- See Also:
-
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
FieldsModifier and TypeFieldDescriptionprotected final FunctionalMapImpl<K, V> protected final DataConversionprotected final Paramsprotected final DataConversion -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimpleWriteOnlyMapImpl(Params params, FunctionalMapImpl<K, V> functionalMap) -
Method Summary
Modifier and TypeMethodDescriptioncache()voidclose()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-onlyConsumeroperation with aEntryView.WriteEntryViewof the value associated with the key, and return aCompletableFuturewhich 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-onlyBiConsumeroperation, with an argument passed in and aEntryView.WriteEntryViewof the value associated with the key, and return aCompletableFuturewhich will be completed when the operation completes.Evaluate a write-onlyConsumeroperation with theEntryView.WriteEntryViewof the value associated with the key, for all existing keys in functional map, and returns aCompletableFuturethat 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-onlyBiConsumeroperation, with an argument passed in and aEntryView.WriteEntryViewof the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuturethat will be completed when the write-only operation has been executed against all the entries.Evaluate a write-onlyConsumeroperation with theEntryView.WriteEntryViewof the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuturethat will be completed when the write-only operation has been executed against all the entries.protected InvocationContextgetInvocationContext(boolean isWrite, int keyCount) getName()Functional map's name.Functional map's status.protected <T> CompletableFuture<T> invokeAsync(InvocationContext ctx, VisitableCommand cmd) readCacheEntry(K key, InternalCacheEntry<K, V> ice) default <R> Rdefault KtoStorageKey(K key) Methods inherited from class org.infinispan.functional.impl.WriteOnlyMapImpl
listeners, truncate, withParamsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface org.infinispan.functional.FunctionalMap
cache, getName, getStatus, isEncoded
-
Field Details
-
fmap
-
params
-
keyDataConversion
-
valueDataConversion
-
-
Constructor Details
-
SimpleWriteOnlyMapImpl
-
-
Method Details
-
create
-
eval
Description copied from interface:FunctionalMap.WriteOnlyMapEvaluate a write-onlyConsumeroperation with aEntryView.WriteEntryViewof the value associated with the key, and return aCompletableFuturewhich 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:
evalin interfaceFunctionalMap.WriteOnlyMap<K,V> - Overrides:
evalin classWriteOnlyMapImpl<K,V> - Parameters:
key- the key associated with theEntryView.WriteEntryViewto be passed to the operationf- operation that takes aEntryView.WriteEntryViewassociated with the key and writes to the it without returning anything- Returns:
- a
CompletableFuturewhich 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.WriteOnlyMapEvaluate a write-onlyBiConsumeroperation, with an argument passed in and aEntryView.WriteEntryViewof the value associated with the key, and return aCompletableFuturewhich 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 aBiConsumerthat takes user provided value as first parameter, the operation does not capture any external objects when implementing simple operations, and hence, theBiConsumercould be cached and reused each time it's invoked.Note that when
encodersare in place despite the argument type and value type don't have to match the argument will use value encoding.- Specified by:
evalin interfaceFunctionalMap.WriteOnlyMap<K,V> - Overrides:
evalin classWriteOnlyMapImpl<K,V> - Parameters:
key- the key associated with theEntryView.WriteEntryViewto be passed to the operationargument- argument passed in as first parameter to theBiConsumeroperation.f- operation that takes a user defined value, and aEntryView.WriteEntryViewassociated with the key, and writes to theEntryView.WriteEntryViewpassed in without returning anything- Returns:
- a
CompletableFuturewhich will be completed when the operation completes
-
evalMany
public CompletableFuture<Void> evalMany(Set<? extends K> keys, Consumer<EntryView.WriteEntryView<K, V>> f) Description copied from interface:FunctionalMap.WriteOnlyMapEvaluate a write-onlyConsumeroperation with theEntryView.WriteEntryViewof the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuturethat 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:
evalManyin interfaceFunctionalMap.WriteOnlyMap<K,V> - Overrides:
evalManyin classWriteOnlyMapImpl<K,V> - Parameters:
keys- the keys associated with each of theEntryView.WriteEntryViewpassed in the function callbacksf- operation that theEntryView.WriteEntryViewassociated with one of the keys passed in- Returns:
- a
CompletableFuturewhich will be completed when theConsumeroperation has been executed against all entries
-
evalMany
public <T> CompletableFuture<Void> evalMany(Map<? extends K, ? extends T> arguments, BiConsumer<T, EntryView.WriteEntryView<K, V>> f) Description copied from interface:FunctionalMap.WriteOnlyMapEvaluate a write-onlyBiConsumeroperation, with an argument passed in and aEntryView.WriteEntryViewof the value associated with the key, for each of the keys in the set passed in, and returns aCompletableFuturethat 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
encodersare in place despite the argument type and value type don't have to match the argument will use value encoding.- Specified by:
evalManyin interfaceFunctionalMap.WriteOnlyMap<K,V> - Overrides:
evalManyin classWriteOnlyMapImpl<K,V> - Parameters:
arguments- the key/value pairs associated with each of theEntryView.WriteEntryViewpassed in the function callbacksf- operation that consumes a value associated with a key in the entries collection and theEntryView.WriteEntryViewassociated with that key in the cache- Returns:
- a
CompletableFuturewhich will be completed when theBiConsumeroperation has been executed against all entries
-
evalAll
Description copied from interface:FunctionalMap.WriteOnlyMapEvaluate a write-onlyConsumeroperation with theEntryView.WriteEntryViewof the value associated with the key, for all existing keys in functional map, and returns aCompletableFuturethat will be completed when the write-only operation has been executed against all the entries.- Specified by:
evalAllin interfaceFunctionalMap.WriteOnlyMap<K,V> - Overrides:
evalAllin classWriteOnlyMapImpl<K,V> - Parameters:
f- operation that theEntryView.WriteEntryViewassociated with one of the keys passed in- Returns:
- a
CompletableFuturewhich will be completed when theConsumeroperation has been executed against all entries
-
toStorageKey
-
toLocalExecution
-
readCacheEntry
-
getName
Description copied from interface:FunctionalMapFunctional map's name.- Specified by:
getNamein interfaceFunctionalMap<K,V>
-
getStatus
Description copied from interface:FunctionalMapFunctional map's status.- Specified by:
getStatusin interfaceFunctionalMap<K,V>
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
cache
- Specified by:
cachein interfaceFunctionalMap<K,V>
-
getInvocationContext
-
invokeAsync
-
encodeKeys
-
encodeEntries
-