Package org.infinispan.container.impl
Class DefaultSegmentedDataContainer<K,V>
- java.lang.Object
-
- org.infinispan.container.impl.AbstractInternalDataContainer<K,V>
-
- org.infinispan.container.impl.DefaultSegmentedDataContainer<K,V>
-
- All Implemented Interfaces:
Iterable<InternalCacheEntry<K,V>>,DataContainer<K,V>,InternalDataContainer<K,V>
- Direct Known Subclasses:
BoundedSegmentedDataContainer,L1SegmentedDataContainer
public class DefaultSegmentedDataContainer<K,V> extends AbstractInternalDataContainer<K,V>
DataContainer implementation that internally stores entries in an array of maps. This array is indexed by the segment that the entries belong to. This provides for much better iteration of entries when a subset of segments are required.This implementation doesn't support bounding or temporary entries (L1).
- Since:
- 9.3
- Author:
- wburns
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
AbstractInternalDataContainer.EntryIterator
-
Nested classes/interfaces inherited from interface org.infinispan.container.DataContainer
DataContainer.ComputeAction<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicReferenceArray<PeekableTouchableMap<K,V>>mapsprotected Supplier<PeekableTouchableMap<K,V>>mapSupplierprotected io.reactivex.rxjava3.functions.Predicate<InternalCacheEntry<K,V>>notExpiredPredicateprotected booleanshouldStopSegments-
Fields inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
configuration, entryFactory, evictionManager, expirationManager, keyPartitioner, listeners, orderer, passivator, timeService
-
-
Constructor Summary
Constructors Constructor Description DefaultSegmentedDataContainer(Supplier<PeekableTouchableMap<K,V>> mapSupplier, int numSegments)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSegments(org.infinispan.commons.util.IntSet segments)Sets what segments this data container should be using.voidclear()Removes all entries in the containervoidforEach(org.infinispan.commons.util.IntSet segments, Consumer<? super InternalCacheEntry<K,V>> action)Performs the given action for each element of the container that maps to the given set of segments until all elements have been processed or the action throws an exception.PeekableTouchableMap<K,V>getMapForSegment(int segment)intgetSegmentForKey(Object key)Iterator<InternalCacheEntry<K,V>>iterator()Iterator<InternalCacheEntry<K,V>>iterator(org.infinispan.commons.util.IntSet segments)Same asDataContainer.iterator()except that only entries that map to the provided segments are returned via the iterator.Iterator<InternalCacheEntry<K,V>>iteratorIncludingExpired()Same asDataContainer.iterator()except that is also returns expired entries.Iterator<InternalCacheEntry<K,V>>iteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)Same asDataContainer.iteratorIncludingExpired()except that only entries that map to the provided segments are returned via the iterator.org.reactivestreams.Publisher<InternalCacheEntry<K,V>>publisher(int segment)voidremoveSegments(org.infinispan.commons.util.IntSet segments)Removes and un-associates the given segments.intsizeIncludingExpired()intsizeIncludingExpired(org.infinispan.commons.util.IntSet segment)Returns how many entries are present in the data container that map to the given segments including any entries that may be expiredSpliterator<InternalCacheEntry<K,V>>spliterator()Spliterator<InternalCacheEntry<K,V>>spliterator(org.infinispan.commons.util.IntSet segments)Same asDataContainer.spliterator()except that only entries that map to the provided segments are returned via this spliterator.Spliterator<InternalCacheEntry<K,V>>spliteratorIncludingExpired()Same asDataContainer.spliterator()except that is also returns expired entries.Spliterator<InternalCacheEntry<K,V>>spliteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)Same asDataContainer.spliteratorIncludingExpired()except that only entries that map to the provided segments are returned via this spliterator.voidstart()voidstop()-
Methods inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
addRemovalListener, applyListener, clear, compute, compute, computeEntryRemoved, computeEntryWritten, containsKey, containsKey, evict, evict, expiredIterationPredicate, filterExpiredEntries, get, get, handleEviction, peek, peek, put, put, remove, remove, removeRemovalListener, touch
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.container.DataContainer
capacity, evictionSize, resize, size
-
Methods inherited from interface org.infinispan.container.impl.InternalDataContainer
cleanUp, size
-
-
-
-
Field Detail
-
maps
protected final AtomicReferenceArray<PeekableTouchableMap<K,V>> maps
-
mapSupplier
protected final Supplier<PeekableTouchableMap<K,V>> mapSupplier
-
shouldStopSegments
protected boolean shouldStopSegments
-
notExpiredPredicate
protected io.reactivex.rxjava3.functions.Predicate<InternalCacheEntry<K,V>> notExpiredPredicate
-
-
Constructor Detail
-
DefaultSegmentedDataContainer
public DefaultSegmentedDataContainer(Supplier<PeekableTouchableMap<K,V>> mapSupplier, int numSegments)
-
-
Method Detail
-
start
public void start()
-
stop
public void stop()
-
getSegmentForKey
public int getSegmentForKey(Object key)
- Specified by:
getSegmentForKeyin classAbstractInternalDataContainer<K,V>
-
getMapForSegment
public PeekableTouchableMap<K,V> getMapForSegment(int segment)
- Specified by:
getMapForSegmentin classAbstractInternalDataContainer<K,V>
-
publisher
public org.reactivestreams.Publisher<InternalCacheEntry<K,V>> publisher(int segment)
-
iterator
public Iterator<InternalCacheEntry<K,V>> iterator(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainerSame asDataContainer.iterator()except that only entries that map to the provided segments are returned via the iterator. The iterator will not return expired entries.- Parameters:
segments- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments
-
iterator
public Iterator<InternalCacheEntry<K,V>> iterator()
Description copied from interface:DataContainerThis iterator only returns entries that are not expired, however it will not remove them while doing so.
- Returns:
- iterator that doesn't produce expired entries
-
spliterator
public Spliterator<InternalCacheEntry<K,V>> spliterator(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainerSame asDataContainer.spliterator()except that only entries that map to the provided segments are returned via this spliterator. The spliterator will not return expired entries.- Parameters:
segments- segments of entries to return- Returns:
- spliterator containing entries mapping to those segments that aren't expired
-
spliterator
public Spliterator<InternalCacheEntry<K,V>> spliterator()
Description copied from interface:DataContainerThis spliterator only returns entries that are not expired, however it will not remove them while doing so.
- Returns:
- spliterator that doesn't produce expired entries
-
iteratorIncludingExpired
public Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainerSame asDataContainer.iteratorIncludingExpired()except that only entries that map to the provided segments are returned via the iterator. The iterator can return expired entries.- Parameters:
segments- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments that could be expired
-
iteratorIncludingExpired
public Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()
Description copied from interface:DataContainerSame asDataContainer.iterator()except that is also returns expired entries.- Returns:
- iterator that returns all entries including expired ones
-
spliteratorIncludingExpired
public Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainerSame asDataContainer.spliteratorIncludingExpired()except that only entries that map to the provided segments are returned via this spliterator. The spliterator will return expired entries as well.- Parameters:
segments- segments of entries to use- Returns:
- spliterator containing entries mapping to those segments that could be expired
-
spliteratorIncludingExpired
public Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired()
Description copied from interface:DataContainerSame asDataContainer.spliterator()except that is also returns expired entries.- Returns:
- spliterator that returns all entries including expired ones
-
sizeIncludingExpired
public int sizeIncludingExpired(org.infinispan.commons.util.IntSet segment)
Description copied from interface:InternalDataContainerReturns how many entries are present in the data container that map to the given segments including any entries that may be expired- Parameters:
segment- segments of entries to count- Returns:
- count of the number of entries in the container including expired entries
-
sizeIncludingExpired
public int sizeIncludingExpired()
- Returns:
- count of the number of entries in the container including expired entries
-
clear
public void clear()
Description copied from interface:DataContainerRemoves all entries in the container
-
forEach
public void forEach(org.infinispan.commons.util.IntSet segments, Consumer<? super InternalCacheEntry<K,V>> action)Description copied from interface:InternalDataContainerPerforms the given action for each element of the container that maps to the given set of segments until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.action- The action to be performed for each element
-
addSegments
public void addSegments(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainerSets what segments this data container should be using. Already associated segments are unaffected by this and takes a union of existing and new segments.- Parameters:
segments- segments to associate with this container
-
removeSegments
public void removeSegments(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainerRemoves and un-associates the given segments. This will notify any listeners registered viaInternalDataContainer.addRemovalListener(Consumer)of entries that were removed due to no longer being associated with this container. There is no guarantee if the consumer is invoked once or multiple times for a given group of segments and could be in any order.When this method is invoked an implementation is free to remove any entries that don't map to segments currently associated with this container. Note that entries that were removed due to their segments never being associated with this container do not notify listeners registered via
InternalDataContainer.addRemovalListener(Consumer).- Parameters:
segments- segments that should no longer be associated with this container
-
-