Class OffHeapBufferStorageEngine<K,V>
java.lang.Object
org.terracotta.offheapstore.storage.listener.AbstractListenableStorageEngine<K,V>
org.terracotta.offheapstore.storage.PortabilityBasedStorageEngine<K,V>
org.terracotta.offheapstore.storage.OffHeapBufferStorageEngine<K,V>
- Type Parameters:
K- key type handled by this engineV- value type handled by this engine
- All Implemented Interfaces:
OffHeapStorageArea.Owner, BinaryStorageEngine, ListenableStorageEngine<K,V>, StorageEngine<K, V>
- Direct Known Subclasses:
SerializableStorageEngine, StringStorageEngine
public class OffHeapBufferStorageEngine<K,V>
extends PortabilityBasedStorageEngine<K,V>
implements OffHeapStorageArea.Owner
A generic ByteBuffer based key/value store.
This storage engine implementation uses Portability instances to
convert key/value instances in to ByteBuffers. The content of these
ByteBuffers are then stored in slices of a single large data area.
-
Nested Class Summary
Nested classes/interfaces inherited from class PortabilityBasedStorageEngine
PortabilityBasedStorageEngine.CachedEncode<K,V> Nested classes/interfaces inherited from interface StorageEngine
StorageEngine.Owner -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final intprivate static final intprotected StorageEngine.Ownerprotected final OffHeapStorageAreaprivate static final intFields inherited from class PortabilityBasedStorageEngine
keyPortability, valuePortability -
Constructor Summary
ConstructorsConstructorDescriptionOffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability) OffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) OffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold) OffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, float compressThreshold) OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability) Creates a storage engine using the given page source, and portabilities.OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold) OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, float compressThreshold) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidstatic <K,V> Factory <OffHeapBufferStorageEngine<K, V>> createFactory(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) static <K,V> Factory <OffHeapBufferStorageEngine<K, V>> createFactory(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold) static <K,V> Factory <OffHeapBufferStorageEngine<K, V>> createFactory(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) static <K,V> Factory <OffHeapBufferStorageEngine<K, V>> createFactory(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold) voiddestroy()evictAtAddress(long address, boolean shrink) protected voidfree(long address) longReturns a measure of the amount of memory allocated for this storage engine.longReturns a measure of the total size of the keys and values stored in this storage engine.protected WriteContextgetKeyWriteContext(long address) longReturns a measure of the amount of memory consumed by this storage engine.protected WriteContextgetValueWriteContext(long address) longReturns a measure of the amount of vital memory allocated for this storage engine.private WriteContextgetWriteContext(long address, int max) booleanisThief()booleanmoved(long from, long to) readKeyBuffer(long address) intreadKeyHash(long encoding) readValueBuffer(long address) booleanshrink()intsizeOf(long address) toString()protected LongwriteMappingBuffers(ByteBuffer keyBuffer, ByteBuffer valueBuffer, int hash) protected LongwriteMappingBuffersGathering(ByteBuffer[] keyBuffers, ByteBuffer[] valueBuffers, int hash) Methods inherited from class PortabilityBasedStorageEngine
attachedMapping, clear, equalsBinaryKey, equalsKey, equalsValue, freeMapping, invalidateCache, readBinaryKey, readBinaryValue, readKey, readValue, writeBinaryMapping, writeBinaryMapping, writeMappingMethods inherited from class AbstractListenableStorageEngine
fireCleared, fireCopied, fireFreed, fireRecovered, fireWritten, hasListeners, hasRecoveryListeners, registerListener
-
Field Details
-
KEY_HASH_OFFSET
private static final int KEY_HASH_OFFSET- See Also:
-
KEY_LENGTH_OFFSET
private static final int KEY_LENGTH_OFFSET- See Also:
-
VALUE_LENGTH_OFFSET
private static final int VALUE_LENGTH_OFFSET- See Also:
-
DATA_OFFSET
private static final int DATA_OFFSET- See Also:
-
HEADER_SIZE
private static final int HEADER_SIZE- See Also:
-
storageArea
-
owner
-
-
Constructor Details
-
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability) Creates a storage engine using the given page source, and portabilities.- Parameters:
width-intorlongbased enginesource- allocator used for storage allocationpageSize- internal (constant) page sizekeyPortability- key type portabilityvaluePortability- value type portability
-
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, float compressThreshold) -
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability) -
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, float compressThreshold) -
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) -
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold) -
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) -
OffHeapBufferStorageEngine
public OffHeapBufferStorageEngine(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold)
-
-
Method Details
-
createFactory
public static <K,V> Factory<OffHeapBufferStorageEngine<K,V>> createFactory(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) -
createFactory
public static <K,V> Factory<OffHeapBufferStorageEngine<K,V>> createFactory(PointerSize width, PageSource source, int pageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold) -
createFactory
public static <K,V> Factory<OffHeapBufferStorageEngine<K,V>> createFactory(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim) -
createFactory
public static <K,V> Factory<OffHeapBufferStorageEngine<K,V>> createFactory(PointerSize width, PageSource source, int initialPageSize, int maximalPageSize, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean thief, boolean victim, float compressThreshold) -
clearInternal
protected void clearInternal()- Specified by:
clearInternalin classPortabilityBasedStorageEngine<K,V>
-
free
protected void free(long address) - Specified by:
freein classPortabilityBasedStorageEngine<K,V>
-
readKeyBuffer
- Specified by:
readKeyBufferin classPortabilityBasedStorageEngine<K,V>
-
getKeyWriteContext
- Specified by:
getKeyWriteContextin classPortabilityBasedStorageEngine<K,V>
-
readValueBuffer
- Specified by:
readValueBufferin classPortabilityBasedStorageEngine<K,V>
-
getValueWriteContext
- Specified by:
getValueWriteContextin classPortabilityBasedStorageEngine<K,V>
-
getWriteContext
-
writeMappingBuffers
- Specified by:
writeMappingBuffersin classPortabilityBasedStorageEngine<K,V>
-
writeMappingBuffersGathering
protected Long writeMappingBuffersGathering(ByteBuffer[] keyBuffers, ByteBuffer[] valueBuffers, int hash) - Overrides:
writeMappingBuffersGatheringin classPortabilityBasedStorageEngine<K,V>
-
getAllocatedMemory
public long getAllocatedMemory()Description copied from interface:StorageEngineReturns a measure of the amount of memory allocated for this storage engine.- Specified by:
getAllocatedMemoryin interfaceStorageEngine<K,V> - Returns:
- memory allocated for this engine in bytes
-
getOccupiedMemory
public long getOccupiedMemory()Description copied from interface:StorageEngineReturns a measure of the amount of memory consumed by this storage engine.- Specified by:
getOccupiedMemoryin interfaceStorageEngine<K,V> - Returns:
- memory occupied by this engine in bytes
-
getVitalMemory
public long getVitalMemory()Description copied from interface:StorageEngineReturns a measure of the amount of vital memory allocated for this storage engine.- Specified by:
getVitalMemoryin interfaceStorageEngine<K,V> - Returns:
- vital memory allocated for this engine in bytes
-
getDataSize
public long getDataSize()Description copied from interface:StorageEngineReturns a measure of the total size of the keys and values stored in this storage engine.- Specified by:
getDataSizein interfaceStorageEngine<K,V> - Returns:
- size of the stored keys and values in bytes
-
toString
-
destroy
public void destroy()- Specified by:
destroyin interfaceStorageEngine<K,V>
-
shrink
public boolean shrink()- Specified by:
shrinkin interfaceStorageEngine<K,V>
-
evictAtAddress
- Specified by:
evictAtAddressin interfaceOffHeapStorageArea.Owner
-
isThief
public boolean isThief()- Specified by:
isThiefin interfaceOffHeapStorageArea.Owner
-
readKeyHash
public int readKeyHash(long encoding) - Specified by:
readKeyHashin interfaceBinaryStorageEngine
-
moved
public boolean moved(long from, long to) - Specified by:
movedin interfaceOffHeapStorageArea.Owner
-
sizeOf
public int sizeOf(long address) - Specified by:
sizeOfin interfaceOffHeapStorageArea.Owner
-
bind
- Specified by:
bindin interfaceStorageEngine<K,V>
-
writeLock
- Specified by:
writeLockin interfaceOffHeapStorageArea.Owner
-