org.terracotta.offheapstore
Class AbstractLockedOffHeapHashMap<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>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values
All Implemented Interfaces:
ConcurrentMap<K,V>, ReadWriteLock, Map<K,V>, MapInternals, Segment<K,V>, StorageEngine.Owner
Direct Known Subclasses:
AbstractOffHeapClockCache, AbstractPersistentLockedOffHeapHashMap, ReadWriteLockedOffHeapHashMap, WriteLockedOffHeapHashMap

public abstract class AbstractLockedOffHeapHashMap<K,V>
extends OffHeapHashMap<K,V>
implements Segment<K,V>

An abstract locked off-heap map.

Subclasses must implement the readLock() and writeLock() methods such that they return the correct locks under which read and write operations must occur.

Author:
Chris Dennis

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
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
 
Constructor Summary
AbstractLockedOffHeapHashMap(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine)
           
AbstractLockedOffHeapHashMap(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine, int tableSize)
           
AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine)
           
AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, boolean bootstrap)
           
AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize)
           
AbstractLockedOffHeapHashMap(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize, boolean bootstrap)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 void destroy()
           
 Set<Map.Entry<K,V>> entrySet()
           
 boolean evict(int index, boolean shrink)
           
 V fill(K key, V value)
          Associates the specified value with the specified key in this map.
 V fill(K key, V value, int metadata)
           
 V get(Object key)
           
 V getAndSetMetadata(K key, int mask, int metadata)
           
 Long getEncodingForHashAndBinary(int hash, ByteBuffer binaryKey)
           
 long installMappingForHashAndEncoding(int pojoHash, ByteBuffer offheapBinaryKey, ByteBuffer offheapBinaryValue, int metadata)
           
 Set<K> keySet()
           
 V put(K key, V value)
           
 V put(K key, V value, int metadata)
           
 V putIfAbsent(K key, V value)
           
abstract  Lock readLock()
           
 V remove(Object key)
           
 boolean remove(Object key, Object value)
           
protected  boolean removeMapping(Object o)
           
 boolean removeNoReturn(Object key)
           
 V replace(K key, V value)
           
 boolean replace(K key, V oldValue, V newValue)
           
 boolean setMetadata(K key, int writeMask, int metadata)
           
 boolean shrink()
           
 int size()
           
 Collection<V> values()
           
abstract  Lock writeLock()
           
 
Methods inherited from class org.terracotta.offheapstore.OffHeapHashMap
added, encodingSet, fill, getAllocatedMemory, getAtTableOffset, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getEntryAtTableOffset, getMetadata, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getSlotForHashAndEncoding, getStorageEngine, getTableCapacity, getUsedSlotCount, getVitalMemory, hit, isAvailable, isPresent, isRemoved, isTerminating, isThiefForTableAllocations, removeAtTableOffset, removed, spread, storageEngineFailure, tableExpansionFailure, tryIncreaseReprobe, updated, updateEncoding, updateMetadata
 
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
getLock
 
Methods inherited from interface java.util.Map
containsValue, equals, hashCode, isEmpty, putAll
 
Methods inherited from interface org.terracotta.offheapstore.MapInternals
getAllocatedMemory, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getTableCapacity, getUsedSlotCount, getVitalMemory
 

Constructor Detail

AbstractLockedOffHeapHashMap

public AbstractLockedOffHeapHashMap(PageSource source,
                                    StorageEngine<? super K,? super V> storageEngine)

AbstractLockedOffHeapHashMap

public AbstractLockedOffHeapHashMap(PageSource source,
                                    boolean tableAllocationsSteal,
                                    StorageEngine<? super K,? super V> storageEngine)

AbstractLockedOffHeapHashMap

public AbstractLockedOffHeapHashMap(PageSource source,
                                    StorageEngine<? super K,? super V> storageEngine,
                                    boolean bootstrap)

AbstractLockedOffHeapHashMap

public AbstractLockedOffHeapHashMap(PageSource source,
                                    StorageEngine<? super K,? super V> storageEngine,
                                    int tableSize)

AbstractLockedOffHeapHashMap

public AbstractLockedOffHeapHashMap(PageSource source,
                                    boolean tableAllocationsSteal,
                                    StorageEngine<? super K,? super V> storageEngine,
                                    int tableSize)

AbstractLockedOffHeapHashMap

