Package io.debezium.util
Class BoundedConcurrentHashMap.LRU<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<BoundedConcurrentHashMap.HashEntry<K,V>,V>
io.debezium.util.BoundedConcurrentHashMap.LRU<K,V>
- All Implemented Interfaces:
BoundedConcurrentHashMap.EvictionPolicy<K,
,V> Serializable
,Cloneable
,Map<BoundedConcurrentHashMap.HashEntry<K,
V>, V>
- Enclosing class:
- BoundedConcurrentHashMap<K,
V>
static final class BoundedConcurrentHashMap.LRU<K,V>
extends LinkedHashMap<BoundedConcurrentHashMap.HashEntry<K,V>,V>
implements BoundedConcurrentHashMap.EvictionPolicy<K,V>
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
Modifier and TypeFieldDescriptionprivate final ConcurrentLinkedQueue<BoundedConcurrentHashMap.HashEntry<K,
V>> private final float
private final Set<BoundedConcurrentHashMap.HashEntry<K,
V>> private final int
private final BoundedConcurrentHashMap.Segment<K,
V> private static final long
The serialVersionUIDprivate final int
Fields inherited from interface io.debezium.util.BoundedConcurrentHashMap.EvictionPolicy
MAX_BATCH_SIZE
-
Constructor Summary
ConstructorDescriptionLRU
(BoundedConcurrentHashMap.Segment<K, V> s, int capacity, float lf, int maxBatchSize, float batchThresholdFactor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Invoked to notify EvictionPolicy implementation that all Segment entries have been cleared.createNewEntry
(K key, int hash, BoundedConcurrentHashMap.HashEntry<K, V> next, V value) execute()
Invokes eviction policy algorithm and returns set of evicted entries.protected boolean
boolean
Invoked to notify EvictionPolicy implementation that an entry in Segment has been accessed.Invoked to notify EvictionPolicy implementation that there has been an attempt to access an entry in Segment, however that entry was not present in Segment.void
Invoked to notify EvictionPolicy implementation that an entry e has been removed from Segment.protected boolean
strategy()
Returns type of eviction algorithm (strategy).boolean
Returns true if batching threshold has expired, false otherwise.Methods inherited from class java.util.LinkedHashMap
containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDThe serialVersionUID- See Also:
-
accessQueue
-
segment
-
maxBatchQueueSize
private final int maxBatchQueueSize -
trimDownSize
private final int trimDownSize -
batchThresholdFactor
private final float batchThresholdFactor -
evicted
-
-
Constructor Details
-
LRU
public LRU(BoundedConcurrentHashMap.Segment<K, V> s, int capacity, float lf, int maxBatchSize, float batchThresholdFactor)
-
-
Method Details
-
execute
Description copied from interface:BoundedConcurrentHashMap.EvictionPolicy
Invokes eviction policy algorithm and returns set of evicted entries. Set cannot be null but could possibly be an empty set.- Specified by:
execute
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V> - Returns:
- set of evicted entries.
-
onEntryMiss
public Set<BoundedConcurrentHashMap.HashEntry<K,V>> onEntryMiss(BoundedConcurrentHashMap.HashEntry<K, V> e) Description copied from interface:BoundedConcurrentHashMap.EvictionPolicy
Invoked to notify EvictionPolicy implementation that there has been an attempt to access an entry in Segment, however that entry was not present in Segment.- Specified by:
onEntryMiss
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V> - Parameters:
e
- accessed entry in Segment- Returns:
- non null set of evicted entries.
-
onEntryHit
Description copied from interface:BoundedConcurrentHashMap.EvictionPolicy
Invoked to notify EvictionPolicy implementation that an entry in Segment has been accessed. Returns true if batching threshold has been reached, false otherwise. Note that this method is potentially invoked without holding a lock on Segment.- Specified by:
onEntryHit
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V> - Parameters:
e
- accessed entry in Segment- Returns:
- true if batching threshold has been reached, false otherwise.
-
thresholdExpired
public boolean thresholdExpired()Description copied from interface:BoundedConcurrentHashMap.EvictionPolicy
Returns true if batching threshold has expired, false otherwise. Note that this method is potentially invoked without holding a lock on Segment.- Specified by:
thresholdExpired
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V> - Returns:
- true if batching threshold has expired, false otherwise.
-
onEntryRemove
Description copied from interface:BoundedConcurrentHashMap.EvictionPolicy
Invoked to notify EvictionPolicy implementation that an entry e has been removed from Segment.- Specified by:
onEntryRemove
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V> - Parameters:
e
- removed entry in Segment
-
clear
public void clear()Description copied from interface:BoundedConcurrentHashMap.EvictionPolicy
Invoked to notify EvictionPolicy implementation that all Segment entries have been cleared.- Specified by:
clear
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V> - Specified by:
clear
in interfaceMap<K,
V> - Overrides:
clear
in classLinkedHashMap<BoundedConcurrentHashMap.HashEntry<K,
V>, V>
-
strategy
Description copied from interface:BoundedConcurrentHashMap.EvictionPolicy
Returns type of eviction algorithm (strategy).- Specified by:
strategy
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V> - Returns:
- type of eviction algorithm
-
isAboveThreshold
protected boolean isAboveThreshold() -
removeEldestEntry
- Overrides:
removeEldestEntry
in classLinkedHashMap<BoundedConcurrentHashMap.HashEntry<K,
V>, V>
-
createNewEntry
public BoundedConcurrentHashMap.HashEntry<K,V> createNewEntry(K key, int hash, BoundedConcurrentHashMap.HashEntry<K, V> next, V value) - Specified by:
createNewEntry
in interfaceBoundedConcurrentHashMap.EvictionPolicy<K,
V>
-