public class SortedEvictionPolicy<K,V> extends AbstractEvictionPolicy<K,V> implements IgniteMBeanAware
The eviction starts in the following cases:
batchSize elements greater than the maximum size.maxMemSize == 0).
batchSize elements will be evicted in this case. The default batchSize value is 1.
Entries comparison based on Comparator instance if provided.
Default Comparator behaviour is use cache entries keys for comparison that imposes a requirement for keys
to implement Comparable interface.
User defined comparator should implement Serializable interface.
memSize| Constructor and Description |
|---|
SortedEvictionPolicy()
Constructs sorted eviction policy with all defaults.
|
SortedEvictionPolicy(@Nullable Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size and given entry comparator.
|
SortedEvictionPolicy(int max)
Constructs sorted eviction policy with maximum size.
|
SortedEvictionPolicy(int max,
@Nullable Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size and given entry comparator.
|
SortedEvictionPolicy(int max,
int batchSize,
@Nullable Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size, eviction batch size and entries comparator.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getCurrentSize() |
Object |
getMBean() |
Collection<EvictableEntry<K,V>> |
queue()
Gets read-only view of backed queue in proper order.
|
void |
readExternal(ObjectInput in) |
protected boolean |
removeMeta(Object meta)
Removes holder from backed queue and marks holder as removed.
|
SortedEvictionPolicy<K,V> |
setBatchSize(int batchSize)
Sets batch size.
|
SortedEvictionPolicy<K,V> |
setMaxMemorySize(long maxMemSize)
Sets maximum allowed cache size in bytes.
|
SortedEvictionPolicy<K,V> |
setMaxSize(int max)
Sets maximum allowed size of cache before entry will start getting evicted.
|
protected int |
shrink0()
Tries to remove one item from queue.
|
protected boolean |
touch(EvictableEntry<K,V> entry) |
void |
writeExternal(ObjectOutput out) |
getBatchSize, getCurrentMemorySize, getMaxMemorySize, getMaxSize, onEntryAccessed, shrinkpublic SortedEvictionPolicy()
public SortedEvictionPolicy(int max)
max - Maximum allowed size of cache before entry will start getting evicted.public SortedEvictionPolicy(int max,
@Nullable
@Nullable Comparator<EvictableEntry<K,V>> comp)
max - Maximum allowed size of cache before entry will start getting evicted.comp - Entries comparator.public SortedEvictionPolicy(int max,
int batchSize,
@Nullable
@Nullable Comparator<EvictableEntry<K,V>> comp)
max - Maximum allowed size of cache before entry will start getting evicted.batchSize - Batch size.comp - Entries comparator.public SortedEvictionPolicy(@Nullable
@Nullable Comparator<EvictableEntry<K,V>> comp)
comp - Entries comparator.public SortedEvictionPolicy<K,V> setMaxMemorySize(long maxMemSize)
setMaxMemorySize in class AbstractEvictionPolicy<K,V>maxMemSize - Maximum allowed cache size in bytes.this for chaining.public SortedEvictionPolicy<K,V> setMaxSize(int max)
setMaxSize in class AbstractEvictionPolicy<K,V>max - Maximum allowed size of cache before entry will start getting evicted.this for chaining.public SortedEvictionPolicy<K,V> setBatchSize(int batchSize)
setBatchSize in class AbstractEvictionPolicy<K,V>batchSize - Batch size.this for chaining.public Collection<EvictableEntry<K,V>> queue()
protected boolean touch(EvictableEntry<K,V> entry)
touch in class AbstractEvictionPolicy<K,V>entry - Entry to touch.True if backed queue has been changed by this call.public int getCurrentSize()
getCurrentSize in class AbstractEvictionPolicy<K,V>protected int shrink0()
shrink0 in class AbstractEvictionPolicy<K,V>-1 if queue is empty.public Object getMBean()
getMBean in interface IgniteMBeanAwarepublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizablewriteExternal in class AbstractEvictionPolicy<K,V>IOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizablereadExternal in class AbstractEvictionPolicy<K,V>IOExceptionClassNotFoundExceptionprotected boolean removeMeta(Object meta)
removeMeta in class AbstractEvictionPolicy<K,V>meta - Holder.True if meta was successfully removed from the container.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023