public abstract class PortabilityBasedStorageEngine<K,V> extends AbstractListenableStorageEngine<K,V> implements StorageEngine<K,V>, BinaryStorageEngine
StorageEngine.Owner| Modifier and Type | Field and Description |
|---|---|
protected Portability<? super K> |
keyPortability |
protected Portability<? super V> |
valuePortability |
| Constructor and Description |
|---|
PortabilityBasedStorageEngine(Portability<? super K> keyPortability,
Portability<? super V> valuePortability)
Creates a storage engine using the given portabilities.
|
| Modifier and Type | Method and Description |
|---|---|
void |
attachedMapping(long encoding,
int hash,
int metadata) |
void |
clear()
Called to indicate that all keys and values are now free.
|
protected abstract void |
clearInternal() |
boolean |
equalsBinaryKey(ByteBuffer binaryKey,
long encoding) |
boolean |
equalsKey(Object key,
long encoding)
Called to determine the equality of the given object against the
given encoded form.
|
boolean |
equalsValue(Object value,
long encoding)
Called to determine the equality of the given Java object value against the
given encoded form.
|
protected abstract void |
free(long address) |
void |
freeMapping(long encoding,
int hash,
boolean removal)
Called to indicate that the associated encoded value is no longer needed.
|
protected abstract WriteContext |
getKeyWriteContext(long address) |
protected abstract WriteContext |
getValueWriteContext(long address) |
void |
invalidateCache()
Invalidate any local key/value caches.
|
ByteBuffer |
readBinaryKey(long encoding) |
ByteBuffer |
readBinaryValue(long encoding) |
K |
readKey(long encoding,
int hashCode)
Converts the supplied encoded key into its correct object form.
|
protected abstract ByteBuffer |
readKeyBuffer(long address) |
V |
readValue(long encoding)
Converts the supplied encoded value into its correct object form.
|
protected abstract ByteBuffer |
readValueBuffer(long address) |
Long |
writeBinaryMapping(ByteBuffer[] binaryKey,
ByteBuffer[] binaryValue,
int pojoHash,
int metadata) |
Long |
writeBinaryMapping(ByteBuffer binaryKey,
ByteBuffer binaryValue,
int pojoHash,
int metadata) |
Long |
writeMapping(K key,
V value,
int hash,
int metadata)
Converts the supplied key and value objects into their encoded form.
|
protected abstract Long |
writeMappingBuffers(ByteBuffer keyBuffer,
ByteBuffer valueBuffer,
int hash) |
protected Long |
writeMappingBuffersGathering(ByteBuffer[] keyBuffers,
ByteBuffer[] valueBuffers,
int hash) |
fireCleared, fireCopied, fireFreed, fireRecovered, fireWritten, hasListeners, hasRecoveryListeners, registerListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbind, destroy, getAllocatedMemory, getDataSize, getOccupiedMemory, getVitalMemory, shrinkreadKeyHashprotected final Portability<? super K> keyPortability
protected final Portability<? super V> valuePortability
public PortabilityBasedStorageEngine(Portability<? super K> keyPortability, Portability<? super V> valuePortability)
keyPortability - key type portabilityvaluePortability - value type portabilitypublic final Long writeMapping(K key, V value, int hash, int metadata)
StorageEnginewriteMapping in interface StorageEngine<K,V>key - a key objectvalue - a value objecthash - the key hashmetadata - the metadata bitspublic void attachedMapping(long encoding,
int hash,
int metadata)
attachedMapping in interface StorageEngine<K,V>public final void freeMapping(long encoding,
int hash,
boolean removal)
StorageEngineThis call can be used to free any associated resources tied to the lifecycle of the supplied encoded value.
freeMapping in interface StorageEngine<K,V>encoding - encoded valuehash - hash of the freed mappingremoval - marks removal from a mappublic final void clear()
StorageEngineclear in interface StorageEngine<K,V>public V readValue(long encoding)
StorageEnginereadValue in interface StorageEngine<K,V>encoding - encoded valuepublic boolean equalsValue(Object value, long encoding)
StorageEngine
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.
equalsValue in interface StorageEngine<K,V>value - a value objectencoding - encoded valuetrue if the value and the encoding are equalpublic K readKey(long encoding, int hashCode)
StorageEnginereadKey in interface StorageEngine<K,V>encoding - encoded keyhashCode - hash-code of the decoded keypublic boolean equalsKey(Object key, long encoding)
StorageEngine
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.
equalsKey in interface StorageEngine<K,V>key - a key objectencoding - encoded valuetrue if the key and the encoding are equalpublic ByteBuffer readBinaryKey(long encoding)
readBinaryKey in interface BinaryStorageEnginepublic ByteBuffer readBinaryValue(long encoding)
readBinaryValue in interface BinaryStorageEnginepublic boolean equalsBinaryKey(ByteBuffer binaryKey, long encoding)
equalsBinaryKey in interface BinaryStorageEnginepublic Long writeBinaryMapping(ByteBuffer[] binaryKey, ByteBuffer[] binaryValue, int pojoHash, int metadata)
writeBinaryMapping in interface BinaryStorageEnginepublic Long writeBinaryMapping(ByteBuffer binaryKey, ByteBuffer binaryValue, int pojoHash, int metadata)
writeBinaryMapping in interface BinaryStorageEngineprotected Long writeMappingBuffersGathering(ByteBuffer[] keyBuffers, ByteBuffer[] valueBuffers, int hash)
protected abstract void free(long address)
protected abstract void clearInternal()
protected abstract ByteBuffer readKeyBuffer(long address)
protected abstract WriteContext getKeyWriteContext(long address)
protected abstract ByteBuffer readValueBuffer(long address)
protected abstract WriteContext getValueWriteContext(long address)
protected abstract Long writeMappingBuffers(ByteBuffer keyBuffer, ByteBuffer valueBuffer, int hash)
public void invalidateCache()
StorageEngineThis 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).
invalidateCache in interface StorageEngine<K,V>Copyright © 2015–2024. All rights reserved.