Class OffHeapBufferHalfStorageEngine<T>
- java.lang.Object
-
- org.terracotta.offheapstore.storage.PortabilityBasedHalfStorageEngine<T>
-
- org.terracotta.offheapstore.storage.OffHeapBufferHalfStorageEngine<T>
-
- All Implemented Interfaces:
OffHeapStorageArea.Owner,HalfStorageEngine<T>
public class OffHeapBufferHalfStorageEngine<T> extends PortabilityBasedHalfStorageEngine<T> implements OffHeapStorageArea.Owner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.terracotta.offheapstore.storage.PortabilityBasedHalfStorageEngine
PortabilityBasedHalfStorageEngine.CachedEncode<T>
-
-
Field Summary
Fields Modifier and Type Field Description private static intDATA_OFFSETprivate static intHEADER_LENGTHprivate static intKEY_HASH_OFFSETprivate static intLENGTH_OFFSETprivate longmaskprivate StorageEngine.Ownerownerprivate OffHeapStorageAreastorageArea
-
Constructor Summary
Constructors Constructor Description OffHeapBufferHalfStorageEngine(PageSource source, int initialPageSize, int maximalPageSize, Portability<? super T> portability, boolean thief, boolean victim)OffHeapBufferHalfStorageEngine(PageSource source, int pageSize, Portability<? super T> portability)OffHeapBufferHalfStorageEngine(PageSource source, int pageSize, Portability<? super T> portability, boolean thief, boolean victim)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(StorageEngine.Owner o, long m)voidclear()Called to indicate that all keys and values are now free.static <T> Factory<OffHeapBufferHalfStorageEngine<T>>createFactory(PageSource source, int initialPageSize, int maximalPageSize, Portability<? super T> portability, boolean thief, boolean victim)static <T> Factory<OffHeapBufferHalfStorageEngine<T>>createFactory(PageSource source, int pageSize, Portability<? super T> portability)static <T> Factory<OffHeapBufferHalfStorageEngine<T>>createFactory(PageSource source, int pageSize, Portability<? super T> portability, boolean thief, boolean victim)voiddestroy()java.util.Collection<java.lang.Long>evictAtAddress(long address, boolean shrink)voidfree(int address)Called to indicate that the associated encoded value is no longer needed.longgetAllocatedMemory()Returns a measure of the amount of memory allocated for this storage engine.longgetDataSize()Returns a measure of the total size of the keys and values stored in this storage engine.longgetOccupiedMemory()Returns a measure of the amount of memory consumed by this storage engine.longgetVitalMemory()Returns a measure of the amount of vital memory allocated for this storage engine.booleanisThief()booleanmoved(long from, long to)protected java.nio.ByteBufferreadBuffer(int address)booleanshrink()intsizeOf(long address)java.lang.StringtoString()protected java.lang.IntegerwriteBuffer(java.nio.ByteBuffer buffer, int hash)java.util.concurrent.locks.LockwriteLock()-
Methods inherited from class org.terracotta.offheapstore.storage.PortabilityBasedHalfStorageEngine
equals, invalidateCache, read, write
-
-
-
-
Field Detail
-
KEY_HASH_OFFSET
private static final int KEY_HASH_OFFSET
- See Also:
- Constant Field Values
-
LENGTH_OFFSET
private static final int LENGTH_OFFSET
- See Also:
- Constant Field Values
-
DATA_OFFSET
private static final int DATA_OFFSET
- See Also:
- Constant Field Values
-
HEADER_LENGTH
private static final int HEADER_LENGTH
- See Also:
- Constant Field Values
-
owner
private volatile StorageEngine.Owner owner
-
mask
private volatile long mask
-
storageArea
private final OffHeapStorageArea storageArea
-
-
Constructor Detail
-
OffHeapBufferHalfStorageEngine
public OffHeapBufferHalfStorageEngine(PageSource source, int pageSize, Portability<? super T> portability)
-
OffHeapBufferHalfStorageEngine
public OffHeapBufferHalfStorageEngine(PageSource source, int pageSize, Portability<? super T> portability, boolean thief, boolean victim)
-
OffHeapBufferHalfStorageEngine
public OffHeapBufferHalfStorageEngine(PageSource source, int initialPageSize, int maximalPageSize, Portability<? super T> portability, boolean thief, boolean victim)
-
-
Method Detail
-
createFactory
public static <T> Factory<OffHeapBufferHalfStorageEngine<T>> createFactory(PageSource source, int pageSize, Portability<? super T> portability)
-
createFactory
public static <T> Factory<OffHeapBufferHalfStorageEngine<T>> createFactory(PageSource source, int pageSize, Portability<? super T> portability, boolean thief, boolean victim)
-
createFactory
public static <T> Factory<OffHeapBufferHalfStorageEngine<T>> createFactory(PageSource source, int initialPageSize, int maximalPageSize, Portability<? super T> portability, boolean thief, boolean victim)
-
clear
public void clear()
Description copied from interface:HalfStorageEngineCalled to indicate that all keys and values are now free.- Specified by:
clearin interfaceHalfStorageEngine<T>
-
free
public void free(int address)
Description copied from interface:HalfStorageEngineCalled to indicate that the associated encoded value is no longer needed.This call can be used to free any associated resources tied to the lifecycle of the supplied encoded value.
- Specified by:
freein interfaceHalfStorageEngine<T>- Specified by:
freein classPortabilityBasedHalfStorageEngine<T>- Parameters:
address- encoded value
-
readBuffer
protected java.nio.ByteBuffer readBuffer(int address)
- Specified by:
readBufferin classPortabilityBasedHalfStorageEngine<T>
-
writeBuffer
protected java.lang.Integer writeBuffer(java.nio.ByteBuffer buffer, int hash)- Specified by:
writeBufferin classPortabilityBasedHalfStorageEngine<T>
-
getAllocatedMemory
public long getAllocatedMemory()
Description copied from interface:HalfStorageEngineReturns a measure of the amount of memory allocated for this storage engine.- Specified by:
getAllocatedMemoryin interfaceHalfStorageEngine<T>- Returns:
- memory allocated for this engine in bytes
-
getOccupiedMemory
public long getOccupiedMemory()
Description copied from interface:HalfStorageEngineReturns a measure of the amount of memory consumed by this storage engine.- Specified by:
getOccupiedMemoryin interfaceHalfStorageEngine<T>- Returns:
- memory occupied by this engine in bytes
-
getVitalMemory
public long getVitalMemory()
Description copied from interface:HalfStorageEngineReturns a measure of the amount of vital memory allocated for this storage engine.- Specified by:
getVitalMemoryin interfaceHalfStorageEngine<T>- Returns:
- vital memory allocated for this engine in bytes
-
getDataSize
public long getDataSize()
Description copied from interface:HalfStorageEngineReturns a measure of the total size of the keys and values stored in this storage engine.- Specified by:
getDataSizein interfaceHalfStorageEngine<T>- Returns:
- size of the stored keys and values in bytes
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
bind
public void bind(StorageEngine.Owner o, long m)
- Specified by:
bindin interfaceHalfStorageEngine<T>
-
destroy
public void destroy()
- Specified by:
destroyin interfaceHalfStorageEngine<T>
-
shrink
public boolean shrink()
- Specified by:
shrinkin interfaceHalfStorageEngine<T>
-
evictAtAddress
public java.util.Collection<java.lang.Long> evictAtAddress(long address, boolean shrink)- Specified by:
evictAtAddressin interfaceOffHeapStorageArea.Owner
-
writeLock
public java.util.concurrent.locks.Lock writeLock()
- Specified by:
writeLockin interfaceOffHeapStorageArea.Owner
-
isThief
public boolean isThief()
- Specified by:
isThiefin interfaceOffHeapStorageArea.Owner
-
moved
public boolean moved(long from, long to)- Specified by:
movedin interfaceOffHeapStorageArea.Owner
-
sizeOf
public int sizeOf(long address)
- Specified by:
sizeOfin interfaceOffHeapStorageArea.Owner
-
-