K - key type handled by this engineV - value type handled by this enginepublic class SplitStorageEngine<K,V> extends Object implements StorageEngine<K,V>
StorageEngine composed of two independent engines, one for the
keys, one for the values.StorageEngine.Owner| Modifier and Type | Field and Description |
|---|---|
protected HalfStorageEngine<? super K> |
keyStorageEngine |
protected HalfStorageEngine<? super V> |
valueStorageEngine |
| Constructor and Description |
|---|
SplitStorageEngine(HalfStorageEngine<? super K> keyStorageEngine,
HalfStorageEngine<? super V> valueStorageEngine)
Creates a composite storage engine, with independent key and value engines.
|
| Modifier and Type | Method and Description |
|---|---|
void |
attachedMapping(long encoding,
int hash,
int metadata) |
void |
bind(StorageEngine.Owner owner) |
void |
clear()
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) |
void |
destroy() |
static long |
encoding(int keyEncoding,
int valueEncoding) |
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.
|
void |
freeMapping(long encoding,
int hash,
boolean removal)
Called to indicate that the associated encoded value is no longer needed.
|
long |
getAllocatedMemory()
Returns a measure of the amount of memory allocated for this storage engine.
|
long |
getDataSize()
Returns a measure of the total size of the keys and values stored in this storage engine.
|
long |
getOccupiedMemory()
Returns a measure of the amount of memory consumed by this storage engine.
|
long |
getVitalMemory()
Returns a measure of the amount of vital memory allocated for this storage engine.
|
void |
invalidateCache()
Invalidate any local key/value caches.
|
static int |
keyEncoding(long encoding) |
K |
readKey(long encoding,
int hashCode)
Converts the supplied encoded key into its correct object form.
|
V |
readValue(long encoding)
Converts the supplied encoded value into its correct object form.
|
boolean |
shrink() |
String |
toString() |
static int |
valueEncoding(long encoding) |
Long |
writeMapping(K key,
V value,
int hash,
int metadata)
Converts the supplied key and value objects into their encoded form.
|
protected final HalfStorageEngine<? super K> keyStorageEngine
protected final HalfStorageEngine<? super V> valueStorageEngine
public SplitStorageEngine(HalfStorageEngine<? super K> keyStorageEngine, HalfStorageEngine<? super V> valueStorageEngine)
keyStorageEngine - storage engine for the keysvalueStorageEngine - storage engine for the valuespublic static <K,V> Factory<SplitStorageEngine<K,V>> createFactory(Factory<? extends HalfStorageEngine<K>> keyFactory, Factory<? extends HalfStorageEngine<V>> valueFactory)
public 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 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 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 void clear()
StorageEngineclear in interface StorageEngine<K,V>public long getAllocatedMemory()
StorageEnginegetAllocatedMemory in interface StorageEngine<K,V>public long getOccupiedMemory()
StorageEnginegetOccupiedMemory in interface StorageEngine<K,V>public long getVitalMemory()
StorageEnginegetVitalMemory in interface StorageEngine<K,V>public long getDataSize()
StorageEnginegetDataSize in interface StorageEngine<K,V>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>public void bind(StorageEngine.Owner owner)
bind in interface StorageEngine<K,V>public void destroy()
destroy in interface StorageEngine<K,V>public boolean shrink()
shrink in interface StorageEngine<K,V>public static int valueEncoding(long encoding)
public static int keyEncoding(long encoding)
public static long encoding(int keyEncoding,
int valueEncoding)
Copyright © 2015–2024. All rights reserved.