org.ehcache.impl.internal.store.disk.factories
Class EhcachePersistentSegmentFactory.EhcachePersistentSegment<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.terracotta.offheapstore.OffHeapHashMap<K,V>
          extended by org.terracotta.offheapstore.AbstractLockedOffHeapHashMap<K,V>
              extended by org.terracotta.offheapstore.AbstractOffHeapClockCache<K,V>
                  extended by org.terracotta.offheapstore.disk.persistent.AbstractPersistentOffHeapCache<K,V>
                      extended by org.terracotta.offheapstore.disk.persistent.PersistentReadWriteLockedOffHeapClockCache<K,V>
                          extended by org.ehcache.impl.internal.store.disk.factories.EhcachePersistentSegmentFactory.EhcachePersistentSegment<K,V>
All Implemented Interfaces:
java.util.concurrent.ConcurrentMap<K,V>, java.util.concurrent.locks.ReadWriteLock, java.util.Map<K,V>, org.terracotta.offheapstore.disk.persistent.Persistent, org.terracotta.offheapstore.MapInternals, org.terracotta.offheapstore.pinning.PinnableCache<K,V>, org.terracotta.offheapstore.pinning.PinnableSegment<K,V>, org.terracotta.offheapstore.Segment<K,V>, org.terracotta.offheapstore.storage.StorageEngine.Owner
Enclosing class:
EhcachePersistentSegmentFactory<K,V>

public static class EhcachePersistentSegmentFactory.EhcachePersistentSegment<K,V>
extends org.terracotta.offheapstore.disk.persistent.PersistentReadWriteLockedOffHeapClockCache<K,V>


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.terracotta.offheapstore.OffHeapHashMap
ENTRY_SIZE, hashtable, hashTablePage, modCount, removedSlots, reprobeLimit, RESERVED_STATUS_BITS, size, STATUS, STATUS_USED, storageEngine, tableSource
 
Method Summary
 V compute(K key, BiFunction<K,V,V> mappingFunction, boolean pin)
          Computes a new mapping for the given key by calling the function passed in.
 boolean computeIfPinned(K key, BiFunction<K,V,V> remappingFunction, Function<V,java.lang.Boolean> flippingPinningBitFunction)
          Computes a new value for the given key if a mapping is present and pinned, BiFunction is invoked under appropriate lock scope The pinning bit from the metadata, will be flipped (i.e.
 V computeIfPresent(K key, BiFunction<K,V,V> mappingFunction)
          Computes a new mapping for the given key only if a mapping existed already by calling the function passed in.
 boolean evict(int index, boolean shrink)
           
protected  boolean evictable(int status)
           
 V put(K key, V value)
           
 V putPinned(K key, V value)
           
 
Methods inherited from class org.terracotta.offheapstore.disk.persistent.PersistentReadWriteLockedOffHeapClockCache
getLock, readLock, writeLock
 
Methods inherited from class org.terracotta.offheapstore.disk.persistent.AbstractPersistentOffHeapCache
bootstrap, close, flush, persist
 
Methods inherited from class org.terracotta.offheapstore.AbstractOffHeapClockCache
getAndPin, getEvictionIndex, hit, isPinned, setPinning, storageEngineFailure, tableExpansionFailure
 
Methods inherited from class org.terracotta.offheapstore.AbstractLockedOffHeapHashMap
clear, containsKey, destroy, entrySet, fill, fill, get, getAndSetMetadata, getEncodingForHashAndBinary, getMetadata, getValueAndSetMetadata, installMappingForHashAndEncoding, keySet, put, putIfAbsent, remove, remove, removeMapping, removeNoReturn, replace, replace, shrink, size, values
 
Methods inherited from class org.terracotta.offheapstore.OffHeapHashMap
added, encodingSet, fill, getAllocatedMemory, getAtTableOffset, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getEntryAtTableOffset, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getSlotForHashAndEncoding, getStorageEngine, getTableCapacity, getUsedSlotCount, getVitalMemory, isAvailable, isPresent, isRemoved, isTerminating, isThiefForTableAllocations, removeAtTableOffset, removed, spread, tryIncreaseReprobe, updated, updateEncoding
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.terracotta.offheapstore.Segment
destroy, fill, fill, getAndSetMetadata, getMetadata, getValueAndSetMetadata, put, removeNoReturn, shrink
 
Methods inherited from interface org.terracotta.offheapstore.MapInternals
getAllocatedMemory, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getTableCapacity, getUsedSlotCount, getVitalMemory
 
Methods inherited from interface java.util.concurrent.ConcurrentMap
putIfAbsent, remove, replace, replace
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values
 

Method Detail

compute

public V compute(K key,
                 BiFunction<K,V,V> mappingFunction,
                 boolean pin)
Computes a new mapping for the given key by calling the function passed in. It will pin the mapping if the flag is true, it will however not unpin an existing pinned mapping in case the function returns the existing value.

Parameters:
key - the key to compute the mapping for
mappingFunction - the function to compute the mapping
pin - pins the mapping if {code true}
Returns:
the mapped value

computeIfPresent

public V computeIfPresent(K key,
                          BiFunction<K,V,V> mappingFunction)
Computes a new mapping for the given key only if a mapping existed already by calling the function passed in.

Parameters:
key - the key to compute the mapping for
mappingFunction - the function to compute the mapping
Returns:
the mapped value

computeIfPinned

public boolean computeIfPinned(K key,
                               BiFunction<K,V,V> remappingFunction,
                               Function<V,java.lang.Boolean> flippingPinningBitFunction)
Computes a new value for the given key if a mapping is present and pinned, BiFunction is invoked under appropriate lock scope The pinning bit from the metadata, will be flipped (i.e. unset) if the Function returns true

Parameters:
key - the key of the mapping to compute the value for
remappingFunction - the function used to compute
flippingPinningBitFunction - evaluated to see whether we want to unpin the mapping
Returns:
true if transitioned to unpinned, false otherwise

put

public V put(K key,
             V value)
Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class org.terracotta.offheapstore.AbstractLockedOffHeapHashMap<K,V>

putPinned

public V putPinned(K key,
                   V value)
Specified by:
putPinned in interface org.terracotta.offheapstore.pinning.PinnableCache<K,V>
Overrides:
putPinned in class org.terracotta.offheapstore.AbstractOffHeapClockCache<K,V>

evictable

protected boolean evictable(int status)
Overrides:
evictable in class org.terracotta.offheapstore.AbstractOffHeapClockCache<K,V>

evict

public boolean evict(int index,
                     boolean shrink)
Specified by:
evict in interface org.terracotta.offheapstore.storage.StorageEngine.Owner
Overrides:
evict in class org.terracotta.offheapstore.AbstractOffHeapClockCache<K,V>