Class ConverterCollections.ConverterInvocableMap<FK,TK,FV,TV>
- All Implemented Interfaces:
InvocableMap<TK,
,TV> Serializable
,Map<TK,
TV>
- Enclosing class:
ConverterCollections
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMap
InvocableMap.Entry<K,
V>, InvocableMap.EntryAggregator<K, V, R>, InvocableMap.EntryProcessor<K, V, R>, InvocableMap.ParallelAwareAggregator<K, V, P, R>, InvocableMap.StreamingAggregator<K, V, P, R> -
Field Summary
Fields inherited from class com.tangosol.util.ConverterCollections.ConverterMap
m_convKeyDown, m_convKeyUp, m_convValDown, m_convValUp, m_map, m_set
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<R> R
aggregate
(Filter filter, InvocableMap.EntryAggregator<? super TK, ? super TV, R> agent) Perform an aggregating operation against the set of entries that are selected by the given Filter.<R> R
aggregate
(Collection<? extends TK> collKeys, InvocableMap.EntryAggregator<? super TK, ? super TV, R> agent) Perform an aggregating operation against the entries specified by the passed keys.protected static Object
convertSafe
(Converter converter, Object oValue) Convert the provided value with the given converter.Return the underlying InvocableMap.<R> R
invoke
(TK key, InvocableMap.EntryProcessor<TK, TV, R> agent) Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.invokeAll
(Filter filter, InvocableMap.EntryProcessor<TK, TV, R> agent) Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.invokeAll
(Collection<? extends TK> collKeys, InvocableMap.EntryProcessor<TK, TV, R> agent) Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value.putIfAbsent
(TK key, TV value) boolean
boolean
Methods inherited from class com.tangosol.util.ConverterCollections.ConverterMap
clear, containsKey, containsValue, entrySet, equals, get, getConverterKeyDown, getConverterKeyUp, getConverterValueDown, getConverterValueUp, getMap, hashCode, instantiateCollection, instantiateEntrySet, instantiateMap, instantiateSet, isEmpty, keySet, put, putAll, remove, size, subMap, toString, values
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.tangosol.util.InvocableMap
aggregate, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getOrDefault, invokeAll, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
-
Constructor Details
-
ConverterInvocableMap
public ConverterInvocableMap(InvocableMap<FK, FV> map, Converter<FK, TK> convKeyUp, Converter<TK, FK> convKeyDown, Converter<FV, TV> convValUp, Converter<TV, FV> convValDown) Constructor.- Parameters:
map
- the underlying InvocableMapconvKeyUp
- the Converter to view the underlying InvocableMap's keys throughconvKeyDown
- the Converter to use to pass keys down to the underlying InvocableMapconvValUp
- the Converter to view the underlying InvocableMap's values throughconvValDown
- the Converter to use to pass values down to the underlying InvocableMap
-
-
Method Details
-
aggregate
public <R> R aggregate(Collection<? extends TK> collKeys, InvocableMap.EntryAggregator<? super TK, ? super TV, R> agent) Perform an aggregating operation against the entries specified by the passed keys.- Specified by:
aggregate
in interfaceInvocableMap<FK,
TK> - 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 acrossagent
- the EntryAggregator that is used to aggregate across the specified entries of this Map- Returns:
- the result of the aggregation
-
aggregate
Perform an aggregating operation against the set of entries that are selected by the given Filter.- Specified by:
aggregate
in interfaceInvocableMap<FK,
TK> - 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 acrossagent
- the EntryAggregator that is used to aggregate across the selected entries of this Map- Returns:
- the result of the aggregation
-
invoke
Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.- Specified by:
invoke
in interfaceInvocableMap<FK,
TK> - 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 Mapagent
- the EntryProcessor to use to process the specified key- Returns:
- the result of the invocation as returned from the EntryProcessor
-
invokeAll
public <R> Map<TK,R> invokeAll(Collection<? extends TK> collKeys, InvocableMap.EntryProcessor<TK, TV, R> agent) Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.- Specified by:
invokeAll
in interfaceInvocableMap<FK,
TK> - 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 Mapagent
- the EntryProcessor to use to process the specified keys- Returns:
- a Map containing the results of invoking the EntryProcessor against each of the specified keys
-
invokeAll
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.Unless specified otherwise, InvocableMap implementations will perform this operation in two steps: (1) use the filter to retrieve a matching entry set; (2) apply the agent to every filtered entry. This algorithm assumes that the agent's processing does not affect the result of the specified filter evaluation, since the filtering and processing could be performed in parallel on different threads. If this assumption does not hold, the processor logic has to be idempotent, or at least re-evaluate the filter. This could be easily accomplished by wrapping the processor with the
ConditionalProcessor
.- Specified by:
invokeAll
in interfaceInvocableMap<FK,
TK> - Type Parameters:
R
- the type of value returned by the EntryProcessor- Parameters:
filter
- a Filter that results in the set of keys to be processedagent
- the EntryProcessor to use to process the specified keys- Returns:
- a Map containing the results of invoking the EntryProcessor against the keys that are selected by the given Filter
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceInvocableMap<FK,
TK> - Specified by:
putIfAbsent
in interfaceMap<FK,
TK>
-
remove
-
replace
-
replace
-
merge
public TV merge(TK key, TV value, Remote.BiFunction<? super TV, ? super TV, ? extends TV> remappingFunction) Description copied from interface:InvocableMap
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.- Specified by:
merge
in interfaceInvocableMap<FK,
TK> - 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
-
merge
-
getInvocableMap
Return the underlying InvocableMap.- Returns:
- the underlying InvocableMap
-
convertSafe
Convert the provided value with the given converter. If there is an issue in type conversion return the given value.- Parameters:
converter
- the converter to useoValue
- the value to convert- Returns:
- a converted value or the original value
-