Interface StorageEngine<K,V>
-
- Type Parameters:
K- key type handled by this engineV- value type handled by this engine
- All Known Subinterfaces:
PersistentStorageEngine<K,V>
- All Known Implementing Classes:
FileBackedStorageEngine,LongStorageEngine,OffHeapBufferStorageEngine,PersistentSplitStorageEngine,PortabilityBasedStorageEngine,SerializableStorageEngine,SplitStorageEngine,StringStorageEngine
public interface StorageEngine<K,V>An object that encodes map/cache keys and values to integers.StorageEngineinstances can choose their own method of value/key encoding. Keys that are small enough to be fully encoded in theIntegerreturn can be stored directly in the table, others could be stored in some additional data structure.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceStorageEngine.Owner
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidattachedMapping(long encoding, int hash, int metadata)voidbind(StorageEngine.Owner owner)voidclear()Called to indicate that all keys and values are now free.voiddestroy()booleanequalsKey(java.lang.Object key, long encoding)Called to determine the equality of the given object against the given encoded form.booleanequalsValue(java.lang.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.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.voidinvalidateCache()Invalidate any local key/value caches.KreadKey(long encoding, int hashCode)Converts the supplied encoded key into its correct object form.VreadValue(long encoding)Converts the supplied encoded value into its correct object form.booleanshrink()java.lang.LongwriteMapping(K key, V value, int hash, int metadata)Converts the supplied key and value objects into their encoded form.
-
-
-
Method Detail
-
writeMapping
java.lang.Long writeMapping(K key, V value, int hash, int metadata)
Converts the supplied key and value objects into their encoded form.- Parameters:
key- a key objectvalue- a value objecthash- the key hashmetadata- the metadata bits- Returns:
- the encoded mapping
-
attachedMapping
void attachedMapping(long encoding, int hash, int metadata)
-
freeMapping
void freeMapping(long encoding, int hash, boolean removal)Called 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.
- Parameters:
encoding- encoded valuehash- hash of the freed mappingremoval- marks removal from a map
-
readValue
V readValue(long encoding)
Converts the supplied encoded value into its correct object form.- Parameters:
encoding- encoded value- Returns:
- a decoded value object
-
equalsValue
boolean equalsValue(java.lang.Object value, long encoding)Called 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.- Parameters:
value- a value objectencoding- encoded value- Returns:
trueif the value and the encoding are equal
-
readKey
K readKey(long encoding, int hashCode)
Converts the supplied encoded key into its correct object form.- Parameters:
encoding- encoded keyhashCode- hash-code of the decoded key- Returns:
- a decoded key object
-
equalsKey
boolean equalsKey(java.lang.Object key, long encoding)Called 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.- Parameters:
key- a key objectencoding- encoded value- Returns:
trueif the key and the encoding are equal
-
clear
void clear()
Called to indicate that all keys and values are now free.
-
getAllocatedMemory
long getAllocatedMemory()
Returns a measure of the amount of memory allocated for this storage engine.- Returns:
- memory allocated for this engine in bytes
-
getOccupiedMemory
long getOccupiedMemory()
Returns a measure of the amount of memory consumed by this storage engine.- Returns:
- memory occupied by this engine in bytes
-
getVitalMemory
long getVitalMemory()
Returns a measure of the amount of vital memory allocated for this storage engine.- Returns:
- vital memory allocated for this engine in bytes
-
getDataSize
long getDataSize()
Returns a measure of the total size of the keys and values stored in this storage engine.- Returns:
- size of the stored keys and values in bytes
-
invalidateCache
void invalidateCache()
Invalidate 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).
-
bind
void bind(StorageEngine.Owner owner)
-
destroy
void destroy()
-
shrink
boolean shrink()
-
-