Class SimpleReadOnlyMapImpl<K,V>
- All Implemented Interfaces:
AutoCloseable
,FunctionalMap<K,
,V> FunctionalMap.ReadOnlyMap<K,
V>
ReadOnlyMapImpl
that works with a simple cache.- Since:
- 15.0
- Author:
- José Bolina
- 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 DataConversion
protected final Params
protected final DataConversion
-
Method Summary
Modifier and TypeMethodDescriptioncache()
void
close()
protected Map
<?, ?> encodeEntries
(Map<? extends K, ?> entries) protected Set
<?> encodeKeys
(Set<? extends K> keys) <R> CompletableFuture
<R> Evaluate a read-only function on the value associated with the key and return aCompletableFuture
with the return type of the function.<R> Traversable
<R> Evaluate a read-only function on a key and potential value associated in the functional map, for each of the keys in the set passed in, and returns anTraversable
to work on each computed function's result.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) readCacheEntry
(K key, InternalCacheEntry<K, V> ice) default <R> R
default K
toStorageKey
(K key) Methods inherited from class org.infinispan.functional.impl.ReadOnlyMapImpl
create, entries, keys, withParams
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
Methods inherited from interface org.infinispan.functional.FunctionalMap.ReadOnlyMap
eval, evalMany
-
Field Details
-
fmap
-
params
-
keyDataConversion
-
valueDataConversion
-
-
Method Details
-
eval
Description copied from interface:FunctionalMap.ReadOnlyMap
Evaluate a read-only function on the value associated with the key and return aCompletableFuture
with the return type of the function. If the user is not sure if the key is present,EntryView.ReadEntryView.find()
can be used to find out for sure. Typically, function implementations would return value orMetaParam
information from the cache entry in the functional map.By returning
CompletableFuture
instead of the function's return type directly, the method hints at the possibility that to execute the function might require to go remote to retrieve data in persistent store or another clustered node.This method can be used to implement read-only single-key based operations in
ConcurrentMap
such as:The function must not mutate neither the key returned through
EntryView.ReadEntryView.key()
nor the internally stored value provided throughEntryView.ReadEntryView.get()
orEntryView.ReadEntryView.find()
.- Specified by:
eval
in interfaceFunctionalMap.ReadOnlyMap<K,
V> - Overrides:
eval
in classReadOnlyMapImpl<K,
V> - Type Parameters:
R
- function return type- Parameters:
key
- the key associated with theEntryView.ReadEntryView
to be passed to the function.f
- function that takes aEntryView.ReadEntryView
associated with the key, and returns a value.- Returns:
- a
CompletableFuture
which will be completed with the returned value from the function
-
evalMany
public <R> Traversable<R> evalMany(Set<? extends K> keys, Function<EntryView.ReadEntryView<K, V>, R> f) Description copied from interface:FunctionalMap.ReadOnlyMap
Evaluate a read-only function on a key and potential value associated in the functional map, for each of the keys in the set passed in, and returns anTraversable
to work on each computed function's result.The function passed in will be executed for as many keys present in keys collection set. Similar to
FunctionalMap.ReadOnlyMap.eval(Object, Function)
, if the user is not sure whether a particular key is present,EntryView.ReadEntryView.find()
can be used to find out for sure. DESIGN RATIONALE:- It makes sense to expose global operation like this instead of forcing users to iterate over the keys to lookup and call get individually since Infinispan can do things more efficiently.
The function must not mutate neither the key returned through
EntryView.ReadEntryView.key()
nor the internally stored value provided throughEntryView.ReadEntryView.get()
orEntryView.ReadEntryView.find()
.- Specified by:
evalMany
in interfaceFunctionalMap.ReadOnlyMap<K,
V> - Overrides:
evalMany
in classReadOnlyMapImpl<K,
V> - Type Parameters:
R
- function return type- Parameters:
keys
- the keys associated with each of theEntryView.ReadEntryView
passed in the function callbacksf
- function that takes aEntryView.ReadEntryView
associated with the key, and returns a value. It'll be invoked once for each key passed in- Returns:
- a sequential
Traversable
that can be navigated to retrieve each function return value
-
toStorageKey
-
toLocalExecution
-
readCacheEntry
-
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
-