Class PortabilityBasedStorageEngine<K,V>
- All Implemented Interfaces:
BinaryStorageEngine, ListenableStorageEngine<K,V>, StorageEngine<K, V>
- Direct Known Subclasses:
FileBackedStorageEngine, OffHeapBufferStorageEngine
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classNested classes/interfaces inherited from interface StorageEngine
StorageEngine.Owner -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Portability<? super K> private PortabilityBasedStorageEngine.CachedEncode<K, V> protected final Portability<? super V> -
Constructor Summary
ConstructorsConstructorDescriptionPortabilityBasedStorageEngine(Portability<? super K> keyPortability, Portability<? super V> valuePortability) Creates a storage engine using the given portabilities. -
Method Summary
Modifier and TypeMethodDescriptionvoidattachedMapping(long encoding, int hash, int metadata) final voidclear()Called to indicate that all keys and values are now free.protected abstract voidbooleanequalsBinaryKey(ByteBuffer binaryKey, long encoding) booleanCalled to determine the equality of the given object against the given encoded form.booleanequalsValue(Object value, long encoding) Called to determine the equality of the given Java object value against the given encoded form.protected abstract voidfree(long address) final voidfreeMapping(long encoding, int hash, boolean removal) Called to indicate that the associated encoded value is no longer needed.protected abstract WriteContextgetKeyWriteContext(long address) protected abstract WriteContextgetValueWriteContext(long address) voidInvalidate any local key/value caches.readBinaryKey(long encoding) readBinaryValue(long encoding) readKey(long encoding, int hashCode) Converts the supplied encoded key into its correct object form.protected abstract ByteBufferreadKeyBuffer(long address) readValue(long encoding) Converts the supplied encoded value into its correct object form.protected abstract ByteBufferreadValueBuffer(long address) writeBinaryMapping(ByteBuffer[] binaryKey, ByteBuffer[] binaryValue, int pojoHash, int metadata) writeBinaryMapping(ByteBuffer binaryKey, ByteBuffer binaryValue, int pojoHash, int metadata) final LongwriteMapping(K key, V value, int hash, int metadata) Converts the supplied key and value objects into their encoded form.protected abstract LongwriteMappingBuffers(ByteBuffer keyBuffer, ByteBuffer valueBuffer, int hash) protected LongwriteMappingBuffersGathering(ByteBuffer[] keyBuffers, ByteBuffer[] valueBuffers, int hash) Methods inherited from class AbstractListenableStorageEngine
fireCleared, fireCopied, fireFreed, fireRecovered, fireWritten, hasListeners, hasRecoveryListeners, registerListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BinaryStorageEngine
readKeyHashMethods inherited from interface StorageEngine
bind, destroy, getAllocatedMemory, getDataSize, getOccupiedMemory, getVitalMemory, shrink
-
Field Details
-
keyPortability
-
valuePortability
-
lastMapping
-
-
Constructor Details
-
PortabilityBasedStorageEngine
public PortabilityBasedStorageEngine(Portability<? super K> keyPortability, Portability<? super V> valuePortability) Creates a storage engine using the given portabilities.- Parameters:
keyPortability- key type portabilityvaluePortability- value type portability
-
-
Method Details
-
writeMapping
Description copied from interface:StorageEngineConverts the supplied key and value objects into their encoded form.- Specified by:
writeMappingin interfaceStorageEngine<K,V> - Parameters:
key- a key objectvalue- a value objecthash- the key hashmetadata- the metadata bits- Returns:
- the encoded mapping
-
attachedMapping
public void attachedMapping(long encoding, int hash, int metadata) - Specified by:
attachedMappingin interfaceStorageEngine<K,V>
-
freeMapping
public final void freeMapping(long encoding, int hash, boolean removal) Description copied from interface:StorageEngineCalled 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:
freeMappingin interfaceStorageEngine<K,V> - Parameters:
encoding- encoded valuehash- hash of the freed mappingremoval- marks removal from a map
-
clear
public final void clear()Description copied from interface:StorageEngineCalled to indicate that all keys and values are now free.- Specified by:
clearin interfaceStorageEngine<K,V>
-
readValue
Description copied from interface:StorageEngineConverts the supplied encoded value into its correct object form.- Specified by:
readValuein interfaceStorageEngine<K,V> - Parameters:
encoding- encoded value- Returns:
- a decoded value object
-
equalsValue
Description copied from interface:StorageEngineCalled to determine the equality of the given Java object value against the given encoded form.Simple implementations will probably perform a decode on the given encoded form in order to do a regular
Object.equals(Object)comparison. This method is provided to allow implementations to optimize this comparison if possible.- Specified by:
equalsValuein interfaceStorageEngine<K,V> - Parameters:
value- a value objectencoding- encoded value- Returns:
trueif the value and the encoding are equal
-
readKey
Description copied from interface:StorageEngineConverts the supplied encoded key into its correct object form.- Specified by:
readKeyin interfaceStorageEngine<K,V> - Parameters:
encoding- encoded keyhashCode- hash-code of the decoded key- Returns:
- a decoded key object
-
equalsKey
Description copied from interface:StorageEngineCalled to determine the equality of the given object against the given encoded form.Simple implementations will probably perform a decode on the given encoded form in order to do a regular
Object.equals(Object)comparison. This method is provided to allow implementations to optimize this comparison if possible.- Specified by:
equalsKeyin interfaceStorageEngine<K,V> - Parameters:
key- a key objectencoding- encoded value- Returns:
trueif the key and the encoding are equal
-
readBinaryKey
- Specified by:
readBinaryKeyin interfaceBinaryStorageEngine
-
readBinaryValue
- Specified by:
readBinaryValuein interfaceBinaryStorageEngine
-
equalsBinaryKey
- Specified by:
equalsBinaryKeyin interfaceBinaryStorageEngine
-
writeBinaryMapping
public Long writeBinaryMapping(ByteBuffer[] binaryKey, ByteBuffer[] binaryValue, int pojoHash, int metadata) - Specified by:
writeBinaryMappingin interfaceBinaryStorageEngine
-
writeBinaryMapping
public Long writeBinaryMapping(ByteBuffer binaryKey, ByteBuffer binaryValue, int pojoHash, int metadata) - Specified by:
writeBinaryMappingin interfaceBinaryStorageEngine
-
writeMappingBuffersGathering
protected Long writeMappingBuffersGathering(ByteBuffer[] keyBuffers, ByteBuffer[] valueBuffers, int hash) -
free
protected abstract void free(long address) -
clearInternal
protected abstract void clearInternal() -
readKeyBuffer
-
getKeyWriteContext
-
readValueBuffer
-
getValueWriteContext
-
writeMappingBuffers
-
invalidateCache
public void invalidateCache()Description copied from interface:StorageEngineInvalidate any local key/value caches.This is called to indicate the termination of a map write "phase". Caching is permitted within a write operation (i.e. to cache around allocation failures during eviction processes).
- Specified by:
invalidateCachein interfaceStorageEngine<K,V>
-