Class ReadOnlySegmentAwareMap<K,V>
- All Implemented Interfaces:
Map<K,
V>
Any operation that would modify this map will throw an UnsupportedOperationException
This map is useful when you don't want to copy an entire map but only need to see entries from the given segments.
Note many operations are not constant time when using this map. The
values()
method is not supported as well. Please check\
the method you are using to see if it will perform differently than normally expected.
- Since:
- 7.2
- Author:
- wburns
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionReadOnlySegmentAwareMap
(Map<K, V> map, LocalizedCacheTopology topology, IntSet allowedSegments) -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) boolean
containsValue
(Object value) delegate()
entrySet()
boolean
isEmpty()
Checks if the provided map is empty.protected boolean
keyAllowed
(Object key) keySet()
int
size()
Returns the size of the read only map.toString()
values()
NOTE: this method is not supported.Methods inherited from class org.infinispan.commons.util.AbstractDelegatingMap
clear, compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll
-
Field Details
-
map
-
topology
-
allowedSegments
-
segmentAwareKeySet
-
segmentAwareEntrySet
-
-
Constructor Details
-
ReadOnlySegmentAwareMap
public ReadOnlySegmentAwareMap(Map<K, V> map, LocalizedCacheTopology topology, IntSet allowedSegments)
-
-
Method Details
-
delegate
- Specified by:
delegate
in classAbstractDelegatingMap<K,
V>
-
keyAllowed
-
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - Overrides:
containsKey
in classAbstractDelegatingMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V> - Overrides:
containsValue
in classAbstractDelegatingMap<K,
V>
-
get
-
entrySet
-
isEmpty
public boolean isEmpty()Checks if the provided map is empty. This is done by iterating over all of the keys until it can find a key that maps to a given segment.This method should always be preferred over checking the size to see if it is empty.
This time complexity for this method between O(1) to O(N).
-
keySet
-
size
public int size()Returns the size of the read only map. This is done by iterating over all of the keys counting all that are in the segments.If you are using this method to verify if the map is empty, you should instead use the
invalid reference
ReadOnlySegmentAwareEntryMap#isEmpty()
This time complexity for this method is always O(N).
-
values
NOTE: this method is not supported. Due to the nature of this map, we don't want to copy the underlying value collection. Thus almost any operation will require O(N) and therefore this method is not provided. -
toString
-