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
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentLinkedQueue<BoundedConcurrentHashMap.HashEntry<K,V>> private final floatprivate final Set<BoundedConcurrentHashMap.HashEntry<K,V>> private final intprivate final BoundedConcurrentHashMap.Segment<K,V> private static final longThe serialVersionUIDprivate final intFields inherited from interface io.debezium.util.BoundedConcurrentHashMap.EvictionPolicy
MAX_BATCH_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionLRU(BoundedConcurrentHashMap.Segment<K, V> s, int capacity, float lf, int maxBatchSize, float batchThresholdFactor) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()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 booleanbooleanInvoked 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.voidInvoked to notify EvictionPolicy implementation that an entry e has been removed from Segment.protected booleanstrategy()Returns type of eviction algorithm (strategy).booleanReturns true if batching threshold has expired, false otherwise.Methods inherited from class java.util.LinkedHashMap
containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class java.util.AbstractMap
equals, hashCode, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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.EvictionPolicyInvokes eviction policy algorithm and returns set of evicted entries. Set cannot be null but could possibly be an empty set.- Specified by:
executein 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.EvictionPolicyInvoked 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:
onEntryMissin interfaceBoundedConcurrentHashMap.EvictionPolicy<K,V> - Parameters:
e- accessed entry in Segment- Returns:
- non null set of evicted entries.
-
onEntryHit
Description copied from interface:BoundedConcurrentHashMap.EvictionPolicyInvoked 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:
onEntryHitin 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.EvictionPolicyReturns true if batching threshold has expired, false otherwise. Note that this method is potentially invoked without holding a lock on Segment.- Specified by:
thresholdExpiredin interfaceBoundedConcurrentHashMap.EvictionPolicy<K,V> - Returns:
- true if batching threshold has expired, false otherwise.
-
onEntryRemove
Description copied from interface:BoundedConcurrentHashMap.EvictionPolicyInvoked to notify EvictionPolicy implementation that an entry e has been removed from Segment.- Specified by:
onEntryRemovein interfaceBoundedConcurrentHashMap.EvictionPolicy<K,V> - Parameters:
e- removed entry in Segment
-
clear
public void clear()Description copied from interface:BoundedConcurrentHashMap.EvictionPolicyInvoked to notify EvictionPolicy implementation that all Segment entries have been cleared.- Specified by:
clearin interfaceBoundedConcurrentHashMap.EvictionPolicy<K,V> - Specified by:
clearin interfaceMap<K,V> - Overrides:
clearin classLinkedHashMap<BoundedConcurrentHashMap.HashEntry<K,V>, V>
-
strategy
Description copied from interface:BoundedConcurrentHashMap.EvictionPolicyReturns type of eviction algorithm (strategy).- Specified by:
strategyin interfaceBoundedConcurrentHashMap.EvictionPolicy<K,V> - Returns:
- type of eviction algorithm
-
isAboveThreshold
protected boolean isAboveThreshold() -
removeEldestEntry
- Overrides:
removeEldestEntryin 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:
createNewEntryin interfaceBoundedConcurrentHashMap.EvictionPolicy<K,V>
-