Class SplitStorageEngine<K,V>
- Type Parameters:
K- key type handled by this engineV- value type handled by this engine
- All Implemented Interfaces:
StorageEngine<K,V>
- Direct Known Subclasses:
PersistentSplitStorageEngine
StorageEngine composed of two independent engines, one for the
keys, one for the values.-
Nested Class Summary
Nested classes/interfaces inherited from interface StorageEngine
StorageEngine.Owner -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HalfStorageEngine<? super K> protected final HalfStorageEngine<? super V> -
Constructor Summary
ConstructorsConstructorDescriptionSplitStorageEngine(HalfStorageEngine<? super K> keyStorageEngine, HalfStorageEngine<? super V> valueStorageEngine) Creates a composite storage engine, with independent key and value engines. -
Method Summary
Modifier and TypeMethodDescriptionvoidattachedMapping(long encoding, int hash, int metadata) voidbind(StorageEngine.Owner owner) voidclear()Called to indicate that all keys and values are now free.static <K,V> Factory <SplitStorageEngine<K, V>> createFactory(Factory<? extends HalfStorageEngine<K>> keyFactory, Factory<? extends HalfStorageEngine<V>> valueFactory) voiddestroy()static longencoding(int keyEncoding, int valueEncoding) 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.voidfreeMapping(long encoding, int hash, boolean removal) Called to indicate that the associated encoded value is no longer needed.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.longReturns a measure of the amount of memory consumed by this storage engine.longReturns a measure of the amount of vital memory allocated for this storage engine.voidInvalidate any local key/value caches.static intkeyEncoding(long encoding) readKey(long encoding, int hashCode) Converts the supplied encoded key into its correct object form.readValue(long encoding) Converts the supplied encoded value into its correct object form.booleanshrink()toString()static intvalueEncoding(long encoding) writeMapping(K key, V value, int hash, int metadata) Converts the supplied key and value objects into their encoded form.
-
Field Details
-
keyStorageEngine
-
valueStorageEngine
-
-
Constructor Details
-
SplitStorageEngine
public SplitStorageEngine(HalfStorageEngine<? super K> keyStorageEngine, HalfStorageEngine<? super V> valueStorageEngine) Creates a composite storage engine, with independent key and value engines.- Parameters:
keyStorageEngine- storage engine for the keysvalueStorageEngine- storage engine for the values
-
-
Method Details
-
createFactory
public static <K,V> Factory<SplitStorageEngine<K,V>> createFactory(Factory<? extends HalfStorageEngine<K>> keyFactory, Factory<? extends HalfStorageEngine<V>> valueFactory) -
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 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
-
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
-
clear
public void clear()Description copied from interface:StorageEngineCalled to indicate that all keys and values are now free.- Specified by:
clearin interfaceStorageEngine<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
-
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>
-
bind
- Specified by:
bindin interfaceStorageEngine<K,V>
-
destroy
public void destroy()- Specified by:
destroyin interfaceStorageEngine<K,V>
-
shrink
public boolean shrink()- Specified by:
shrinkin interfaceStorageEngine<K,V>
-
valueEncoding
public static int valueEncoding(long encoding) -
keyEncoding
public static int keyEncoding(long encoding) -
encoding
public static long encoding(int keyEncoding, int valueEncoding)
-