Interface AsyncNamedMap<K,V>
-
- Type Parameters:
K
- the type of the map entry keysV
- the type of the map entry values
- All Known Subinterfaces:
AsyncNamedCache<K,V>
public interface AsyncNamedMap<K,V>
AsynchronousNamedMap
.- Since:
- 20.06
- Author:
- Aleks Seovic 2020.06.06
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AsyncNamedMap.Complete
AnAsyncNamedMap.Option
to use to specify theExecutor
to use to complete theCompletableFuture
returned from async methods.static interface
AsyncNamedMap.Option
An immutable option for creating and configuringAsyncNamedMap
s.static class
AsyncNamedMap.OrderBy
A configuration option which determines the ordering of async operations.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <R> CompletableFuture<R>
aggregate(Filter<?> filter, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation asynchronously against the set of entries that are selected by the given Filter.default <R> CompletableFuture<R>
aggregate(InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation asynchronously against all the entries.<R> CompletableFuture<R>
aggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation asynchronously against the entries specified by the passed keys.default CompletableFuture<Void>
clear()
Removes all of the mappings from this map.default CompletableFuture<V>
compute(K key, Remote.BiFunction<? super K,? super V,? extends V> remappingFunction)
Compute a new mapping for the specified key and its current value.default CompletableFuture<V>
computeIfAbsent(K key, Remote.Function<? super K,? extends V> mappingFunction)
Compute the value using the given mapping function and enter it into this map (unlessnull
), if the specified key is not already associated with a value (or is mapped tonull
).default CompletableFuture<V>
computeIfPresent(K key, Remote.BiFunction<? super K,? super V,? extends V> remappingFunction)
Compute a new mapping given the key and its current mapped value, if the value for the specified key is present and non-null.default CompletableFuture<Boolean>
containsKey(K key)
Returns true if this map contains a mapping for the specified key.default CompletableFuture<Set<Map.Entry<K,V>>>
entrySet()
Return a set view of all the entries contained in this map.default CompletableFuture<Set<Map.Entry<K,V>>>
entrySet(Filter<?> filter)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.default CompletableFuture<Set<Map.Entry<K,V>>>
entrySet(Filter<?> filter, Comparator<?> comparator)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.default CompletableFuture<Void>
entrySet(Filter<?> filter, BiConsumer<? super K,? super V> callback)
Stream the entries that satisfy the specified filter to the provided callback.default CompletableFuture<Void>
entrySet(Filter<?> filter, Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Stream the entries that satisfy the specified filter to the provided callback.default CompletableFuture<Void>
entrySet(BiConsumer<? super K,? super V> callback)
Stream all the entries contained in this map to the provided callback.default CompletableFuture<Void>
entrySet(Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Stream all the entries contained in this map to the provided callback.default CompletableFuture<V>
get(K key)
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.default CompletableFuture<Map<K,V>>
getAll(Filter<?> filter)
Get all the entries that satisfy the specified filter.default CompletableFuture<Void>
getAll(Filter<?> filter, BiConsumer<? super K,? super V> callback)
Get all the entries that satisfy the specified filter.default CompletableFuture<Void>
getAll(Filter<?> filter, Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Get all the entries that satisfy the specified filter.default CompletableFuture<Map<K,V>>
getAll(Collection<? extends K> colKeys)
Get all the specified keys, if they are in the map.default CompletableFuture<Void>
getAll(Collection<? extends K> colKeys, BiConsumer<? super K,? super V> callback)
Stream the entries associated with the specified keys to the provided callback.default CompletableFuture<Void>
getAll(Collection<? extends K> colKeys, Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Stream the entries associated with the specified keys to the provided callback.NamedMap<K,V>
getNamedMap()
Return theNamedCache
instance thisAsyncNamedCache
is based on.default CompletableFuture<V>
getOrDefault(K key, V valueDefault)
Returns the value to which the specified key is mapped, orvalueDefault
if this map contains no mapping for the key.<R> CompletableFuture<R>
invoke(K key, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the Entry specified by the passed key asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation.<R> CompletableFuture<Map<K,R>>
invokeAll(Filter<?> filter, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation for each entry.default <R> CompletableFuture<Void>
invokeAll(Filter<?> filter, InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.<R> CompletableFuture<Void>
invokeAll(Filter<?> filter, InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.default <R> CompletableFuture<Map<K,R>>
invokeAll(InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against all the entries asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation for each entry.default <R> CompletableFuture<Void>
invokeAll(InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
Invoke the passed EntryProcessor against all the entries asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.default <R> CompletableFuture<Void>
invokeAll(InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
Invoke the passed EntryProcessor against all the entries asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.<R> CompletableFuture<Map<K,R>>
invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the entries specified by the passed keys asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation for each entry.default <R> CompletableFuture<Void>
invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
Invoke the passed EntryProcessor against the entries specified by the passed keys asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.<R> CompletableFuture<Void>
invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
Invoke the passed EntryProcessor against the entries specified by the passed keys asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.default CompletableFuture<Boolean>
isEmpty()
Returns true if this map contains no key-value mappings.default CompletableFuture<Set<K>>
keySet()
Return a set view of all the keys contained in this map.default CompletableFuture<Set<K>>
keySet(Filter<?> filter)
Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.default CompletableFuture<Void>
keySet(Filter<?> filter, Consumer<? super K> callback)
Stream the keys for the entries that satisfy the specified filter to the provided callback.default CompletableFuture<Void>
keySet(Consumer<? super K> callback)
Stream the keys of all the entries contained in this map to the provided callback.default CompletableFuture<V>
merge(K key, V value, Remote.BiFunction<? super V,? super V,? extends V> remappingFunction)
If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value.default CompletableFuture<Void>
put(K key, V value)
Associates the specified value with the specified key in this map.default CompletableFuture<Void>
putAll(Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map.default CompletableFuture<V>
putIfAbsent(K key, V value)
If the specified key is not already associated with a value (or is mapped tonull
) associates it with the given value and returnsnull
, else returns the current value.default CompletableFuture<V>
remove(K key)
Removes the mapping for a key from this map if it is present.default CompletableFuture<Boolean>
remove(K key, V value)
Removes the entry for the specified key only if it is currently mapped to the specified value.default CompletableFuture<Void>
removeAll(Filter<?> filter)
Removes all of the mappings that satisfy the specified filter from this map.default CompletableFuture<Void>
removeAll(Collection<? extends K> colKeys)
Removes all of the mappings from the specified keys from this map, if they are present in the map.default CompletableFuture<V>
replace(K key, V value)
Replaces the entry for the specified key only if it is currently mapped to some value.default CompletableFuture<Boolean>
replace(K key, V oldValue, V newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.default CompletableFuture<Map<K,Void>>
replaceAll(Filter<?> filter, Remote.BiFunction<? super K,? super V,? extends V> function)
Replace each entry's value with the result of invoking the given function on that entry until all entries selected by the specified filter have been processed or the function throws an exception.default CompletableFuture<Map<K,Void>>
replaceAll(Remote.BiFunction<? super K,? super V,? extends V> function)
Replace each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.default CompletableFuture<Map<K,Void>>
replaceAll(Collection<? extends K> collKeys, Remote.BiFunction<? super K,? super V,? extends V> function)
Replace each entry's value with the result of invoking the given function on that entry until all entries for the specified key set have been processed or the function throws an exception.default CompletableFuture<Integer>
size()
Returns the number of key-value mappings in this map.default CompletableFuture<Collection<V>>
values()
Return a collection of all the values contained in this map.default CompletableFuture<Collection<V>>
values(Filter<?> filter)
Return a collection of the values contained in this map that satisfy the criteria expressed by the filter.default CompletableFuture<Collection<V>>
values(Filter<?> filter, Comparator<? super V> comparator)
Return a collection of the values contained in this map that satisfy the criteria expressed by the filter.default CompletableFuture<Void>
values(Filter<?> filter, Consumer<? super V> callback)
Stream the values for the entries that satisfy the specified filter to the provided callback.default CompletableFuture<Void>
values(Consumer<? super V> callback)
Stream the values of all the entries contained in this map to the provided callback.
-
-
-
Method Detail
-
getNamedMap
NamedMap<K,V> getNamedMap()
Return theNamedCache
instance thisAsyncNamedCache
is based on.- Returns:
- the
NamedCache
instance thisAsyncNamedCache
is based on
-
get
default CompletableFuture<V> get(K key)
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- a
CompletableFuture
for the value to which the specified key is mapped
-
getAll
default CompletableFuture<Map<K,V>> getAll(Collection<? extends K> colKeys)
Get all the specified keys, if they are in the map. For each key that is in the map, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map indicates that it was not in the map, which may imply (for maps that can load behind the scenes) that the requested data could not be loaded.- Parameters:
colKeys
- a collection of keys that may be in the named map- Returns:
- a
CompletableFuture
for a Map of keys to values for the specified keys passed in colKeys
-
getAll
default CompletableFuture<Map<K,V>> getAll(Filter<?> filter)
Get all the entries that satisfy the specified filter. For each entry that satisfies the filter, the key and its corresponding value will be placed in the map that is returned by this method.- Parameters:
filter
- a Filter that determines the set of entries to return- Returns:
- a
CompletableFuture
for a Map of keys to values for the specified filter
-
getAll
default CompletableFuture<Void> getAll(Filter<?> filter, BiConsumer<? super K,? super V> callback)
Get all the entries that satisfy the specified filter. For each entry that satisfies the filter, the key and its corresponding value will be placed in the map that is returned by this method.- Parameters:
filter
- a Filter that determines the set of entries to returncallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
for a Map of keys to values for the specified filter
-
getAll
default CompletableFuture<Void> getAll(Filter<?> filter, Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Get all the entries that satisfy the specified filter. For each entry that satisfies the filter, the key and its corresponding value will be placed in the map that is returned by this method.- Parameters:
filter
- a Filter that determines the set of entries to returncallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
for a Map of keys to values for the specified filter
-
getAll
default CompletableFuture<Void> getAll(Collection<? extends K> colKeys, BiConsumer<? super K,? super V> callback)
Stream the entries associated with the specified keys to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
colKeys
- a collection of keys that may be in the named mapcallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
getAll
default CompletableFuture<Void> getAll(Collection<? extends K> colKeys, Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Stream the entries associated with the specified keys to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
colKeys
- a collection of keys that may be in the named mapcallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
put
default CompletableFuture<Void> put(K key, V value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.Invoking this method is equivalent to the following call:
put(oKey, oValue, CacheMap.EXPIRY_DEFAULT);
- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- a
CompletableFuture
-
putAll
default CompletableFuture<Void> putAll(Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map.- Parameters:
map
- mappings to be added to this map- Returns:
- a
CompletableFuture
-
remove
default CompletableFuture<V> remove(K key)
Removes the mapping for a key from this map if it is present.- Parameters:
key
- key whose mapping is to be removed from the map- Returns:
- a
CompletableFuture
for the previous value associated with the key
-
removeAll
default CompletableFuture<Void> removeAll(Collection<? extends K> colKeys)
Removes all of the mappings from the specified keys from this map, if they are present in the map.- Parameters:
colKeys
- a collection of keys that may be in the named map- Returns:
- a
CompletableFuture
-
removeAll
default CompletableFuture<Void> removeAll(Filter<?> filter)
Removes all of the mappings that satisfy the specified filter from this map.- Parameters:
filter
- a Filter that determines the set of entries to remove- Returns:
- a
CompletableFuture
-
keySet
default CompletableFuture<Set<K>> keySet()
Return a set view of all the keys contained in this map. NOTE: The returnedSet
will contain all the keys from the cache, which for a large cache could be a very large set consuming a large amount of memory. In this case it is better to usekeySet(Consumer)
- Returns:
- a complete set of keys for this map
-
keySet
default CompletableFuture<Set<K>> keySet(Filter<?> filter)
Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfy- Returns:
- a set of keys for entries that satisfy the specified criteria
-
keySet
default CompletableFuture<Void> keySet(Consumer<? super K> callback)
Stream the keys of all the entries contained in this map to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
callback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
keySet
default CompletableFuture<Void> keySet(Filter<?> filter, Consumer<? super K> callback)
Stream the keys for the entries that satisfy the specified filter to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfycallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
entrySet
default CompletableFuture<Set<Map.Entry<K,V>>> entrySet()
Return a set view of all the entries contained in this map. Each element in the returned set is aMap.Entry
.- Returns:
- a set of all entries in this map
-
entrySet
default CompletableFuture<Set<Map.Entry<K,V>>> entrySet(Filter<?> filter)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is aMap.Entry
.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfy- Returns:
- a set of entries that satisfy the specified criteria
-
entrySet
default CompletableFuture<Set<Map.Entry<K,V>>> entrySet(Filter<?> filter, Comparator<?> comparator)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is aMap.Entry
. It is further guaranteed that its iterator will traverse the set in such a way that the entry values come up in ascending order, sorted by the specified Comparator or according to the natural ordering (seeComparable
).- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfycomparator
- the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used- Returns:
- a set of entries that satisfy the specified criteria
-
entrySet
default CompletableFuture<Void> entrySet(BiConsumer<? super K,? super V> callback)
Stream all the entries contained in this map to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
callback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
entrySet
default CompletableFuture<Void> entrySet(Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Stream all the entries contained in this map to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
callback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
entrySet
default CompletableFuture<Void> entrySet(Filter<?> filter, BiConsumer<? super K,? super V> callback)
Stream the entries that satisfy the specified filter to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfycallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
entrySet
default CompletableFuture<Void> entrySet(Filter<?> filter, Consumer<? super Map.Entry<? extends K,? extends V>> callback)
Stream the entries that satisfy the specified filter to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfycallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
values
default CompletableFuture<Collection<V>> values()
Return a collection of all the values contained in this map.- Returns:
- a collection of all the values in this map
-
values
default CompletableFuture<Collection<V>> values(Filter<?> filter)
Return a collection of the values contained in this map that satisfy the criteria expressed by the filter.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfy- Returns:
- a collection of values for entries that satisfy the specified criteria
-
values
default CompletableFuture<Collection<V>> values(Filter<?> filter, Comparator<? super V> comparator)
Return a collection of the values contained in this map that satisfy the criteria expressed by the filter.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfycomparator
- the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used- Returns:
- a collection of values for entries that satisfy the specified criteria
-
values
default CompletableFuture<Void> values(Consumer<? super V> callback)
Stream the values of all the entries contained in this map to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
callback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
values
default CompletableFuture<Void> values(Filter<?> filter, Consumer<? super V> callback)
Stream the values for the entries that satisfy the specified filter to the provided callback. Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Parameters:
filter
- the Filter object representing the criteria that the entries of this map should satisfycallback
- a consumer of results as they become available- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
invoke
<R> CompletableFuture<R> invoke(K key, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the Entry specified by the passed key asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
key
- the key to process; it is not required to exist within the Mapprocessor
- the EntryProcessor to use to process the specified key- Returns:
- a
CompletableFuture
that can be used to obtain the result of the invocation
-
invokeAll
default <R> CompletableFuture<Map<K,R>> invokeAll(InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against all the entries asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation for each entry.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
processor
- the EntryProcessor to use to process the specified keys- Returns:
- a
CompletableFuture
that can be used to obtain the result of the invocation for each entry
-
invokeAll
<R> CompletableFuture<Map<K,R>> invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the entries specified by the passed keys asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation for each entry.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
collKeys
- the keys to process; these keys are not required to exist within the Mapprocessor
- the EntryProcessor to use to process the specified keys- Returns:
- a
CompletableFuture
that can be used to obtain the result of the invocation for each entry
-
invokeAll
<R> CompletableFuture<Map<K,R>> invokeAll(Filter<?> filter, InvocableMap.EntryProcessor<K,V,R> processor)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter asynchronously, returning aCompletableFuture
that can be used to obtain the result of the invocation for each entry.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
filter
- a Filter that results in the set of keys to be processedprocessor
- the EntryProcessor to use to process the specified keys- Returns:
- a
CompletableFuture
that can be used to obtain the result of the invocation for each entry
-
invokeAll
default <R> CompletableFuture<Void> invokeAll(InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
Invoke the passed EntryProcessor against all the entries asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.Instead of collecting and returning the complete result, this method will stream partial results of the processor execution to the specified partial result callback, which allows for a much lower memory overhead.
Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
processor
- the EntryProcessor to use to process the specified keyscallback
- a user-defined callback that will be called for each partial result- Returns:
- a
CompletableFuture
that can be used to determine if the operation completed successfully
-
invokeAll
default <R> CompletableFuture<Void> invokeAll(InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
Invoke the passed EntryProcessor against all the entries asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.Instead of collecting and returning the complete result, this method will stream partial results of the processor execution to the specified partial result callback, which allows for a much lower memory overhead.
Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
processor
- the EntryProcessor to use to process the specified keyscallback
- a user-defined callback that will be called for each partial result- Returns:
- a
CompletableFuture
that can be used to determine if the operation completed successfully
-
invokeAll
<R> CompletableFuture<Void> invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
Invoke the passed EntryProcessor against the entries specified by the passed keys asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.Instead of collecting and returning the complete result, this method will stream partial results of the processor execution to the specified partial result callback, which allows for a much lower memory overhead.
Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
collKeys
- the keys to process; these keys are not required to exist within the Mapprocessor
- the EntryProcessor to use to process the specified keyscallback
- a user-defined callback that will be called for each partial result- Returns:
- a
CompletableFuture
that can be used to determine if the operation completed successfully
-
invokeAll
default <R> CompletableFuture<Void> invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
Invoke the passed EntryProcessor against the entries specified by the passed keys asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.Instead of collecting and returning the complete result, this method will stream partial results of the processor execution to the specified partial result callback, which allows for a much lower memory overhead.
Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
collKeys
- the keys to process; these keys are not required to exist within the Mapprocessor
- the EntryProcessor to use to process the specified keyscallback
- a user-defined callback that will be called for each partial result- Returns:
- a
CompletableFuture
that can be used to determine if the operation completed successfully
-
invokeAll
<R> CompletableFuture<Void> invokeAll(Filter<?> filter, InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.Instead of collecting and returning the complete result, this method will stream partial results of the processor execution to the specified partial result callback, which allows for a much lower memory overhead.
Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
filter
- a Filter that results in the set of keys to be processedprocessor
- the EntryProcessor to use to process the specified keyscallback
- a user-defined callback that will be called for each partial result- Returns:
- a
CompletableFuture
that can be used to determine if the operation completed successfully
-
invokeAll
default <R> CompletableFuture<Void> invokeAll(Filter<?> filter, InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter asynchronously, returning aCompletableFuture
that can be used to determine if the operation completed successfully.Instead of collecting and returning the complete result, this method will stream partial results of the processor execution to the specified partial result callback, which allows for a much lower memory overhead.
Note: the callback implementation must be thread-safe as it may be called by multiple worker threads in cases where Coherence splits the operation over multiple partitions.- Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
filter
- a Filter that results in the set of keys to be processedprocessor
- the EntryProcessor to use to process the specified keyscallback
- a user-defined callback that will be called for each partial result- Returns:
- a
CompletableFuture
that can be used to determine if the operation completed successfully
-
aggregate
default <R> CompletableFuture<R> aggregate(InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation asynchronously against all the entries.- Type Parameters:
R
- the type of value returned by the EntryAggregator- Parameters:
aggregator
- the EntryAggregator that is used to aggregate across the specified entries of this Map- Returns:
- a
CompletableFuture
that can be used to obtain the result of the aggregation
-
aggregate
<R> CompletableFuture<R> aggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation asynchronously against the entries specified by the passed keys.- Type Parameters:
R
- the type of value returned by the EntryAggregator- Parameters:
collKeys
- the Collection of keys that specify the entries within this Map to aggregate acrossaggregator
- the EntryAggregator that is used to aggregate across the specified entries of this Map- Returns:
- a
CompletableFuture
that can be used to obtain the result of the aggregation
-
aggregate
<R> CompletableFuture<R> aggregate(Filter<?> filter, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator)
Perform an aggregating operation asynchronously against the set of entries that are selected by the given Filter.- Type Parameters:
R
- the type of value returned by the EntryAggregator- Parameters:
filter
- the Filter that is used to select entries within this Map to aggregate acrossaggregator
- the EntryAggregator that is used to aggregate across the selected entries of this Map- Returns:
- a
CompletableFuture
that can be used to obtain the result of the aggregation
-
size
default CompletableFuture<Integer> size()
Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.- Returns:
- the number of key-value mappings in this map
-
isEmpty
default CompletableFuture<Boolean> isEmpty()
Returns true if this map contains no key-value mappings.- Returns:
- true if this map contains no key-value mappings
-
clear
default CompletableFuture<Void> clear()
Removes all of the mappings from this map. The map will be empty after this operation completes.
-
containsKey
default CompletableFuture<Boolean> containsKey(K key)
Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)- Parameters:
key
- key whose presence in this map is to be tested- Returns:
- true if this map contains a mapping for the specified key
-
getOrDefault
default CompletableFuture<V> getOrDefault(K key, V valueDefault)
Returns the value to which the specified key is mapped, orvalueDefault
if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returnedvalueDefault
- the default mapping of the key- Returns:
- the value to which the specified key is mapped, or
valueDefault
if this map contains no mapping for the key
-
putIfAbsent
default CompletableFuture<V> putIfAbsent(K key, V value)
If the specified key is not already associated with a value (or is mapped tonull
) associates it with the given value and returnsnull
, else returns the current value.- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- the previous value associated with the specified key, or
null
if there was no mapping for the key. (Anull
return can also indicate that the map previously associatednull
with the key, if the implementation supports null values.)
-
remove
default CompletableFuture<Boolean> remove(K key, V value)
Removes the entry for the specified key only if it is currently mapped to the specified value.- Parameters:
key
- key with which the specified value is associatedvalue
- value expected to be associated with the specified key- Returns:
true
if the value was removed
-
replace
default CompletableFuture<V> replace(K key, V value)
Replaces the entry for the specified key only if it is currently mapped to some value.- Parameters:
key
- key with which the specified value is associatedvalue
- value to be associated with the specified key- Returns:
- the previous value associated with the specified key, or
null
if there was no mapping for the key. (Anull
return can also indicate that the map previously associatednull
with the key, if the implementation supports null values.)
-
replace
default CompletableFuture<Boolean> replace(K key, V oldValue, V newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.- Parameters:
key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keynewValue
- value to be associated with the specified key- Returns:
true
if the value was replaced
-
computeIfAbsent
default CompletableFuture<V> computeIfAbsent(K key, Remote.Function<? super K,? extends V> mappingFunction)
Compute the value using the given mapping function and enter it into this map (unlessnull
), if the specified key is not already associated with a value (or is mapped tonull
).If the mapping function returns
null
no mapping is recorded. If the function itself throws an (unchecked) exception, the exception is rethrown, and no mapping is recorded.The most common usage is to construct a new object serving as an initial mapped value or memoized result, as in:
map.computeIfAbsent(key, k -> new Value(f(k)));
Or to implement a multi-value map,
Map<K, Collection<V>>
, supporting multiple values per key:map.computeIfAbsent(key, k -> new HashSet<V>()).add(v);
add
method will be called on the client-side copy of the collection stored on the server.- Parameters:
key
- key with which the specified value is to be associatedmappingFunction
- the function to compute a value- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
-
computeIfPresent
default CompletableFuture<V> computeIfPresent(K key, Remote.BiFunction<? super K,? super V,? extends V> remappingFunction)
Compute a new mapping given the key and its current mapped value, if the value for the specified key is present and non-null.If the function returns
null
, the mapping is removed. If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.- Parameters:
key
- the key with which the specified value is to be associatedremappingFunction
- the function to compute a value- Returns:
- the new value associated with the specified key, or null if none
-
compute
default CompletableFuture<V> compute(K key, Remote.BiFunction<? super K,? super V,? extends V> remappingFunction)
Compute a new mapping for the specified key and its current value.If the function returns
null
, the mapping is removed (or remains absent if initially absent). If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.- Parameters:
key
- the key with which the computed value is to be associatedremappingFunction
- the function to compute a value- Returns:
- the new value associated with the specified key, or null if none
-
merge
default CompletableFuture<V> merge(K key, V value, Remote.BiFunction<? super V,? super V,? extends V> remappingFunction)
If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value. Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result isnull
.This method may be of use when combining multiple mapped values for a key. For example, to either create or append a
String msg
to a value mapping:map.merge(key, msg, String::concat)
null
the mapping is removed. If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.- Parameters:
key
- key with which the resulting value is to be associatedvalue
- the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the keyremappingFunction
- the function to recompute a value if present- Returns:
- the new value associated with the specified key, or null if no value is associated with the key
-
replaceAll
default CompletableFuture<Map<K,Void>> replaceAll(Remote.BiFunction<? super K,? super V,? extends V> function)
Replace each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.- Parameters:
function
- the function to apply to each entry
-
replaceAll
default CompletableFuture<Map<K,Void>> replaceAll(Collection<? extends K> collKeys, Remote.BiFunction<? super K,? super V,? extends V> function)
Replace each entry's value with the result of invoking the given function on that entry until all entries for the specified key set have been processed or the function throws an exception.- Parameters:
collKeys
- the keys to process; these keys are not required to exist within the Mapfunction
- the function to apply to each entry
-
replaceAll
default CompletableFuture<Map<K,Void>> replaceAll(Filter<?> filter, Remote.BiFunction<? super K,? super V,? extends V> function)
Replace each entry's value with the result of invoking the given function on that entry until all entries selected by the specified filter have been processed or the function throws an exception.- Parameters:
filter
- the filter that should be used to select entriesfunction
- the function to apply to each entry
-
-