Class PortabilityBasedHalfStorageEngine<T>

java.lang.Object
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>
  • Field Details

  • Constructor Details

    • PortabilityBasedHalfStorageEngine

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

    • 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>