public static class ConverterCollections.ConverterNamedCache<FK,TK,FV,TV> extends ConverterCollections.ConverterCacheMap<FK,TK,FV,TV> implements NamedCache<TK,TV>, Serializable
NamedCache.Option
QueryMap.Entry<K,V>
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>
Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<TK,TV> |
m_mapConcurrent
A Converter ConcurrentMap around the underlying NamedCache.
|
protected InvocableMap<TK,TV> |
m_mapInvocable
A Converter InvocableMap around the underlying NamedCache.
|
protected QueryMap<TK,TV> |
m_mapQuery
A Converter QueryMap around the underlying NamedCache.
|
m_convKeyDown, m_convKeyUp, m_convValDown, m_convValUp, m_map, m_set
EXPIRY_DEFAULT, EXPIRY_NEVER
LOCK_ALL
Constructor and Description |
---|
ConverterNamedCache(NamedCache<FK,FV> cache,
Converter<FK,TK> convKeyUp,
Converter<TK,FK> convKeyDown,
Converter<FV,TV> convValUp,
Converter<TV,FV> convValDown)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<T,E> void |
addIndex(ValueExtractor<? super T,? extends E> extractor,
boolean fOrdered,
Comparator<? super E> comparator)
Add an index to this QueryMap.
|
<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.
|
<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.
|
void |
destroy()
Release and destroy this instance of NamedCollection.
|
Set<Map.Entry<TK,TV>> |
entrySet(Filter filter)
Return a set view of the entries contained in this map that satisfy the
criteria expressed by the filter.
|
Set<Map.Entry<TK,TV>> |
entrySet(Filter filter,
Comparator comparator)
Return a set view of the entries contained in this map that satisfy the
criteria expressed by the filter.
|
String |
getCacheName()
Return the cache name.
|
CacheService |
getCacheService()
Return the CacheService that this NamedCache is a part of.
|
NamedCache<FK,FV> |
getNamedCache()
Return the underlying NamedCache.
|
<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.
|
<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.
|
<R> Map<TK,R> |
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.
|
boolean |
isActive()
Specifies whether or not the Releasable is active.
|
boolean |
isDestroyed()
Specifies whether or not the NamedCache has been destroyed.
|
boolean |
isReleased()
Specifies whether or not the NamedCache has been released.
|
Set<TK> |
keySet(Filter filter)
Return a set view of the keys contained in this map for entries that
satisfy the criteria expressed by the filter.
|
boolean |
lock(Object oKey)
Attempt to lock the specified item and return immediately.
|
boolean |
lock(Object oKey,
long cWait)
Attempt to lock the specified item within the specified period of time.
|
TV |
merge(TK key,
TV value,
BiFunction<? super TV,? super TV,? extends TV> remappingFunction) |
TV |
merge(TK key,
TV value,
Remote.BiFunction<? super TV,? super TV,? extends TV> 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.
|
TV |
putIfAbsent(TK key,
TV value) |
void |
release()
Release local resources associated with this Releasable instance.
|
boolean |
remove(Object key,
Object value) |
<T,E> void |
removeIndex(ValueExtractor<? super T,? extends E> extractor)
Remove an index from this QueryMap.
|
TV |
replace(TK key,
TV value) |
boolean |
replace(TK key,
TV oldValue,
TV newValue) |
void |
truncate()
Removes all mappings from this map.
|
boolean |
unlock(Object oKey)
Unlock the specified item.
|
getAll, getCacheMap, put
addMapListener, addMapListener, addMapListener, getConverterListener, getObservableMap, removeMapListener, removeMapListener, removeMapListener
clear, containsKey, containsValue, entrySet, equals, get, getConverterKeyDown, getConverterKeyUp, getConverterValueDown, getConverterValueUp, getMap, hashCode, instantiateCollection, instantiateEntrySet, instantiateMap, instantiateSet, isEmpty, keySet, put, putAll, remove, size, toString, values
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
as, async, async, clear, getName, getService, put, view
close
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, putAll, remove, replaceAll, size, values
containsKey, containsValue, get, isEmpty, put, putAll, remove, size
aggregate, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getOrDefault, invokeAll, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
protected ConcurrentMap<TK,TV> m_mapConcurrent
protected InvocableMap<TK,TV> m_mapInvocable
public ConverterNamedCache(NamedCache<FK,FV> cache, Converter<FK,TK> convKeyUp, Converter<TK,FK> convKeyDown, Converter<FV,TV> convValUp, Converter<TV,FV> convValDown)
cache
- the underlying NamedCacheconvKeyUp
- the Converter to view the underlying
NamedCache's keys throughconvKeyDown
- the Converter to use to pass keys down to the
underlying NamedCacheconvValUp
- the Converter to view the underlying
NamedCache's values throughconvValDown
- the Converter to use to pass values down to the
underlying NamedCachepublic String getCacheName()
getCacheName
in interface NamedCache<TK,TV>
public CacheService getCacheService()
getCacheService
in interface NamedCache<TK,TV>
public boolean isActive()
isActive
in interface Releasable
public void release()
release
in interface Releasable
public void destroy()
Warning: This method is used to completely destroy the specified collection across the cluster. All references in the entire cluster to this collection will be invalidated, the collection data will be cleared, and all internal resources will be released.
destroy
in interface NamedCollection
public void truncate()
Note: the removal of entries caused by this truncate operation will
not be observable. This includes any registered listeners
, triggers
, or interceptors
. However, a
CacheLifecycleEvent
is raised to notify subscribers of the execution of this operation.
truncate
in interface NamedCache<TK,TV>
public boolean isDestroyed()
isDestroyed
in interface NamedCache<TK,TV>
public boolean isReleased()
isReleased
in interface NamedCache<TK,TV>
public boolean lock(Object oKey, long cWait)
The item doesn't have to exist to be locked. While the item is locked there is known to be a lock holder which has an exclusive right to modify (calling put and remove methods) that item.
Lock holder is an abstract concept that depends on the ConcurrentMap implementation. For example, holder could be a cluster member or a thread (or both).
Locking strategy may vary for concrete implementations as well. Lock could have an expiration time (this lock is sometimes called a "lease") or be held indefinitely (until the lock holder terminates).
Some implementations may allow the entire map to be locked. If the map is
locked in such a way, then only a lock holder is allowed to perform
any of the "put" or "remove" operations.
Pass the special constant ConcurrentMap.LOCK_ALL
as the oKey parameter
to indicate the map lock.
lock
in interface ConcurrentMap<TK,TV>
oKey
- key being lockedcWait
- the number of milliseconds to continue trying to obtain
a lock; pass zero to return immediately; pass -1 to block
the calling thread until the lock could be obtainedpublic boolean lock(Object oKey)
This method behaves exactly as if it simply performs the call lock(oKey, 0).
lock
in interface ConcurrentMap<TK,TV>
oKey
- key being lockedpublic boolean unlock(Object oKey)
unlock
in interface ConcurrentMap<TK,TV>
oKey
- key being unlockedpublic <R> R invoke(TK key, InvocableMap.EntryProcessor<TK,TV,R> agent)
invoke
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryProcessorkey
- the key to process; it is not required to exist within
the Mapagent
- the EntryProcessor to use to process the specified keypublic <R> Map<TK,R> invokeAll(Collection<? extends TK> collKeys, InvocableMap.EntryProcessor<TK,TV,R> agent)
invokeAll
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryProcessorcollKeys
- the keys to process; these keys are not required to
exist within the Mapagent
- the EntryProcessor to use to process the specified keyspublic <R> Map<TK,R> invokeAll(Filter filter, InvocableMap.EntryProcessor<TK,TV,R> agent)
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
.
invokeAll
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryProcessorfilter
- a Filter that results in the set of keys to be
processedagent
- the EntryProcessor to use to process the specified keyspublic <R> R aggregate(Collection<? extends TK> collKeys, InvocableMap.EntryAggregator<? super TK,? super TV,R> agent)
aggregate
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryAggregatorcollKeys
- 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 Mappublic <R> R aggregate(Filter filter, InvocableMap.EntryAggregator<? super TK,? super TV,R> agent)
aggregate
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryAggregatorfilter
- 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 Mappublic Set<TK> keySet(Filter filter)
Unlike the Map.keySet()
method, the set returned by this method may
not be backed by the map, so changes to the set may not reflected in the
map, and vice-versa.
Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.
public Set<Map.Entry<TK,TV>> entrySet(Filter filter)
Map.Entry
.
Unlike the Map.entrySet()
method, the set returned by this method
may not be backed by the map, so changes to the set may not be reflected
in the map, and vice-versa.
Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.
public Set<Map.Entry<TK,TV>> entrySet(Filter filter, Comparator comparator)
Map.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 (see Comparable
).
Unlike the Map.entrySet()
method, the set returned by this method
may not be backed by the map, so changes to the set may not be reflected
in the map, and vice-versa.
Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.
entrySet
in interface QueryMap<TK,TV>
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 usedChainedComparator
public <T,E> void addIndex(ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)
The ordering maintained by this map (as determined by either the
specified Comparator or the natural ordering of the indexed values) must
be consistent with equals (see Comparable
or Comparator
for a precise definition of consistent with equals.)
This method is only intended as a hint to the cache implementation, and as such it may be ignored by the cache if indexes are not supported or if the desired index (or a similar index) already exists. It is expected that an application will call this method to suggest an index even if the index may already exist, just so that the application is certain that index has been suggested. For example in a distributed environment, each server will likely suggest the same set of indexes when it starts, and there is no downside to the application blindly requesting those indexes regardless of whether another server has already requested the same indexes.
Note: Indexes are a feature of Coherence Enterprise Edition and Coherence Grid Edition. This method will have no effect when using Coherence Standard Edition.
addIndex
in interface QueryMap<TK,TV>
T
- the type of the value to extract fromE
- the type of value that will be extractedextractor
- the ValueExtractor object that is used to extract an
indexable Object from a value stored in the indexed
Map. Must not be null.fOrdered
- true iff the contents of the indexed information should
be ordered; false otherwisecomparator
- the Comparator object which imposes an ordering on
entries in the indexed map; or null if the
entries' values natural ordering should be usedReflectionExtractor
,
ChainedComparator
public <T,E> void removeIndex(ValueExtractor<? super T,? extends E> extractor)
removeIndex
in interface QueryMap<TK,TV>
T
- the type of the value to extract fromE
- the type of value that will be extractedextractor
- the ValueExtractor object that is used to extract an
indexable Object from a value stored in the Map.public TV putIfAbsent(TK key, TV value)
putIfAbsent
in interface InvocableMap<TK,TV>
putIfAbsent
in interface Map<TK,TV>
public TV merge(TK key, TV value, Remote.BiFunction<? super TV,? super TV,? extends TV> remappingFunction)
InvocableMap
null
.
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)
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.merge
in interface InvocableMap<TK,TV>
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 presentpublic TV merge(TK key, TV value, BiFunction<? super TV,? super TV,? extends TV> remappingFunction)
public NamedCache<FK,FV> getNamedCache()