org.terracotta.offheapstore.storage
Class PortabilityBasedHalfStorageEngine<T>

java.lang.Object
  extended by org.terracotta.offheapstore.storage.PortabilityBasedHalfStorageEngine<T>
All Implemented Interfaces:
HalfStorageEngine<T>
Direct Known Subclasses:
OffHeapBufferHalfStorageEngine

public abstract class PortabilityBasedHalfStorageEngine<T>
extends Object
implements HalfStorageEngine<T>

Author:
cdennis

Constructor Summary
PortabilityBasedHalfStorageEngine(Portability<? super T> portability)
           
 
Method Summary
 boolean equals(Object value, int encoding)
          Called to determine the equality of the given Java object value against the given encoded form.
abstract  void free(int encoding)
          Called to indicate that the associated encoded value is no longer needed.
 void invalidateCache()
          Invalidate any local key/value caches.
 T read(int encoding)
          Converts the supplied encoded value into its correct object form.
protected abstract  ByteBuffer readBuffer(int encoding)
           
 Integer write(T object, int hash)
          Converts the supplied value object into it's encoded form.
protected abstract  Integer writeBuffer(ByteBuffer buffer, int hash)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.terracotta.offheapstore.storage.HalfStorageEngine
bind, clear, destroy, getAllocatedMemory, getDataSize, getOccupiedMemory, getVitalMemory, shrink
 

Constructor Detail

PortabilityBasedHalfStorageEngine

public PortabilityBasedHalfStorageEngine(Portability<? super T> portability)
Method Detail

write

public Integer write(T object,
                     int hash)
Description copied from interface: HalfStorageEngine
Converts the supplied value object into it's encoded form.

Specified by:
write in interface HalfStorageEngine<T>
Parameters:
object - a value object
hash - the keys hash
Returns:
encoded value

free

public abstract void free(int encoding)
Description copied from interface: HalfStorageEngine
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.

Specified by:
free in interface HalfStorageEngine<T>
Parameters:
encoding - encoded value

read

public T read(int encoding)
Description copied from interface: HalfStorageEngine
Converts the supplied encoded value into its correct object form.

Specified by:
read in interface HalfStorageEngine<T>
Parameters:
encoding - encoded value
Returns:
a decoded value object

equals

public boolean equals(Object value,
                      int encoding)
Description copied from interface: HalfStorageEngine
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.

Specified by:
equals in interface HalfStorageEngine<T>
Parameters:
value - a value object
encoding - encoded value
Returns:
true if the value and the encoding are equal

readBuffer

protected abstract ByteBuffer readBuffer(int encoding)

writeBuffer

protected abstract Integer writeBuffer(ByteBuffer buffer,
                                       int hash)

invalidateCache

public void invalidateCache()
Description copied from interface: HalfStorageEngine
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).

Specified by:
invalidateCache in interface HalfStorageEngine<T>


Copyright © 2016. All Rights Reserved.