public AbstractLockedOffHeapHashMap(PageSource source,
                                    StorageEngine<? super K,? super V> storageEngine,
                                    int tableSize,
                                    boolean bootstrap)
Method Detail

size

public int size()
Specified by:
size in interface Map<K,V>
Overrides:
size in class OffHeapHashMap<K,V>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class OffHeapHashMap<K,V>

get

public V get(Object key)
Specified by:
get in interface Map<K,V>
Overrides:
get in class OffHeapHashMap<K,V>

getEncodingForHashAndBinary

public Long getEncodingForHashAndBinary(int hash,
                                        ByteBuffer binaryKey)
Specified by:
getEncodingForHashAndBinary in interface StorageEngine.Owner
Overrides:
getEncodingForHashAndBinary in class OffHeapHashMap<K,V>

installMappingForHashAndEncoding

public long installMappingForHashAndEncoding(int pojoHash,
                                             ByteBuffer offheapBinaryKey,
                                             ByteBuffer offheapBinaryValue,
                                             int metadata)
Specified by:
installMappingForHashAndEncoding in interface StorageEngine.Owner
Overrides:
installMappingForHashAndEncoding in class OffHeapHashMap<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Overrides:
put in class OffHeapHashMap<K,V>

put

public V put(K key,
             V value,
             int metadata)
Specified by:
put in interface Segment<K,V>
Overrides:
put in class OffHeapHashMap<K,V>

fill

public V fill(K key,
              V value)
Description copied from class: OffHeapHashMap
Associates the specified value with the specified key in this map. If the map does not contain a mapping for the key, the new mapping is only installed if there is room. If the map previously contained a mapping for the key, the old value is replaced by the specified value even if this results in a failure or eviction.

Specified by:
fill in interface Segment<K,V>
Overrides:
fill in class OffHeapHashMap<K,V>
Parameters:
key - key with which the specified value is to be associated
value - value to be associated with the specified key
Returns:
the previous value associated with key, or null if there was no mapping for key (irrespective of whether the value was successfully installed).

fill

public V fill(K key,
              V value,
              int metadata)
Specified by:
fill in interface Segment<K,V>
Overrides:
fill in class OffHeapHashMap<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class OffHeapHashMap<K,V>

removeNoReturn

public boolean removeNoReturn(Object key)
Specified by:
removeNoReturn in interface Segment<K,V>
Overrides:
removeNoReturn in class OffHeapHashMap<K,V>

clear

public void clear()
Specified by:
clear in interface Map<K,V>
Overrides:
clear in class OffHeapHashMap<K,V>

putIfAbsent

public V putIfAbsent(K key,
                     V value)
Specified by:
putIfAbsent in interface ConcurrentMap<K,V>

remove

public boolean remove(Object key,
                      Object value)
Specified by:
remove in interface ConcurrentMap<K,V>

replace

public boolean replace(K key,
                       V oldValue,
                       V newValue)
Specified by:
replace in interface ConcurrentMap<K,V>

replace

public V replace(K key,
                 V value)
Specified by:
replace in interface ConcurrentMap<K,V>

setMetadata

public boolean setMetadata(K key,
                           int writeMask,
                           int metadata)
Specified by:
setMetadata in interface Segment<K,V>

getAndSetMetadata

public V getAndSetMetadata(K key,
                           int mask,
                           int metadata)
Specified by:
getAndSetMetadata in interface Segment<K,V>

removeMapping

protected boolean removeMapping(Object o)
Overrides:
removeMapping in class OffHeapHashMap<K,V>

evict

public boolean evict(int index,
                     boolean shrink)
Specified by:
evict in interface StorageEngine.Owner
Overrides:
evict in class OffHeapHashMap<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Overrides:
entrySet in class OffHeapHashMap<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class OffHeapHashMap<K,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>
Overrides:
values in class AbstractMap<K,V>

destroy

public void destroy()
Specified by:
destroy in interface Segment<K,V>
Overrides:
destroy in class OffHeapHashMap<K,V>

shrink

public boolean shrink()
Specified by:
shrink in interface Segment<K,V>

readLock

public abstract Lock readLock()
Specified by:
readLock in interface ReadWriteLock
Overrides:
readLock in class OffHeapHashMap<K,V>

writeLock

public abstract Lock writeLock()
Specified by:
writeLock in interface ReadWriteLock
Overrides:
writeLock in class OffHeapHashMap<K,V>


Copyright © 2015. All Rights Reserved.